Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Links and Scripts confusion

Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
03-10-2007 08:15
I am having difficulty understanding what is happening to the construction described below.

Create two boxes and link them.
In the ROOT put the text of the sender_script in the attachment.
In the CHILD put the text of the receiver_script.

Take the object into inventoryand then rezz it.
Clicking on the root will send a message to the child. It changes to a transmitter and will send a message to the root when clicked.

OK so far. Now the child is supposed to stop being a transmitter after the click which sends a message. so click the child twice, it sends a message again.

WHY?
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
03-10-2007 09:37
hard to say without seeing the scripts.

Object B needs to ignore the touch after sending. You could do that by using a global variable to keep track, or using a separate state.
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
03-10-2007 09:41
It's difficult to say without seeing your code.

When you say "changes to a transmitter," does this involve a change of state? All I can think of atm is that if your child changes state from "transmitter" to "receiver", and if the receiver state contains no touch event handler, it's touches are being passed to the root, and it's the root which is sending a message when the child is touched the second time. (This can be prevented by adding llPassTouches( FALSE ) to the "receiver" state_entry )

But again, this is all conjecture, without seeing the code or knowing if there's a clear indication of which object is sending messages.
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
03-10-2007 10:09
Sorry the upload of the attachment failed for some reason. I have included it inline.

//Sender_script
default
{
state_entry()
{
llOwnerSay("Hello, default state.";);
llOwnerSay("Switching to transmitter state.";);
state transmitter;
}
on_rez(integer start_param)
{
state transmitter;
}
}

state transmitter
{
state_entry()
{
llOwnerSay("Transmitter state.";);
}

touch_start(integer total_number)
{
llOwnerSay("Transmitting 'abc' to box 2.";);
llMessageLinked(2,0,"abc",NULL_KEY);
llOwnerSay("Switching to receiver state.";);
state receiver;
}
}

state receiver
{
state_entry()
{
llOwnerSay("Receiver state.";);
}

link_message(integer sender_num, integer num, string str, key id)
{
if((sender_num == 2) && (num == 0))
{
llSay(0,str + " received from box " + (string)sender_num);
llSay(0,"Switching to transmitter state.";);
state transmitter;
}
}
}

// Receiver_script
default
{
state_entry()
{
llOwnerSay( "Hello, default state.";);
llOwnerSay( "Switching to receiver state.";);
state receiver;
}
on_rez(integer start_param)
{
state receiver;
}
}

state receiver
{
state_entry()
{
llOwnerSay( "Receiver state.";);
}

link_message(integer sender_num, integer num, string str, key id)
{
if((sender_num == 1) && (num == 0))
{
llOwnerSay(str + " received from box " + (string)sender_num);
llOwnerSay("Switching to transmitter state.";);
state transmitter;
}
}
}

state transmitter
{
state_entry()
{
llOwnerSay( "Transmitter state.";);
}

touch_start(integer total_number)
{
llOwnerSay( "Transmitting 'def' to box 1.";);
llMessageLinked(1,0,"def",NULL_KEY);
llOwnerSay( "Switching to receiver state.";);
state receiver;
}
}

Hope that helps
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
03-10-2007 10:17
From: Deanna Trollop
It's difficult to say without seeing your code.

When you say "changes to a transmitter," does this involve a change of state? All I can think of atm is that if your child changes state from "transmitter" to "receiver", and if the receiver state contains no touch event handler, it's touches are being passed to the root, and it's the root which is sending a message when the child is touched the second time. (This can be prevented by adding llPassTouches( FALSE ) to the "receiver" state_entry )

But again, this is all conjecture, without seeing the code or knowing if there's a clear indication of which object is sending messages.



I think you have given me the answer although I am on the point of testing it.
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
03-10-2007 10:30
Further info
The llPassTouches(FALSE) is indeed the solution to my problem.

The following code needs to be added to the receiver state section of each script.

touch_start(integer total_number)
{
llPassTouches(FALSE);
}