Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Creating Objects

rubiq Campbell
Registered User
Join date: 4 Apr 2006
Posts: 22
05-03-2006 08:00
I am new in second life and would like to create two objects and make them interact.
Neb Soyer
Really good looking.
Join date: 9 Apr 2006
Posts: 45
05-03-2006 08:20
You really need to be more specific. If you be more specific I can help you.

:cool:
_____________________
down in the ghetto.
rubiq Campbell
Registered User
Join date: 4 Apr 2006
Posts: 22
05-03-2006 08:27
I have created two objects and would like to touch one of the objects and make the other object lets say for example start rotating or do something else. Thanks
Deneb Rosewood
Registered User
Join date: 2 Feb 2006
Posts: 15
05-03-2006 08:44
This is a VERY complicated idea when you get into it, I give myself headaches trying to make two prims interact, but that's just me, my scripts get pretty complicated. Some people catch on really easy, while I need to draw blueprints and keep them forever so I have a plan of attack in which to keep to. I'll throw up a quick example:

OBJECT1 (click me!)
CODE

integer timesclicked;
default
{
state_entry()
{
}

touch_start(integer total_number)
{
timesclicked++;
llSetText("Click me! (clicked " + (string)timesclicked + " times.)", <1, 1, 1>, 1);
llSay(821,"clickified " + (string)timesclicked);
// object says "/821 clickified #" where # is the number of times clicked.
}
}



OBJECT2 (Hey, you clicked him!)
CODE

integer timesclicked;
default
{
state_entry()
{
llListen(821, "OBJECT1", "", "");
// All that matters is the Say and Listen have the same channel number, and that it's NOT
// ZERO!!! (channel 0 is out loud chat, and causes lag with listener scripts)
}
listen(integer channel, string name, key id, string msg)
{
if (llToLower(llGetSubString(msg, 0, 9)) == "clickified")
{
timesclicked = llGetSubString(msg, 11, -1);
llSetText("That prim was clicked " + (string)timesclicked + " times.", <1,1,1>,1);
}
}
}


Explaining the listen command: First, remember in the ingame editor you can hold your mouse over the command and it'll tell you correct usage and a brief explination of the command.
The two numbers in the getsubstring things (0,9 and 11,-1) represent where in the message to check. Example: "yay words" would be substring 0,2 = "yay", 3 is a space, and 4,-1 = "words". -1 tells it to take the entire remaining message.

Important: You notice I actually counted the number of letters in clickified, this is because if I'd have simply used -1 to get the entire message: it would NOT == "clickified" (it would == "clickified #", wouldn't work.)

[edit] *edited several times to ensure accuracy and grammer...*