Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

I hear you knocking but ya cant come in

Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
11-26-2006 02:06
OK I'm ultra Newbie to scripting:

I'm trying to write a script trigger that can be sent from one prim to many prims (well actually only two). Basic scenarion is you Touch the trigger prim and it say a command to activates the others. The transmitter works but can't seem to make the reciever work.

Reciever test script:

// Door Lock Script -- based on JohnG Linden


integer gLockChannel = 9394834;
string gOpenMsg = "MSG_OPEN";


//
// states begin here
//

default
{
state_entry()
{
llSay( 0, "Reciever Script Running";);
llListen(gLockChannel, "", "", "";);
// and go to closed state
state door_closed;
}
}

state door_closed
{
listen(integer channel, string name, key id, string msg)
{
if ( msg == gOpenMsg )
{
llSay( 0, "Open Msg recieved";);
}
}
}

------------
Transmitter test script:

// Based on Door Lock Script -- JohnG Linden

//
integer gLockChannel = 9394834;
string gOpenMsg = "MSG_OPEN";
//

//
// States
//

default
{
state_entry()

{
llSay (0, "Transmitter Script Running";);
}

touch_start(integer num_touches)
{
llSay(gLockChannel, gOpenMsg);
llSay(0, "Open Message sent = " + gOpenMsg);
}
}

Can anyone assist please?

Tarak
:-)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-26-2006 03:16
From: Tarak Voss
OK I'm ultra Newbie to scripting:

I'm trying to write a script trigger that can be sent from one prim to many prims (well actually only two). Basic scenarion is you Touch the trigger prim and it say a command to activates the others. The transmitter works but can't seem to make the reciever work.

------------

Can anyone assist please?

Tarak
:-)



First things first, welcome to Scripting.
Secondly please read the sticky at the top of the forum concerning postign code.

use PHP tags to embed the code in a more readable format.

Now to answer your question...

Transmitter test script:
I havent changed this at all, just posted it with PHP tags
CODE

// Based on Door Lock Script -- JohnG Linden
//
integer gLockChannel = 9394834;
string gOpenMsg = "MSG_OPEN";
//

//
// States
//

default
{
state_entry()
{
llSay (0, "Transmitter Script Running");
}

touch_start(integer num_touches)
{
llSay(gLockChannel, gOpenMsg);
llSay(0, "Open Message sent = " + gOpenMsg);
}
}



Reciever test script:
You need to make the receivers listen to the transmitter which you do set up, however its only set up in state default not in the other states. Listens are state specific.
For the code fragments you have posted you dont actually need two states, but I have retained it so you can see the differences more easily.


CODE


// Door Lock Script -- based on JohnG Linden
integer gLockChannel = 9394834;
string gOpenMsg = "MSG_OPEN";


//
// states begin here
//

default
{
state_entry()
{
llSay( 0, "Reciever Script Running");
// and go to closed state
state door_closed;
}
}

state door_closed
{
state_entry()
{
llListen(gLockChannel, "", "", "");
}

listen(integer channel, string name, key id, string msg)
{
if ( msg == gOpenMsg )
{
llSay( 0, "Open Msg recieved");
}
}
}
Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
11-26-2006 04:11
Thanks for that - I shall try to be more attentive next time to the Forum requirements - my appologies.

Tarak
:-)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
11-26-2006 04:16
LOL, sorry didnt mean to make it sound like a chastisement. Using the PHP tags makes it far easier to read as it retains the indentation and colour syntax highlights the code.