Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Touch Disappear Script

Swati Culcomp
Registered User
Join date: 31 Oct 2005
Posts: 1
10-31-2005 19:38
I need a script that will make an object disappear when an avatar touches it.

I'm sure this is pretty simple, but I need a little help... if you could help, I'd appreciate it. Thanks!!!
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
10-31-2005 20:30
CODE


touch_start(integer number)
{
llSetAlpha(0.0, ALL_SIDES);
}

_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Tateru Nino
Girl Genius
Join date: 13 Sep 2005
Posts: 312
10-31-2005 20:59
Kenn's got it, unless by 'disappear' you mean 'softly and silently vanish away, never to be heard from again', ie: totally gone, forever. Boom.

In which case calling llDie(); instead of llSetAlpha(...) is what you want.
_____________________
Michelle Culcomp
Registered User
Join date: 26 Aug 2005
Posts: 6
invisible? disappears but comes back?
11-08-2005 22:41
this is interesting. so what if i wanted to make an object disapear but then come back if, say, a "start game over" button where there that make all of the vanished objects come back?
Cypher Olsen
Registered User
Join date: 7 Aug 2004
Posts: 54
11-08-2005 22:47
In that case, assuming the objects aren't linked... you'll need to have each object listen on a channel for the 'reappear' command, and then have the main object send that command when the game is over/reset.

if it's a timed thing... You could also use llSleep() to make each object reappear after a certain amount of time.

making it reappear is as simple as calling

llSetAlpha(1.0, ALL_SIDES);
Tateru Nino
Girl Genius
Join date: 13 Sep 2005
Posts: 312
11-08-2005 22:48
If you want the object to still exist, but be unable to be seen, that's llSetAlpha(). If you want the object destroyed (possibly to be re-rezzed by another object later) you want llDie().

llSetAlpha() changes the transparency of the prim calling it, anywhere between full and none. At full, you cannot see it. At none, it is visibly solid.

llDie() destroys the object calling it. Boom. Gone. Left-the-grid. If you want another one something or someone has to rez a replacement.

The latter will give you less clutter. Example: Chessboard.
A piece is taken, the piece can llDie(). When a new game is started, the board can rez a fresh set of pieces in their starting places.

Same chessboard with llSetAlpha(): The piece becomes transparent, and thus invisible, but is still right where it was. When a new game is started, each piece must be restored to visibility and moved back to the starting place.
_____________________
Michelle Culcomp
Registered User
Join date: 26 Aug 2005
Posts: 6
11-08-2005 23:36
ah, ok. well my objects won't change locations -- it's like a puzzle where the pieces disappear when touched to reveal another picture underneath. so it sounds like i could just do llSetAlpha() -- since the objects will reappear in the same places that they were before once the reset button is pressed.

not sure i understand "listening on a channel" -- any pointers? that script would be in the reset button touch script but what do i need to put in my script for the disappearing objects in order to "listen" for the "call to arms"? :)

this is very helpful -- thanks!
Gaz Hornpipe
Registered User
Join date: 29 Sep 2005
Posts: 36
11-09-2005 00:26
From: Michelle Culcomp
ah, ok. well my objects won't change locations -- it's like a puzzle where the pieces disappear when touched to reveal another picture underneath. so it sounds like i could just do llSetAlpha() -- since the objects will reappear in the same places that they were before once the reset button is pressed.

not sure i understand "listening on a channel" -- any pointers? that script would be in the reset button touch script but what do i need to put in my script for the disappearing objects in order to "listen" for the "call to arms"? :)

this is very helpful -- thanks!


CODE
integer channel = 889238;
integer listening;

default
{
state_entry()
{
listening = llListen(channel,"Name of Object to Listen To","","");
}

listen(integer channel, string name, key id, string message)
{
if(message == "reset game")
{
llSetAlpha(1.0,ALL_SIDES);
// if prim is part of a linked set use llSetLinkAlpha(llGetLinkNumber(),1.0,ALL_SIDES);
return;
}
}
}


CODE
integer channel = 889238;

default
{
touch_start(integer num_detected)
{
llShout(channel,"reset game");
}
}
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
11-09-2005 07:49
From: Michelle Culcomp
ah, ok. well my objects won't change locations -- it's like a puzzle where the pieces disappear when touched to reveal another picture underneath. so it sounds like i could just do llSetAlpha() -- since the objects will reappear in the same places that they were before once the reset button is pressed.
One potential problem here is that even though they are transparent they still exist, and will block touches on the object beneath. You may be better rezzing them.

To make things easier if the puzzle is something that's complex in three dimensions and easier to lay out by hand than computationally, create a control object that contains copies of all the pieces. After you set up the puzzle, have the control object call llSensor() to get the locations of all the pieces and stick them in a list...

CODE

touch_start(integer num)
{
if(llDetectedKey(0) == llGetOwner())
llSensor("", NULL_KEY, ACTIVE|PASSIVE|SCRIPTED, 3.0, PI);
else if(game_in_progress)
llWhisper(0, "Can't reset a game in progress.");
else
{
integer num = llGetListLength(objList);
integer i;
vector myPos = llGetPos();
rotation myRot = llGetRot();
for(i = 0; i < num; i+=3)
llRezObject(llList2String(objList,i),
myPos+llList2Vector(objList,i+1),
myRot*llList2Rot(objList,i+2), 0);
game_in_progress = 1;
}
}

sensor(integer num)
{
integer i;
vector myPos = llGetPos();
rotation myRot = llGetRot();
for(i = 0; i < num; i++)
{
string objName = llDetectedname(i);
if(llGetInventoryKey(objName)) // It's one of the objects I'm managing...
objList += [ objName, llDetectedPos(i)-myPos, llDetectedRot(i)/myRot ];
}
}
Michelle Culcomp
Registered User
Join date: 26 Aug 2005
Posts: 6
11-11-2005 15:24
ok, i'll give these different scripts a try and see what works the way i want it to and then i'll post again to let you know what ended up working for me (and i'll point you to it if you are curious!). thanks so much everyone!!