Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

help with changing LSL syntax

Atom Burma
Registered User
Join date: 30 May 2006
Posts: 685
11-26-2008 04:24
I threw this up yesterday, here /54/33/294508/1.html for references sake. And honestly I am not versed in LSL at all, totally self taught, and this is a cut and paste of a few scripts, and something has gone a bit off, it won't recompile, it has an error. I was changing it from a touch activated, to sit activated and I can't quite get it to work. Any help would be amazing.


(I will mark the area in question)

(code)

list ANIMS = [];
list ANIMS2 = [];
key chave;
integer i;

default
{
state_entry()
{
llSitTarget(<-0.15,0,-0.38>, ZERO_ROTATION);
}
changed(integer change) {
if (change & CHANGED_LINK)
{
key av = llAvatarOnSitTarget();
if (av)
{
if (llGetInventoryNumber(INVENTORY_ANIMATION) <= 12)
{
for (i = 0; i < llGetInventoryNumber(INVENTORY_ANIMATION); i++)
ANIMS += [llGetInventoryName(INVENTORY_ANIMATION, i)];
}
else
{
for (i = 0; i < 11; i++)
ANIMS += [llGetInventoryName(INVENTORY_ANIMATION, i)];
for (i = 11; i < llGetInventoryNumber(INVENTORY_ANIMATION); i++)
ANIMS2 += [llGetInventoryName(INVENTORY_ANIMATION, i)];
ANIMS += "more...";
ANIMS2 += "...back";
}
}

//This area does not compile, and I know touch is not a 'changed' command. But I am not sure what it should be. I added the 'changed' command above.

touch_start(integer total_number)
{
chave = llDetectedKey(0);
if ((chave == llGetPermissionsKey())

&& (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION))
llDialog(chave, "Select the animation you want to play: ", ANIMS, 777);
else
llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
}

run_time_permissions(integer perm)
{
if ((chave == llGetPermissionsKey()) && (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION))
llDialog(chave, "Select the animation you want to play: ", ANIMS, 777);
}
listen(integer channel, string name, key id, string message)
{
if (channel == 777)
{
if (message == "more...";)
llDialog(chave, "Select the animation you want to play: ", ANIMS2, 777);
else if (message == "...back";)
llDialog(chave, "Select the animation you want to play: ", ANIMS, 777);
else
{
list anims = llGetAnimationList(llGetPermissionsKey());
integer len = llGetListLength(anims);
for (i = 0; i < len; ++i)
{
llStopAnimation(llList2Key(anims, i));
llSleep(0.2);
}
llStartAnimation("default_anim";);
}
}
}

}
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
11-26-2008 04:36
Brackets do not match.
i.e. "default {" has no counterpart.
_____________________
From Studio Dora
Atom Burma
Registered User
Join date: 30 May 2006
Posts: 685
11-26-2008 04:49
yeah, still unclear to what that means, I am referencing scripts to see how similar sit scripts take permissions, still clueless, but thanks
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
11-26-2008 07:50
Actually the problem lies at the end of your 'changed' event handler. Neither the outermost 'if' construct nor the event handler itself are closed. Two close curly braces (}) just before your comment should do the trick.

I suggest sticking to a consistent style for your indents and where you put your braces. It helps a lot. Also I suggest ALWAYS using braces on control statements like 'if', 'else if', 'while', 'for', etc., even when you have only a single statement in them so the braces technically aren't necessary. It just keeps things very clear and readable and helps prevent errors later when you insert or remove statements.
Wouter Hobble
Registered User
Join date: 25 Mar 2008
Posts: 21
11-26-2008 08:32
I suggest you use an offworld editor that helps reveal where your code issues are. I use Eclipse and wrote a short guide on how to get it running here:
http://hobblescripts.com/index.php?option=com_content&view=article&id=15:editing-offworld-eclipse-with-lsl-plus&catid=5:tutorial&Itemid=3
Ee Maculate
Owner of Fourmile Castle
Join date: 11 Jan 2007
Posts: 919
11-26-2008 09:13
Notepad++ (notepad-plus.sourceforge.net/) will check your brackets quite happily...
Ravanne Sullivan
Pole Dancer Extraordinair
Join date: 10 Dec 2005
Posts: 674
11-26-2008 09:20
your if(av) is a problem, av is a key and if I recall correctly from making a similar mistake will always evaluate as true.

You probably want something like

if (av != NULL_KEY)

Also
if ((chave == llGetPermissionsKey())
should be
if (chave == llGetPermissionsKey()) // one too many (
_____________________
Ravanne's Dance Poles and Animations

Available at my Superstore and Showroom on Insula de Somni
http://slurl.com/secondlife/Insula de Somni/94/194/27/
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
11-26-2008 10:24
From: Ravanne Sullivan
your if(av) is a problem, av is a key and if I recall correctly from making a similar mistake will always evaluate as true.

You probably want something like

if (av != NULL_KEY)

Also
if ((chave == llGetPermissionsKey())
should be
if (chave == llGetPermissionsKey()) // one too many (

I believe a NULL_KEY evaluates to false, though it is not the most intuitive and thus readable and maintainable expression to use. I believe the 'if' statement continues on the next non-empty line and DOES have the correct number of parentheses.