|
Johnnytreadlightly Nightfire
Registered User
Join date: 1 Jun 2008
Posts: 11
|
01-10-2009 01:31
I wrote this script for building walls. I wanted to give another option to purchasers or renters to modify their own homes using my textures. Works like a champ.....except when I pick up a building and put it back down, only some of the scripts work whereas they all worked previously. I'm curious if this is a distance problem from the root prim as those near it seem to work and those farther out do not. I'm no expert coder, so please forgive any sloppy code in advance. My first post, be gentle. string sDialogMessage = "Would you like to open or close the window?"; list list_one = ["Open", "Closed", "No Window"]; ************************************************************************** integer iTimeout = 60; string sTimeoutMessage = "Sorry, your request timed out. Please, close the dialog-window and try again..."; integer channel = -1; integer iListenHandle = 0; default { on_rez(integer n) { llResetScript(); } state_entry() { channel -= llFloor(llFrand(10000000))+10; } touch_start(integer total_number) { integer sameGroup = llSameGroup(llDetectedKey(0)) ; key user = llDetectedKey(0); if (sameGroup){ iListenHandle = llListen(channel,"",user,""  ; llSetTimerEvent(iTimeout); llDialog(user, sDialogMessage, list_one, channel); } else{ } } timer() { llListenRemove(iListenHandle); llSetTimerEvent(0); } listen(integer c, string n, key i, string m) { if(m == "Open"  { llSetTexture("b85bdee4-db2a-c8eb-92c8-6f7a73e609e3", 1);//interior llSetTexture("d41aab05-a913-cc0b-a2dc-97cfe2bceaaf", 3);//exterior } if(m == "Closed"  { llSetTexture("94215143-455f-8787-bed7-8bbb6f595f61", 1); //interior llSetTexture("d76972fc-8c2a-9e3b-7ec8-ad35e1d3a3e6", 3); //exterior } if(m == "No Window"  { llSetTexture("42faa10e-a82f-98b4-c54d-fdb3a7a1d86d", 1); //interior llSetTexture("72e2c3c6-7e65-7c32-8962-160ea84fe3c9", 3); //exterior } } }
|
|
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
|
01-10-2009 07:50
From: Johnnytreadlightly Nightfire ... I'm curious if this is a distance problem from the root prim as those near it seem to work and those farther out do not. ...
Yes. If the distance between the root prim of the listening object and the dialog generating prim is greater than 20 meters when a button is pressed, the response will not be heard.
|
|
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
|
01-11-2009 04:03
I don't see anything inherently wrong with the script. I'd prefer to see an unconditional llListenRemove(iListenHandle) in the listen Event Handler as the listen is being re-established with every touch_start, but this doesn't explain your problem. I also don't see how simply moving the object would somehow make the distance rules behave differently. Resizing maybe, but not moving. So, having completely failed to help you, here's a different solution that doesn't use a dialog or listen.  This is a simple toggle script - each click will toggle between the Open and Close textures. More subtly, a double-click will present the No Window textures. Advantages: No dialog, no listen, less lag. Disadvantage: Double Clicks with SL objects are not very intuitive and, indeed, not very common - but I like them  integer WindowStatus; integer Clicks;
WindowControl(integer status) { if(status == 1) //open { llSetTexture("b85bdee4-db2a-c8eb-92c8-6f7a73e609e3", 1);//interior llSetTexture("d41aab05-a913-cc0b-a2dc-97cfe2bceaaf", 3);//exterior } else if(status == 0) // close { llSetTexture("94215143-455f-8787-bed7-8bbb6f595f61", 1); //interior llSetTexture("d76972fc-8c2a-9e3b-7ec8-ad35e1d3a3e6", 3); //exterior } else if(status == 2) // no window { llSetTexture("42faa10e-a82f-98b4-c54d-fdb3a7a1d86d", 1); //interior llSetTexture("72e2c3c6-7e65-7c32-8962-160ea84fe3c9", 3); //exterior WindowStatus = !WindowStatus; } }
default { on_rez(integer n) { WindowStatus = 1; // default to open WindowControl(WindowStatus); }
touch_start(integer total_number) { if (Clicks) { llSetTimerEvent(0.0); Clicks = FALSE; WindowControl(2); } else { llSetTimerEvent(0.5); Clicks = TRUE; } }
timer() { llSetTimerEvent(0.0); Clicks = FALSE; WindowControl(WindowStatus = !WindowStatus); } }
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
01-11-2009 07:18
assuming some or most of the windows are linked to the menu holder here's this. you may need to fix a few syntax errors as i'm not in world to check it. no need for a script in linked windows, just name them "window" without the quotes .and for unlinked windows, use the second script dropping it into any one of the windows on that linkset naming windows the same list list_one = ["Open", "Closed", "No Window"]; list interior = ["b85bdee4-db2a-c8eb-92c8-6f7a73e609e3", "94215143-455f-8787-bed7-8bbb6f595f61", "42faa10e-a82f-98b4-c54d-fdb3a7a1d86d"]; list exterior = ["d41aab05-a913-cc0b-a2dc-97cfe2bceaaf", "d76972fc-8c2a-9e3b-7ec8-ad35e1d3a3e6", "72e2c3c6-7e65-7c32-8962-160ea84fe3c9"];
************************************************** ************************
integer iTimeout = 60; string sTimeoutMessage = "Sorry, your request timed out. Please, close the dialog-window and try again..."; integer primchan = -9999; integer iListenHandle = 0; default { on_rez(integer n) { llResetScript(); }
}
touch_start(integer total_number) {
llListenRemove(iListenHandle); key user = llDetectedKey(0); integer sameGroup = llSameGroup(0); if (sameGroup){ channel -= llFloor(llFrand(10000000))+10; iListenHandle = llListen(channel,"",user,""); llSetTimerEvent(iTimeout); llDialog(user, sDialogMessage, list_one, channel); } else{
} }
timer() { llListenRemove(iListenHandle); llSetTimerEvent(0);
}
listen(integer c, string n, key id, string m) { integer index = llListFindList(list_one,[m]); llSetTexture(llList2string(interior,index),1); llSetTexture(llList2string(exterior,index),1); llShout(chan,m); integer i =llGetNumberOfPrims(); for( i ; i > 0 ; i--) { if(llGetLinkName(i) == llToLower("window")) { llSetLinkTexture(i,llList2string(interior,index),1); llSetLinkTexture(i,llList2string(exterior,index),1); } } }
for the unlinked windows list list_one = ["Open", "Closed", "No Window"]; list interior = ["b85bdee4-db2a-c8eb-92c8-6f7a73e609e3", "94215143-455f-8787-bed7-8bbb6f595f61", "42faa10e-a82f-98b4-c54d-fdb3a7a1d86d"]; list exterior = ["d41aab05-a913-cc0b-a2dc-97cfe2bceaaf", "d76972fc-8c2a-9e3b-7ec8-ad35e1d3a3e6", "72e2c3c6-7e65-7c32-8962-160ea84fe3c9"];
integer primchan = -9999; key owner;
default { on_rez(integer n) { llResetScript(); }
state_entry() { owner = llGetOwner(); llListen(primchan,"",NULL_KEY,""); }
listen(integer c, string n, key id, string m) { if(llGetOwnerKey(id) == owner) { integer index = llListFindList(list_one,[m]); llSetTexture(llList2string(interior,index),1); llSetTexture(llList2string(exterior,index),1); integer i =llGetNumberOfPrims(); for( i ; i > 0 ; i--) { if(llGetLinkName(i) == llToLower("window")) { llSetLinkTexture(i,llList2string(interior,index),1); llSetLinkTexture(i,llList2string(exterior,index),1); } } }
|
|
Johnnytreadlightly Nightfire
Registered User
Join date: 1 Jun 2008
Posts: 11
|
01-11-2009 20:52
I tried changing the root prim to near the center of the build. This seemed to work, though I'll need a different solution in some larger builds.
The touch and double click may be a possibility for me. As you say its hard to educate consumers on what they are not used to, hence the dialog.
The single script with named prims seems the most difficult for my particular need. While it would work if I wanted all my walls the same, I have textured multiple walls with the same concept. The idea was to veer from a simple curtain script into a more customizable option. If you want to move your bed over in the corner, you have the option to remove the windows just in that corner, etc. Difficult to explain without an inworld example. But nonetheless, I shall trudge on. If I work out a better solution I will post it here. Thank you all for your time and efforts.
|