still need help : menu with sensor...
|
|
Marylou Lane
Registered User
Join date: 3 Mar 2007
Posts: 60
|
06-03-2007 08:13
hi ! I would like to put a script in a prim on the floor, that when the avatar comes in the land, he gets a notecard, a LM and there is a drop down menu which scrolls down to say welcome.... I tried something but it doesn't work... I took examples from other scripts to try to make something myself but nothing happens... I hope you understand what I mean... anyway I write the script here, if someone could look at it and try to modify it.. it would be nice... sorry, I'm trying to do myself, but I never learned scripting before SL so it's a little bit difficult for me, and in Wiki, I can see the functions of the codes but I don't understand how to use them... integer CHANNEL = 0; key id; list MENU_ENTREE = []; float range = 1; float rate = 1;
default { sensor(integer number_detected) { integer i; for(i=0;i<number_detected;i++) { if (llListFindList(MENU_ENTREE,[] ) != -1); { llDialog(llDetectedKey(0), "WELCOME...",MENU_ENTREE,CHANNEL); llListen(0,"","",""); llSay(0,"read the note that is given"); llSensorRepeat("","",AGENT,range,TWO_PI,rate); } } } listen(integer channel, string name,key id,string message) { if (llListFindList(MENU_ENTREE,[])!=-1) { llSay(0,"read the note please"); llGiveInventory(id,"LANDMARK"); llGiveInventory(id,"NOTECARD"); } } }
So... I know that's probably very false, but I tried.... I hope someone would be interested in correct my mistakes... thank you Marylou
|
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
06-03-2007 10:50
It's a very good try. No need to apologize, evry scripter started as a beginner. One basic problem is that you need a way to get it started. You need a state_entry() { } section. This will fire when your script resets. In there put the things that need to be initialized at the beginning, such as setting up an initial sensor scan and an llListen. Or, you might set up a timer that goes off maybe every 10 seconds. Then, in the timer event you do a scan. Last good advice. There is a tool called LSL-Editor. Search the forms and try to get it. It allows you to prototype scripts like this on your PC without being logged in to SL, and it is much faster and has excellent error messages. good luck, and don't be afraid to post followup questions for us teacher-type guys to answer  integer CHANNEL = 1010101; key id; list MENU_ENTREE = []; list MENU = ["OK"]; float range = 10; float rate = 10;
default { state_entry() { llSensorRepeat("","",AGENT,range,TWO_PI,rate); } sensor(integer number_detected) { integer i; for(i=0;i<number_detected;i++) { if (llListFindList(MENU_ENTREE,[] ) != -1); { llDialog(llDetectedKey(0), "WELCOME...Please read the note",MENU_ENTREE,CHANNEL); llGiveInventory(id,"LANDMARK"); llGiveInventory(id,"NOTECARD"); llListen(CHANNEL,"","",""); //llSay(0,"read the note that is given"); } } } listen(integer channel, string name,key id,string message) { if (llListFindList(MENU_ENTREE,[])!=-1) { llSay(0,"read the note please"); } }
}
|
|
Marylou Lane
Registered User
Join date: 3 Mar 2007
Posts: 60
|
06-05-2007 08:46
thank you Lee, it works half.... in fact, you don't receive the note and the landmark... but the menu is opening... I don't really know what I have to modify... for me it should give the note and th LM but it doesn't...
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
06-05-2007 09:58
Put the landmark/notecard back down in the listen() where the id passed in means something again and it should work (as long as they hit OK). That or set id to llDetectedKey(i) inside the for loop, and continue to pass id in. Also, change the existing llDetectedKey(0) to llDetectedKey(i) as right now if more than one avatar is sensed, only the first avatar will get a dialog, and it will try to open it for him/her multiple times. Also not sure what MENU_ENTREE is used for at all?? Looks like the original script you based from maybe had an allow list. You shouldn't need to check that. so try this: integer CHANNEL = 1010101; key id; list MENU = ["OK"]; float range = 10; float rate = 10;
default { state_entry() { //PI is sufficient due to how llSensorRepeat works llSensorRepeat("","",AGENT,range,PI,rate); //only need to add the listen once llListen(CHANNEL,"",NULL_KEY,""); }
sensor(integer number_detected) { integer i; for(i=0;i<number_detected;i++) { id=llDetectedKey(i); llDialog(id, "WELCOME...Please read the note",MENU_ENTREE,CHANNEL); //llSay(0,"read the note that is given"); } }
listen(integer channel, string name,key id,string message) { //IM them rather than say on open chat, out of courtesy for nearby users llInstantMessage(id,"read the note please"); //give them junk only if they hit OK, out of courtesty to them llGiveInventory(id,"LANDMARK"); llGiveInventory(id,"NOTECARD"); }
}
|
|
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
|
06-05-2007 09:59
After integer i;
try adding the next line:
id = llDetectedKey(0);
|
|
Marylou Lane
Registered User
Join date: 3 Mar 2007
Posts: 60
|
06-07-2007 07:17
nothing works ..... it don't give the LM nore the notecard, and the menu doesn't open.... I don't understand... I put a cylinder on the floor where people arrives with the menu, LM and notecard, I replace in the script with the notecard name and the LM name.... but it doesn't do anything when I arive in the land... I don't know whats hapening.... 
|
|
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
|
06-07-2007 07:29
Can you post the code again as is? Is it even compiling now?
|
|
Marylou Lane
Registered User
Join date: 3 Mar 2007
Posts: 60
|
06-07-2007 11:28
integer CHANNEL = 1010101; key id; list MENU = ["OK"]; float range = 10; float rate = 10; default { state_entry() { //PI is sufficient due to how llSensorRepeat works llSensorRepeat("","",AGENT,range,PI,rate); //only need to add the listen once llListen(CHANNEL,"",NULL_KEY,""); }
sensor(integer number_detected) { integer i; for(i=0;i<number_detected;i++) { id=llDetectedKey(i); llDialog(id, "WELCOME...Please read the note",MENU,CHANNEL); //llSay(0,"read the note that is given"); } }
listen(integer channel, string name,key id,string message) { //IM them rather than say on open chat, out of courtesy for nearby users llInstantMessage(id,"read the note please"); //give them junk only if they hit OK, out of courtesty to them llGiveInventory(id,"PLANETE DISCOPOLIS"); llGiveInventory(id,"Regles du PLANETE DISCOPOLIS"); }
}
here is the script like it is in my prim.... if you could help me.... thanks
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
06-07-2007 12:03
Ummm, by any chance, is the Running box at the bottom of the script editor not checked? This sure tries to give me stuff--over and over, because it doesn't check to see if it has already offered the stuff to me. Any chance you set the script to Not Running just to avoid the repetition, and forgot?
|
|
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
|
06-07-2007 12:19
Your script worked for me.
|
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
06-07-2007 12:38
*Hasn't look at the code yet*
Simple question, is the script set to running? Open script, little checkbox in the bottom left hand corner.
|
|
altic Plasma
Registered User
Join date: 15 Mar 2006
Posts: 118
|
06-07-2007 15:44
the way thats set up its going to continually spam everyone in range lol
|