Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

vehicle states

Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-25-2007 07:50
i made a car/plane so when i say a command it changes the states of the vehical but im running into a problem

i say d wich ='s drive state and f ='s fight state, but here is the problem every time i say anything at all the vehical changes the state to flight, here is the basic mockup of the script

CODE

default
{
state_entry()
{
llListen(0,llGetOwner(),"")
state drive;
}
}
state drive
{
state_entry()
{
//vehicle stuff
}
{
//avatar get on vehicle stuff
listen(integer channel, string name, key id, string message)
{
if(message == "f");
{
llOwnerSay("Flight Active");
state flight;
}
}
//perm
{
//controls
}
}
state flight
{
state_entry()
{
llListen(0,"",llGetOwner,"");
}
}
//flight stuff
{
//avatar on vehical stuff
}
listen(integer channel, string name, key id, string message)
{
if(message == "d");
{
llOwnerSay("Drive Active");
state drive
}
}
//perm
{
//controls
}

and as i said in the above part, whenever i say anything atall in chat it switches the states to flight and only flight untill i say d for drive, could the posible probuly be that it is listeing for command before the permisions are true?
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-25-2007 14:57
bump...
back to first page :P

i still havent got it worked out, i have no idea what is wrong, i would post full code fut it about 500-600 lines, if you think you can help send me a IM in game
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
11-25-2007 14:59
Well, you don't have a semicolon after "state drive" so it shouldn't compile at all, to start with.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-25-2007 15:02
using semicolons in if tests is a bad no-no and causes script boo-boo's :D

if(message == "f";);

if(message == "d";);
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-25-2007 15:12
Actually wrong in just sooo many places. Either install LSLEditor or paste the script into the lslint site. Work through the list of wrongs point by point and recheck each time. Even then when you finish it still won't work correctly because you have a listen in default. When you changed states to Drive you lost that listen.

CODE

default
{
state_entry()
{

state drive;
}
}
state drive
{
state_entry()
{
//vehicle stuff
llListen(0,"",llGetOwner(),"");
}

listen(integer channel, string name, key id, string message)
{
if(message == "f")
{
llOwnerSay("Flight Active");
state flight;
}
}
}
state flight
{
state_entry()
{
llListen(0,"",llGetOwner(),"");
}

listen(integer channel, string name, key id, string message)
{
if(message == "d")
{
llOwnerSay("Drive Active");
state drive;
}
}
}

Hang in there, it only gets easier :)
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-25-2007 16:25
ok i uploaded it in a txt format you can copy/paste to what you use, that is the script i was working on it is about 530-540 lines
Daten Thielt
Registered User
Join date: 1 Dec 2006
Posts: 104
11-25-2007 17:25
listen(integer channel, string name, key id, string message)
{
if(message = "f";);
{
llOwnerSay("Flight Active";);
state flight;
}
}

Never put ; after an if statement unless ur putting data between ) and ;

listen(integer channel, string name, key id, string message)
{
if(message = "f";)
{
llOwnerSay("Flight Active";);
state flight;
}
}
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-25-2007 17:28
Doing like I said works and gives you the attached. Just not for sure on the if's down in the timer.

Trying an experiment, everyone let me know if they can't open the doc or what they think. It is formatted and color coded. Comments?
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-25-2007 17:52
i can open/ copy paste it in sl so that works :P
with the semicolons i tryed it all with them and without then dosent do anything

EDITED:

script works now, what did or didnt i have?
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-25-2007 18:03
I changed a lot of little things. The easiest way to learn from it would probably be to print both versions out and compare side by side.

But no matter what, your little trick of uploading the txt file was awesome. No matter how many times I had looked at the manage uploads choices, I never thought of the possibility of pasting into txt or doc. Definitely helps in cases of large scripts like this.

Pat yourself on the back!
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-25-2007 18:33
HEHE :) im so smart and stupid at once i always have a ton of little tiny errors floating around my scripts
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
11-25-2007 23:33
One thing I recommend to avoid assigning values to variables in if checks is to do them in reverse.

if (variable = "value";) // typical error when ifs refuse to work

The above line will compile fine but will not exactly do the right thing. It assigns the value to the variable and then executes the if
part. Which will evaluate to TRUE.

if ("value" = variable)

Now this line instead will give you an error as you cannot assign a variable to a value. So you need to correct it to...

if ("value" == variable)

in order to get it to work. And work it will. properly.