|
Clinton Bulan
Registered User
Join date: 9 Oct 2006
Posts: 22
|
04-23-2007 16:39
So, I'm trying to have an object recognize when someone sits on it then store their key to be sent via linked messge. Then recognize when that person stands up yet retain that key until someone else sits down. Apparently I'm a complete moron when it comes to setting "if" statements on "changed_link" conditionals because I can't get it to not fire off both "if"s the second someone sits down. I see why it isn't working but I can't get it to do otherwise. I want the first "if" to trigger when someone sits down and the second "if" when that same person stands up. Also, I've tried storing the key in a list but that just fails and returns a null key. Here's the totally borked, ghetto code I've got thrown together: key currentAVkey = NULL_KEY; string status = "false"; list Listlastkey = [llAvatarOnSitTarget()]; key lastuser = NULL_KEY; default { state_entry() { llSetSitText("Do something"); }
changed(integer change) { lastuser = llList2Key(Listlastkey, 0); if (CHANGED_LINK && status == "false") { llMessageLinked(blah blah blah, lastuser); status = "true"; } if (status = "true") { llMessageLinked(blah blah blah, lastuser); status = "false"; } }}
|
|
Ravanne Sullivan
Pole Dancer Extraordinair
Join date: 10 Dec 2005
Posts: 674
|
04-23-2007 16:58
I think this may be more in line with what you are trying to accomplish, if someone sits on the target it sets lastuser to their key and sets status to TRUE. When they get off it sets status to FALSE yet retains the key of the last avatar to sit on it. integer status = FALSE; key lastuser = NULL_KEY; default { state_entry() { llSetSitText("Do something"); }
changed(integer change) { if (CHANGED_LINK && (llAvatarOnSitTarget() != NULL_KEY)) { lastuser = llAvatarOnSitTarget(); llMessageLinked(blah blah blah, lastuser); status = TRUE; } if (CHANGED_LINK && (llAvatarOnSitTarget() == NULL_KEY)) { llMessageLinked(blah blah blah, lastuser); status = FALSE; } }}
|
|
Clinton Bulan
Registered User
Join date: 9 Oct 2006
Posts: 22
|
04-23-2007 17:12
Seems to be that using the llAvatarOnSitTarget as a "!=" doesn't work because no one is actually currently seated on the prim when the code fires off....at least thats what looks like is happening. I put simple llSay statements after each if to see which was working and I'm only getting the llSay from the 2nd "if". Thanks for the idea though 
|
|
Ravanne Sullivan
Pole Dancer Extraordinair
Join date: 10 Dec 2005
Posts: 674
|
04-23-2007 17:29
What is missing from your code is a sit target statement, llAvatarOnSit Target() won't work without it,. And this should be better, its what I get for trying to do too many things at one time.  integer status = FALSE; key lastuser = NULL_KEY; default { state_entry() { llSetSitText("Do something"); llSitTarget(target * (ZERO_ROTATION / llGetRot()),ZERO_ROTATION / llGetRot()); }
changed(integer change) { if (CHANGED_LINK) { key curAV = llAvatarOnSitTarget(); if (curAV != NULL_KEY) { lastuser = curAV; llMessageLinked(blah blah blah, lastuser); status = TRUE; } else { llMessageLinked(blah blah blah, lastuser); status = FALSE; } } } }
|
|
Clinton Bulan
Registered User
Join date: 9 Oct 2006
Posts: 22
|
04-23-2007 18:32
hhhmmm nothin' errored in a few places too. I had to change a few lines to get it to compile. Here's what I'm looking at currently. Sitting and standing doesn't trigger the llSay commands but again I'm not seeing why. SLS, love it... integer status = FALSE; key curAV = NULL_KEY; default { state_entry() { llSetSitText("Do something"); llSitTarget(<0.0, 0.0, 1.0>, ZERO_ROTATION); }
changed(integer change) { if (CHANGED_LINK) { key curAV = llAvatarOnSitTarget(); if (curAV != NULL_KEY) { llMessageLinked(yada yada ya, curAV); status = TRUE; llSay(0, "Sit"); } else { llMessageLinked(yada yada ya, curAV); status = FALSE; llSay(0,"Stand"); } } }}
|
|
Ravanne Sullivan
Pole Dancer Extraordinair
Join date: 10 Dec 2005
Posts: 674
|
04-24-2007 01:38
The reason why is probably that your script is not running. Your llMessageLinked(yada yada ya, curAV); line is incorrect. The following works perfectly. integer status = FALSE; key lastuser = NULL_KEY; default { state_entry() { llSetSitText("Do something"); llSitTarget( <0.0,0.0,-0.6>, ZERO_ROTATION); }
changed(integer change) { if (CHANGED_LINK) { key curAV = llAvatarOnSitTarget(); if (curAV != NULL_KEY) { lastuser = curAV; llSay(0,"Sit " + (string)lastuser); status = TRUE; } else { llSay(0,"Stand " + (string)lastuser); status = FALSE; } } } }
|