Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

how to interact two objects

vikas Constantine
Registered User
Join date: 14 Jul 2008
Posts: 1
07-28-2008 00:02
2 objects within SL to interact. A good scenario is that an avatar walks up to a box object, he clicks on it, this action would cause a second box object to move or change its appearance. To take this further, an avatar is presented with 2 color options (blue and red) from a computer object and he chooses blue. A second object detects that an event has occurred and blue was selected. The second object's color appearance changes to blue.
Urrong Urnst
Registered User
Join date: 12 Jul 2008
Posts: 49
07-28-2008 00:18
Will the objects be linked or not? Anyway here is the script for two unlinked objects that can be placed anywhere in the sim and will still be working.

Object that will be cliked:

CODE

default
{
state_entry()
{
llListen(10, "","","");
}
touch_start(integer det)
{
llDialog(llDetectedKey(0), "Chose a color:", ["Red", "Green", "Blue"], 10);
}
listen(integer channel, string name, key id, string msg)
{
if(msg == "Red") llRegionSay(10, "Change Red");
else if(msg == "Green") llRegionSay(10, "Change Green");
else if(msg == "Blue") llRegion Say(10, "Change Blue");
}
}


Object that will change color:

CODE

default
{
state_entry()
{
llListen(10, "","","");
}
listen(integer channel, string name, key id, string msg)
{
if(msg == "Change Red") llSetColor(<1,0,0>, ALL_SIDES);
else if(msg == "Change Green") llSetColor(<0,1,0>, ALL_SIDES);
else if(msg == "Change Blue") llSetColor(<0,0,1>, ALL_SIDES);
}
}


This scripts werent compiled so they can have some syntax errors.