Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Phatom script

Krazzora Zaftig
Do you have my marbles?
Join date: 20 Aug 2005
Posts: 649
12-23-2005 13:31
I was trying to make a script that toggle the phantom setting in a prim. Problem is when I save it gives me an error. Can anyone tell me what I am doing wrong?

default
{
touch_start (integer total_number)
{
if(door)
{
door = false;
llSetPrimitiveParams([PRIM_PHANTOM, FALSE])
}
else
{
closed = true;
llSetPrimitiveParams([PRIM_PHANTOM, TRUE])
}
}
}
_____________________
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
12-23-2005 13:36
depends on what the error is, but i'd bet it has something to do with closed = TRUE; and possibly that it should be door = TRUE;
_____________________
Damien Took
Meat Popsicle
Join date: 3 Dec 2004
Posts: 151
12-23-2005 13:39
CODE

integer closed;

default
{
touch_start (integer total_number)
{
if(closed)
{
closed = false;
llSetPrimitiveParams([PRIM_PHANTOM, FALSE]);
}
else
{
closed = true;
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]);
}
}
}


Try that. :)
Krazzora Zaftig
Do you have my marbles?
Join date: 20 Aug 2005
Posts: 649
12-23-2005 13:43
Thanks Damien will try when I log in tonight.

Rickard the error according the script was actually at the { jsut above "else".
_____________________
Damien Took
Meat Popsicle
Join date: 3 Dec 2004
Posts: 151
12-23-2005 13:50
Krazzora,

No problem. That was probably the ";" you left out but the if statement wouldn't have worked properly either becaues you were evaluating one variable and setting another.
Hope that helps. :D
Krazzora Zaftig
Do you have my marbles?
Join date: 20 Aug 2005
Posts: 649
12-23-2005 14:00
Oops...is it obvious I suck at scripting. LMAO
_____________________
Damien Took
Meat Popsicle
Join date: 3 Dec 2004
Posts: 151
12-23-2005 14:13
;) No you don't suck.
It's a common mistake.

I've made huge scripts that would have run perfect had I not messed up 10 if statements...with the same error in each one :)

Trust me, you can program/script for years and still overlook the simple things.
I do it all the time...and it's my job :D
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
12-23-2005 14:24
yes, the semicolon is the bain of all C syntax programmers.
_____________________
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
12-23-2005 20:17
Well, you get used to semi-colons;

In fact, they become a part of your every day life;

But I do second the fact that even experienced programmers mess up often on even the simplest things;
_____________________
--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.
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
01-11-2006 10:29
From: Damien Took
CODE

integer closed;

default
{
touch_start (integer total_number)
{
if(closed)
{
closed = false;
llSetPrimitiveParams([PRIM_PHANTOM, FALSE]);
}
else
{
closed = true;
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]);
}
}
}


Try that. :)


Great I have been wondering how to do this, make an object (door) become phantom with a touch, but when I try this script I get an error message:

(8, 26) : ERROR : Name not defined within scope

Is there something missing from this script?
_____________________

VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240
http://shop.onrez.com/Archtx_Edo
Kayla Stonecutter
Scripting Oncalupen
Join date: 9 Sep 2005
Posts: 224
01-11-2006 12:01
From: ArchTx Edo
Great I have been wondering how to do this, make an object (door) become phantom with a touch, but when I try this script I get an error message, something undefined as I recall??

Is there something missing from this script?

Change the following lines..
CODE

closed = false;
closed = true;

to:
CODE

closed = FALSE;
closed = TRUE;
_____________________
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
Touch on off phantom
01-11-2006 14:01
From: Kayla Stonecutter
Change the following lines..
CODE

closed = false;
closed = true;

to:
CODE

closed = FALSE;
closed = TRUE;



Ahh great.

I was able to make the script work by rewriting it as follows:

CODE

default
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_PHANTOM, FALSE]); state phantom;
}
}
state phantom
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]); state default;
}
}




_____________________

VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240
http://shop.onrez.com/Archtx_Edo
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
01-11-2006 14:14
From: ArchTx Edo
I was able to make the script work by rewriting it as follows:
CODE
   ...code using states...
great work - and welcome to the wonderful world of states.
LSL is one of the few programming languages natively based on states. Continue using states as you have here and you will notice how much more readable and understandable your code becomes.