Jump to content

Syntax Error - I have no idea why it is happening - driving me insane


Tremayne Barbosa
 Share

You are about to reply to a thread that has been inactive for 571 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi,

 

I am a complete noob when it comes to scripting.  I have been reading up and trying to make a script that animates my avatar while holding an orb.  I have the animations in the root prim of the object (glittery orb) that I want to play through the animations, which includes throwing the ball between my hands etc.

 

It seems to be on the line I highlighted in red (row 11, column 13).  I am drawing a complete blank on it.  any help would be greatly appreciated.

 

integer animNum = 0;
integer numAnims = 0;
integer animPriority = 6;
list anims;

default
{
    state_entry()
    {
        // Get the number of animations in the object and store their names in a list
        numAnims = llGetInventoryNumber(INVENTORY_ANIMATION);
        for (integer i = 0; i < numAnims; i++)
        {
            string animName = llGetInventoryName(INVENTORY_ANIMATION, i);
            if (llGetAnimationLength(animName) > 0)
            {
                anims += animName;
            }
        }
 
        if (llGetListLength(anims) > 0)
        {
            // Start playing the first animation on priority 6
            string animName = llList2String(anims, animNum);
            llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
            llStartAnimation(animName);
        }
    }
 
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            // Handle the animation permissions
            llStopAnimation("");
            llSetAnimationOverride("", anims, animPriority);
        }
    }
 
    changed(integer change)
    {
        if (change & CHANGED_ANIMATION)
        {
            // Handle the end of an animation and start playing the next one
            string animName = llList2String(anims, animNum);
            llStopAnimation(animName);
            animNum = (animNum + 1) % llGetListLength(anims);
            animName = llList2String(anims, animNum);
            llStartAnimation(animName);
        }
    }

Edited by Tremayne Barbosa
Link to comment
Share on other sites

25 minutes ago, Tremayne Barbosa said:

for (integer i = 0; i < numAnims; i++)

You can't define a variable inside the for-loop's parameters like that. Try defining it just before the loop.

Also... you have a number of incorrect statements peppered throughout the script.

  • line 15: llGetAnimationLength() is not a valid function.
  • line 36: llSetAnimationOverride() only takes two input parameters, not three.
  • line 42: CHANGED_ANIMATION is not a thing.

I only gave this a surface level glance, just poking it till it compiled. Haven't looked into the actual logic, but I would highly recommend consulting the LSL wiki for documentation on how to script. Including going through some of the beginner tutorials.

Edited by Fenix Eldritch
  • Like 1
Link to comment
Share on other sites

I used ChatGPT yes, after many attempts at trying to write it myself and getting nowwhere.

I will go back to the drawing board i think with this.  I dont know enough on scripting to work this out i dont think.

Thank you for your help though :) I need a bit more time practicing before trying to actually do a complicated script

  • Like 1
Link to comment
Share on other sites

ChatGPT doesn't seem to have the ability to express uncertainty in what it generates, and from what I can see will confidently make up stuff that is demonstrably wrong. This is bad for many reasons, but especially when being used as a reference tool by someone who doesn't know how to code in the first place and therefore cannot spot the flaws.

I'm of the opinion that ChatGPT is a poor substitute for actually leaning how to code. If you want to script things for Second Life, I think your time would be better spent learning how to do it yourself* rather than wrangling the AI and trusting it to not BS you.

*And of course, we here on the forums would be happy to answer questions you have along your journey.

Edited by Fenix Eldritch
typos
  • Like 3
Link to comment
Share on other sites

14 hours ago, Fenix Eldritch said:

Also... you have a number of incorrect statements peppered throughout the script.

  • line 15: llGetAnimationLength() is not a valid function.
  • line 36: llSetAnimationOverride() only takes two input parameters, not three.
  • line 42: CHANGED_ANIMATION is not a thing.

I think CHANGED_ANIMATION is an OpenSimulator extra.

  • Like 1
Link to comment
Share on other sites

Not to mention llSetAnimationOverride requires the PERMISSION_OVERRIDE_ANIMATION, not TRIGGER_ANIMATION.

ChatGPT's code really shouldn't be relied on for now, especially for a niche language like LSL. Either you'll end up asking real people to fix it for you, or have to learn it yourself in either case. Might as well cut the hallucinating AI middleman until it can actually not lie to you.

  • Like 1
Link to comment
Share on other sites

Just echoing what the other (much smarter) people above have said; 

ChatGPT is an amazing tool BUT when it comes to LSL code, it can’t be even remotely relied upon. It makes up functions that don’t exist in order to make the code make logical sense in its own understanding. It does not however, follow the rules of SL scripting most of the time and the output is more often than naught, complete gobblede*****. 

Just hire one of the many amazing scripters available here or in world to tutor you or walk you through things. I’ve said it before, but I have literally every book on second life scripting ever written in english (and one in Russian for some reason) - and even pouring over them for years, my dumb ass still hasn’t learned how to make a competent script. 

So unless you have a basic understanding of coding logic, linguistics or a beautiful mind - hire out :) lol 

Hopefully one day we will be able to rely on A.I. to help us write the code to make our ideas come to life! But that day isn’t here yet. 

 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 571 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...