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!)
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!)
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...*