Tomkinson Posted November 15, 2012 Share Posted November 15, 2012 I am having some trouble with my code. On my island is a clock that tells the time in GMT, it also uses llRegionSay to broadcast the raw seconds since midnight. I've got a box that listens for the time and at a certain trigger time turns from black to red. I want to be able to set that trigger without having to go into the script to change it so I am trying to get it to listen to another channel to set that time. For some reason though it's not working and I can't work out why. It seems to store the number I say to it on channel 3 and will set itself to black when I try and change the colour. When the number comes up that it's waiting for though it does nothing. Can anyone help? string lecture; default { state_entry() { llSay(0, "Hello, Avatar!"); llListen(2, "", "", ""); llListen(3, "", "", ""); lecture = "1"; } touch_start(integer total_number) { llSay(0, lecture); } listen(integer channel, string name, key id, string message) { if(channel == 2) { if(message == lecture) { llSetColor(<1.0, 0.0, 0.0>, ALL_SIDES); llSleep(60.0); } else { llSetColor(<0.0, 0.0, 0.0>, ALL_SIDES); } } if(channel == 3) { lecture = message; } else { } } } Link to comment Share on other sites More sharing options...
xtc4u Posted November 15, 2012 Share Posted November 15, 2012 What you are saying is that if you pass "doit" for instance on channel 3, then a subsequent message of "doit" on channel 2 will not set the color to red? The only thing I can think if is that you are sending the message to channel 3 before the 60 second llSleep after sending a message to channel 3 has timed out. Link to comment Share on other sites More sharing options...
xtc4u Posted November 15, 2012 Share Posted November 15, 2012 I meant the llSleep on the "channel 2 has timed out." Link to comment Share on other sites More sharing options...
Tomkinson Posted November 15, 2012 Author Share Posted November 15, 2012 Yes that is exactly it. Well it should only sleep if the cube manages to turn red, which it never does. I can't for the life of me work out why though. Link to comment Share on other sites More sharing options...
Ron Khondji Posted November 15, 2012 Share Posted November 15, 2012 I would start with making sure the received messages are the expected messages. Add something like: llOwnerSay("Message on channel " + (string)channel + " is: " + message); in your listen event. 1 Link to comment Share on other sites More sharing options...
Qie Niangao Posted November 15, 2012 Share Posted November 15, 2012 Yes, I think the messages being sent aren't what this script is expecting, because just typing stuff at it in channels 3 and 2 seems to work as expected (although that 60 sec sleep makes it annoying to test). Link to comment Share on other sites More sharing options...
Rolig Loon Posted November 15, 2012 Share Posted November 15, 2012 You have a few of things going on. First, you are sending the message "lecture" by triggering a touch event and then expecting to hear the result in a listen event in the same script. That's not ever going to work. A script can't listen to itself except in the particular case of a dialog or textbox. In this case, it's really not going to work because you are sending the message on the public chat channel (0) and you don't have a listener open on that channel at all. Second, you are sending "lecture" as a string and seem to be intending to use it as an integer. It can't be both at the same time. At some point you have to write (integer) lecture to convert it. Third, xtc4u is right: llSleep is blocking your script from hearing anything while it's active. It does exactly what it says. The entire script goes to sleep, unable to listen, respond to any stimuli, or do anything. Miss that window and it will never hear a thing. Link to comment Share on other sites More sharing options...
Tomkinson Posted November 15, 2012 Author Share Posted November 15, 2012 Brilliant, fixed. The time was being shouted with 6 decimal places on the end of it and I wasn't listening for the decimal places. So it differentiated between 60300.000000 and 60300 for instance. Easy fix. Can't believe I missed it. :matte-motes-smile: Link to comment Share on other sites More sharing options...
Tomkinson Posted November 15, 2012 Author Share Posted November 15, 2012 The touch event was just me feeding back to myself that 'lecture' had been set to the correct value. The sleep part is so that the 'light' that it is to become stays on for a minute. :-) Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now