Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Compile error

Iron Winx
Registered User
Join date: 30 Jan 2007
Posts: 7
02-02-2007 15:05
I am working on a script, in which I call a function (state) that I wrote. However, the compiler always reports an error on the first character of that function. I suppose it is something stupid that I forgot to add, or added too much, but I can't seem to find it, and the compiler doesn't really give alot of details either.

CODE

touch_start(integer total_number) { state dirty; }

//Start the talking sequences
state dirty ()
{
while (1)
{
rnd = llCeil(llFrand(12));


The error I get says: (37, 4) : ERROR: Syntax error
where 37,4 is the first letter of the "state dirty()" line.
Is there anyone who can help me out here? And does anybody know of a way to get some more descriptive compiling errors?

Thanks!
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-02-2007 15:13
From: Iron Winx
I am working on a script, in which I call a function (state) that I wrote. However, the compiler always reports an error on the first character of that function. I suppose it is something stupid that I forgot to add, or added too much, but I can't seem to find it, and the compiler doesn't really give alot of details either.

CODE

touch_start(integer total_number) { state dirty; }

//Start the talking sequences
state dirty ()
{
while (1)
{
rnd = llCeil(llFrand(12));


The error I get says: (37, 4) : ERROR: Syntax error
where 37,4 is the first letter of the "state dirty()" line.
Is there anyone who can help me out here? And does anybody know of a way to get some more descriptive compiling errors?

Thanks!



two things
firstly the code sample you have posted would appear to imply that the state dirty is either inside another state or that you have a touch_start event handler not in any state.

States have to be self contained, i.e. they cannot be inside other states or overlap.

default
{
}

state dirty
{
}


not

default
{
state dirty
{
}
}


And secondly states are not declared with parameters or brackets!

As for better error messages use lslint
Iron Winx
Registered User
Join date: 30 Jan 2007
Posts: 7
02-02-2007 16:11
>> States have to be self contained, i.e. they cannot be inside other states or overlap.

That was the one! Thank you bigtime! Up to the next problem ;-)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-03-2007 00:15
I've jsut reread your post and I think I see a conceptual problem.
I fear you are misunderstanding the terms state, function and event_handler.

You declare your own functions before any state definitions.
states contain event handlers, they are predefined and reserved named functions.

CODE

// UserDefined function returning a vector
vector MyFunction()
{
// calling a LSL predefined function
vector pos = llGetPos();
return pos;
}

// Default state (every script must have one!)
default
{
// state_entry event handler - called when the script first enters this state
state_entry()
{
// Switch to user defined state Dirty
state Dirty;
}
}

state Dirty
{
// touch event handler
touch_start(integer total_number)
{
// Calling our own function
vector pos = MyFunction();
}
}
Iron Winx
Registered User
Join date: 30 Jan 2007
Posts: 7
02-03-2007 00:42
Thank you, indeed, I was mixing up "state" and function. Your explanation made it quite clear, thanks.