|
Alasdair Magic
Registered User
Join date: 18 Jul 2008
Posts: 2
|
03-27-2009 20:51
alright, the preamble, Don't flame me for a noob even though I am. I have a question that is likely so simple it's stupid, but I have spent several hours crawling through the posts and the wiki and still I cannot find an answer so I thought I'd paint a target and post the question here.
I am trying to get an object when touched to relay the touched state to others in the linked set, I have used the simple linkmessage script and can get the other prims to say they have been touched but not sure how to generate the change in state to touched from the linked message script.
in essence a childs merry go round with counter rotatind seats, you touch the one piece and it starts the base rotating and simultaneously the seats rotating as they revolve around the base...
any idea what I need to generate the change in state on the sender and receiver ends of the linked message
|
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
03-27-2009 21:34
Ok, first off, touching isn't a state, it's an event. States are something else, but, you're already where you need to be if you have the touch_start sending a link message to the other prims. script 1: default { state_entry() { // whatever... }
touch_start (integer foo) { llMessageLinked (LINK_ALL_OTHERS, 0, "start", NULL_KEY); } }
script 2: default { state_entry() { // whatever... }
link_message( integer sender_num, integer num, string str, key id ) { if (str == "start") { // put start code here } if (str == "stop") { // put stop code here } } }
You might be starting the rotation in the touch_start() event for the touched object, but that doesn't mean you HAVE to have it in a touch_start() in the other scripts in other objects. when you touch the first object, start the rotation, and send the link message, which will trigger the link_message() event, and the start/stop code will reside in the link_message event in the other(s). hope that helps. Also, you're probably going to want touching act as a toggle to start/stop the ride, so you're going to want something like this in the first script...
integer toggle = FALSE;
default { state_entry() { // whatever... }
touch_start (integer foo) { if (toggle) // if toggle is TRUE { // code to start the rotation here... llMessageLinked (LINK_ALL_OTHERS, 0, "start", NULL_KEY); // tell others to start toggle = FALSE; // flip the toggle so next time other condition triggers } if (!toggle) // if toggle is FALSE { // code to stop the rotation goes here... llMessageLinked (LINK_ALL_OTHERS, 0, "stop", NULL_KEY); // tell others to stop toggle = TRUE; // flip the toggle so next time other condition triggers } } }
_____________________
My tutes http://www.youtube.com/johanlaurasia
|
|
Alasdair Magic
Registered User
Join date: 18 Jul 2008
Posts: 2
|
03-27-2009 22:24
thanks a lot, that does help, I'll take a look at what I have and see if I can make it go like I want it to. If i get stuck I'll post it here, I know it's easier to work with the code someone is using or trying to use.
|