Jump to content

Bowling Pin Script; Syntax Error


Syle Devin
 Share

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

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

Recommended Posts

So my script below get's a syntax error at the first "{" before 

{
llOwnerSay("Pin has fallen");
}

I have no idea why. Maybe the script doesn't work but I haven't been able to save it to test. Can anyone shine some light on it for me? Thanks! :)

 

vector rot;
vector pos;
vector up;

default
    {
        state_entry()
            {       
            vector up = <0.0, 0.0, 2.0>; //defines world up
            rot = llRot2Euler( llGetLocalRot() ); //Gets starting rotation and converts to radians
            }
        collision_start(integer num)
            {    
                llOwnerSay("I've been hit");
                llOwnerSay("Rotation is " + (string)rot);
            }
        moving_end()
            {
                llOwnerSay("Frozen");
                if (llVecDist(up*llGetRot(), up) > (llVecDist(rot*llGetRot(), rot))  // decides if world rotation up is greater than the pins up.
                    {
                     llOwnerSay("Pin has fallen");
                    }
                else if (llVecDist(up*llGetRot(), up) < (llVecDist(rot*llGetRot(), rot))
                    {
                     llOwnerSay("Pin has not fallen");
                    }
            }
    }

 

 

Link to comment
Share on other sites

BTW, why not just write something simple like this?

default{    collision_start(integer num)    {            llOwnerSay("I've been hit");    }    moving_end()    {        rotation Rot = llGetRot();        if ((llFabs(Rot.x) >= 0.1) || (llFabs(Rot.y) >= 0.1))        {         llOwnerSay("Pin has fallen");        }        else         {         llOwnerSay("Pin has not fallen");        }    }}

 

 

Link to comment
Share on other sites

I didn't write something like that because it never crossed my mind, lol, as I've mentioned before I am new to scripting and so there area  few things you've used that I don't understand. Someone had given me the line I that I did use and I figured it would work so I was trying to use it. Can't say I fully understood it either.

vector UP = <0.0, 0.0, 1.0>;

if (llVecDist(UP*llGetRot(), UP) > 0.03)

 

What you have given me is a lot simpler but like I said there are a few things I don't understand. I've been trying to wrap my head around radians and how .1 is only a little less than 1.0 which is straight up. Mostly trying to figure out how radians relate to degrees. Or do I have that backwards and 0 is straight up? Also what is llFabs? I looked at the wiki, am I correct to assume it returns a absolute number for whatever value is in the parentheses?

But aside from what I don't understand thanks a lot for the help. I have an idea of how to get it to keep track of score now. I was just stuck on getting it to know when the pin had fallen.

Link to comment
Share on other sites

There's no magic to it.  When an object has its Z axis vertical, the X and Y components of its rotation are both zero.  So, if the pin has fallen over, one or both of them has to be non-zero.  I could just test for

if (Rot.x == 0.0 || Rot.y == 0.0)

but that would be too strict a test.  After all, if a pin is just leaning a little bit (as it would be if the floor wasn't exactly level, for example), then the test would fail.  So, instead, I said let's allow the pin the lean slightly before we say that it fell over.  The value of 0.1 is kind of arbitrary.  You could do somequick tests to decide what a better value might be.

llFabs just takes care of the possibility that the pin might be leaning left or right, so Rot.x or Rot.y might be either positive or negative.  I don't care which, so I just look at the absolute value.

Radians are the standard way to measure angles.  Remember your HS math?  If the radius of a circle sweeps out a full circle of arc, it has gone 2 * PI radians or 360 degrees.  No magic. 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3974 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...