please help with Menu and Listener
|
QueenHeather Hancroft
Registered User
Join date: 26 Sep 2008
Posts: 20
|
09-20-2009 15:59
done as much as i could easily understand but had problem with saving the listener in the end so couldnt finish the project. [PROJECT] when you touch the rezbox it asks you to position it in the center of your land, then hopefully when you press DONE on the menu, i wanted it to ask HOWMANY boxes would i like to build. then HOW FAR APART would i like to build those boxes from each other. so like 10 boxes, 20m apart so a loop to rez each new box +20m apart each time. string HOWMANY; integer menu_channel; integer menu_handler;
menu(key user,string title,list buttons) { clean(); menu_channel = (integer)(llFrand(99999.0) * -1); menu_handler = llListen(menu_channel,"",user,""); llDialog(user,title,buttons,menu_channel); llSetTimerEvent(60.0); } clean() { llSetTimerEvent(0.0); llListenRemove(menu_handler); }
init() { llListen(0, "", llGetOwner(), ""); }
default { on_rez(integer start_param) { llResetScript();; } touch_start(integer total_number) { init() menu(llDetectedKey(0),"Please position the rezbox in the center of your land",["Done"]);
// menu should only appear when "DONE" is pressed so need to listen for it. menu(llDetectedKey(0),"Please Type How Many boxes you wish to build",["OK"]); }
timer() { llSetTimerEvent(0.0); clean(); } state_entry() { llOwnerSay("Loaded.") } }
im sure someone finds this alot easier than me so please help me along
|
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
|
09-20-2009 16:35
You need to add a listen event to capture the result of a menu button being clicked and the user's typing. The code will need to distinguish between "Done", "OK" and a number typed by the user, and respond appropriately. The number typed by the user will, I guess, be typed on channel 0, while the menu buttons will respond on menu_channel, so you can use the channel and message parameters of the listen event to figure out what the situation is. Either you will need seperate listeners, one for each channel, or a slingle listener listening to all channels. The second dialog should be triggered inside the listen event in reponse to the message from the first. That lot should keep you busy for a while  Feel free to ask more questions when you need to.
|
QueenHeather Hancroft
Registered User
Join date: 26 Sep 2008
Posts: 20
|
need help
09-20-2009 17:04
ok well ive done the listener now, second menu appears after done is pressed, stops the old listener and starts a new one on public chat. string HOWMANY; integer DISTANCE; integer menu_channel; integer menu_handler; menu(key user,string title,list buttons) { clean(); menu_channel = (integer)(llFrand(99999.0) * -1); menu_handler = llListen(menu_channel,"",user,""  ; llDialog(user,title,buttons,menu_channel); llSetTimerEvent(60.0); } clean() { llSetTimerEvent(0.0); llListenRemove(menu_handler); } init() { llListen(0, "", llGetOwner(), ""  ; } default { on_rez(integer start_param) { llResetScript(); } touch_start(integer total_number) { menu(llDetectedKey(0),"\nPlease position the rezbox in the center of your land",["Done"]); } timer() { llSetTimerEvent(0.0); clean(); } listen(integer channel, string name, key id, string message) { if (message == "Done"  { menu(id,"\nPlease Type How Many boxes you wish to build",["OK"]); clean(); // stop menu listener init(); // start public channel listener } } state_entry() { llOwnerSay("Loaded."  ; } } just a few steps away from being finished, but afew problems: need to detect what user says for "HOWMANY" then i need to ask the "DISTANCE BETWEEN EACH ONE" then i need to rez them
|
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
|
09-20-2009 17:50
From: QueenHeather Hancroft string HOWMANY = ""; integer DISTANCE = -1; listen(integer channel, string name, key id, string message) { if (message == "Done"  { menu(id,"\nPlease Type How Many boxes you wish to build",["OK"]); clean(); // stop menu listener init(); // start public channel listener } else if (message == "How many"  { //blah blah } else if (message == "How far"  { //blah blah } else { if (channel == 0) { if (HOWMANY = ""  HOWMANY = message;//NB you will need to vaidate this //and reject any messages that don't give a sensible number //and give the user another chance else if (DISTANCE = -1) DISTANCE = (integer) message;//and the same foor this } } } then i need to rez them I can't do indents on my setup in this forum, so that's not going to look good when you paste it; and I don't like the look of that last curly bracket either. I've given the two variables initial values so that we can compare them with a bit of confidence inside the listen event. I've added a few lines of ifs and elses to show how you can use the parameters from the listen event. What I do with the two variables is evil in the extreme; it will break at the slightest deviation from an expected input. And also imagine what'd happen if the user changed their mind somewhere during the process and went back to try to change it. Trying any actual rezzing is probably best left until you're confident of the parameters you're using, but that's shouldn't stop you from exprimenting with that in a different object and using hard-coded parameters. (PS) I should make it clear that I haven't even compiled this code, let alone run it 
|
QueenHeather Hancroft
Registered User
Join date: 26 Sep 2008
Posts: 20
|
09-21-2009 06:19
it now knows how many i want to build, however i couldnt make it read the distance. if anything it used the same variable for HOWMANY and DISTANCE, i tried resetting message back to blank but no good ----- string HOWMANY; string DISTANCE; integer menu_channel; integer menu_handler; menu(key user,string title,list buttons) { clean(); menu_channel = (integer)(llFrand(99999.0) * -1); menu_handler = llListen(menu_channel,"",user,""  ; llDialog(user,title,buttons,menu_channel); llSetTimerEvent(60.0); } clean() { llSetTimerEvent(0.0); llListenRemove(menu_handler); } init() { llListen(0, "", llGetOwner(), ""  ; } default { on_rez(integer start_param) { llResetScript(); } touch_start(integer total_number) { menu(llDetectedKey(0),"\nPlease position the rezbox in the center of your land",["Done"]); } timer() { llSetTimerEvent(0.0); clean(); } listen(integer channel, string name, key id, string message) { if (message == "Next"  { if (HOWMANY != " "  DISTANCE = (string)message; llSay(0,"building" + HOWMANY + " boxes " + DISTANCE + "m apart"  ; } if (message == "Done"  { menu(id,"\nPlease Type How Many Skyboxes you wish to build",["Next"]); clean(); // stop menu listener init(); // start public channel listener } if (channel == 0) { HOWMANY = (string)message; llSay(0,"building " + HOWMANY + " skyboxes "  ; message = " "; menu(llDetectedKey(0),"\nEnter How far apart in meters to build each one (e.g) 20",["next"]); } } state_entry() { llOwnerSay("Loaded."  ; } } yea i could just hardcode it and skip the menus, afterall its only for me. but i feel like im cheating myself
|
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
|
09-21-2009 07:50
From: someone if (HOWMANY != " "  DISTANCE = (string)message; In this test you are comparing HOWMANY with a single space " "; I think you need to comapre it with an empty string "". You can probably already see that this method of deciding which variable you want to get at is already getting messy. Condier using a global variable to make a note of which question has been asked... integer question; integer QUESTION_HOWMANY = 1; integer QUESTION_DISTANCE = 2; //etc then when you create at dialog... question = QUESTION_HOWMANY; llDialog (...); and in the listen event... if (channel == 0) { if (question == QUESTION_HOWMANY) HOWMANY = message; else if (question == QUESTION_DISTANCE) DISTANCE = message; //etc } I'd certainly encourage you to learn how to make menus; I find that the "user interface" is usually the hardest part of any script, and ultimately it's the ease of use that'll make or break any project. If you haven't already played with llRezObject, this links to its wiki page http://wiki.secondlife.com/wiki/LlRezObject. And if you haven't seen the LSL wiki, click the link for it near the top left of the page, marked "LSL Portal". The list of categories on the right of that page is invaluable.
|
raygold Carter
Registered User
Join date: 31 May 2008
Posts: 0
|
09-21-2009 13:55
integer HOWMANY = 3; string DISTANCE = "20";
default { touch_start(integer param) { integer n; for (n = 0;n < HOWMANY; n++) llRezObject("Object", llGetPos()+<0,0,0>, ZERO_VECTOR, ZERO_ROTATION, 42); } }
what do i change here for the object height when rezed
so i can increase it each time
|
QueenHeather Hancroft
Registered User
Join date: 26 Sep 2008
Posts: 20
|
09-21-2009 14:21
string HOWMANY = "2"; string DISTANCE = "20";
default { touch_start(integer param) { integer n; for (n = 0;n < (integer)HOWMANY; n++) { llRezObject("Object", llGetPos() + <0.0,0.0,1.0>, <0.0,0.0,0.0>, <0.0,0.0,0.0,1.0>, 0); } } }
This works, all the objects are rezed same position 1.0m above the mainobject.
i cant seem to replace <0.0,0.0,0.0,1.0> with DISTANCE tho
---
i wanted to to rez multiple boxes starting from 700m up in the sky, and space them out 20m apart each time
|
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
|
09-21-2009 19:13
From: QueenHeather Hancroft string HOWMANY = "2"; string DISTANCE = "20";
default { touch_start(integer param) { integer n; for (n = 0;n < (integer)HOWMANY; n++) { llRezObject("Object", llGetPos() + <0.0,0.0,1.0>, <0.0,0.0,0.0>, <0.0,0.0,0.0,1.0>, 0); } } }
This works, all the objects are rezed same position 1.0m above the mainobject.
i cant seem to replace <0.0,0.0,0.0,1.0> with DISTANCE tho
---
i wanted to to rez multiple boxes starting from 700m up in the sky, and space them out 20m apart each time To rez HOWMANY objects starting at DISTANCE seperated by an INTERVAL try this: for (n = 0; n < (integer) HOWMANY; n++) { llRezObject ("Object", llGetPos() + <0.0, 0.0, (integer) DISTANCE + ((integer) INTERVAL * n)>, ZERO_VECTOR, ZERO_ROTATION, 0); } Use the variables you've collected to calculate the positions the objects should be rezzed in. You can play with the individual components of the position vector. And it'd make sense to declare DISTANCE and HOWMANY as integers to begin with. In the menu script "cast" the string message to an integer when you do the assignment: HOWMANY = (integer) message;.
|
Viktoria Dovgal
…
Join date: 29 Jul 2007
Posts: 3,593
|
09-21-2009 19:21
One trouble you will run into with llRezObject, is that nothing will happen (not even an error message) if you try to rez something more than 10 meters away. The rezzed objects will have to move themselves into place after being created near the source, if you want those larger distances.
eta: you could also have this rezzing object zoom around the sim, if you don't want to deal with scripts in the rezzed items.
|
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
|
09-21-2009 19:25
Good point Viktoria, and one I'd forgotten. So, QueenHeather, start small; DISTANCE = 1, INTERVAL = 1, HOWMANY = 5.
|
QueenHeather Hancroft
Registered User
Join date: 26 Sep 2008
Posts: 20
|
09-22-2009 04:34
ah thats a big problem,
i need to rez 200 small 10x10 sky-boxes so dont have the time to do it myself and keep it all aligned
i like the mainobject flying around the sim idea hmm
|
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
|
09-22-2009 05:58
The skyboxes can be fitted with a very simple script that'll take them to their assigned height as soon as they are rezzed. You can use the start parameter passed to the on_rez event by llRezObject to tell the skybox how high to go.
|
QueenHeather Hancroft
Registered User
Join date: 26 Sep 2008
Posts: 20
|
09-23-2009 06:22
different subject but still about rezzing now,
im rezzing a group of items which aint linked together, and i dont fancy using buddycomponent as a solution.
i found this on the wiki
* rezzing an unlinked set (multiple objects/prims that were taken as one inventory item, but aren't linked together) is possible, but a rot other than ZERO_ROTATION will give unexpected results (the individual objects will be rotated but their positions won't match the rotation). *
i dont understand this, i get unexpected results eitherway. all individual items are rotated but the skybox itself doesnt match the rotation so no good basically,
what is the solution ?
----------------
i do have a different method of rezzing i dont fully understand but all the peices are where they should be atleast
only real problem is... the skybox itself isnt rezed directly-center above my (mainobject/rezzing platform)
thier must be an easier way to get the llGetPos than trial and error.
i doubt i can use a script to determine the vectors it if its a unlinked set?
i have to keep resorting to rezzing at random coords until i get it right.
|
QueenHeather Hancroft
Registered User
Join date: 26 Sep 2008
Posts: 20
|
09-23-2009 13:23
listen(integer channel, string name, key id, string message) { if ( message == "menu"  { anybody tell me how to make this so its not case sensitive, (menu / MENU MeNu)
|
Viktoria Dovgal
…
Join date: 29 Jul 2007
Posts: 3,593
|
09-23-2009 13:35
if (llToLower(message) == "menu"  The assortment of string functions in LSL is a little strange, it will be easier to bookmark this than memorize them: http://wiki.secondlife.com/wiki/Category:LSL_String
|
QueenHeather Hancroft
Registered User
Join date: 26 Sep 2008
Posts: 20
|
09-27-2009 09:28
ah thank you, i got a new problem touch_start(integer total_number) { string maxprims = ((string)llGetParcelMaxPrims(llGetPos(), FALSE)); string totalprimsused = ((string)llGetParcelPrimCount(llGetPos(), PARCEL_COUNT_TOTAL, FALSE)); // HAVING TROUBLE WITH THE LINE BELOW ? if (maxprims - totalprimsused) <= "30"  ; { llSay(0,"WUH OH SPAGETTIOS"  ; } } } im trying to take away the totalprimcount in use away from the maxprims being used on my parcel of land, to ensure thiers always atleast 30 prims spare before rezzing any objects for safety measures instead of sl returning my items i got syntax error so anybody see the problem?
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
09-27-2009 11:57
Sure. Your variables "maxprims" and "totalprimsused" are declared as type string. You can't expect to treat them as integers when you do an if test. What you want instead is .... touch_start(integer total_number) { integer maxprims = (llGetParcelMaxPrims(llGetPos(), FALSE)); integer totalprimsused = (llGetParcelPrimCount(llGetPos(), PARCEL_COUNT_TOTAL, FALSE));
// HAVING TROUBLE WITH THE LINE BELOW ?
if (maxprims - totalprimsused) <= 30); {
If you need them later as strings, recast them at that point.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
QueenHeather Hancroft
Registered User
Join date: 26 Sep 2008
Posts: 20
|
09-27-2009 15:16
good news is i can save it now, but im still having a little trouble. integer test = (maxprims - totalprimsused); llSay(0,(string)test); if (test > 257); { llSay(0,"no prims available"  ; } if (test < 257); { llSay(0,"plenty of prims spare"  ; } } } thiers 2 prims being used on the land, max is 257, heres the info when touched. 15:10] Object: 255 [15:10] Object: no prims available [15:10] Object: plenty of prims spare so since 255 is smaller than 257, shouldnt it just say plenty of prims spare? instead i recieve both messages, surely its either the one or the other hmm
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
09-27-2009 16:02
You have a couple of rogue semicolons in there. It should look like this .... if (test > 257) { // no semicolon after the if test llSay(0,"no prims available"  ; } if (test < 257) { // no semicolon after the if test llSay(0,"plenty of prims spare"  ; }
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
QueenHeather Hancroft
Registered User
Join date: 26 Sep 2008
Posts: 20
|
09-28-2009 06:31
having trouble posting a bit of code on this forum, cant attach notepad either, pain. keeps saying invalid post going to upload a txtfile to another host. http://willhostforfood.com/files4/6/1/7/6179830/rezzer.txtthis is apart of my project, for some reason it keeps rezzing my skybox twice. if it was a badbug it would keep doing it nonstop so im not sure how to fix. i think the problems just with the sensors at the bottom
|
QueenHeather Hancroft
Registered User
Join date: 26 Sep 2008
Posts: 20
|
09-28-2009 09:15
i havent fixed the problem from my last reply yet, but im working on multiple things and i created VIKTORIA DOVGALS suggestion of the mainrezzer zooming around the sim this works beautifully super fast, only problem i encountered is. first object was rezed starting from about 30 feet upto 70 it was meant to start from 700m up in the air !!! so i dont know whats wrong it all looks good to me integer STARTPOS = 700; integer HOWMANY = 5; integer DISTANCE = 15; default { touch_start(integer i) { llSetPos(llGetPos() + <0,0,STARTPOS>  ; // want to make z 700 realy not add to it integer n; for (n = 0;n < HOWMANY; n++) { llRezObject("Object", llGetPos() + <0.0,0.0,0.0>, <0.0,0.0,0.0>, <0.0,0.0,0.0,0.0>, 0); llSetPos(llGetPos() + <0,0,DISTANCE>  ; } llInstantMessage(llGetOwner(), "Operation Complete, now deleting main rezzerprim"  ; //llDie(); } } since land height starts from 22m it makes perfekt sence the first platform was so low in the sky, however still no reason for it to be because the position should have been set to 700 before the loop even began - just read somethings on the wiki, think it silenty fails because its to far apart. need to use warppos i think but dont understand it. grrr
|
QueenHeather Hancroft
Registered User
Join date: 26 Sep 2008
Posts: 20
|
09-28-2009 13:33
i managed to solve the last problem, i tore apart a long distance teleporter to do it. just back to the sensor rezzing duplicates now http://willhostforfood.com/files4/6/1/7/6179830/rezzer.txt
|