Miguelito Shilova Posted September 19, 2014 Share Posted September 19, 2014 Hi there. I'm working on a speedometer script and I need to convert the velocity vector to an integer. I'm thinking that I can use llGetVel for starters. SLWiki notes that to get the velocity relative the local frame (the direction the object is pointing), divide the output of this function by that of its rotation.," and provides the folloiwing to do that ...vector local_vel = llGetVel() / llGetRot();If I declare an integer 'number', how can I convert 'local_vel' to an integer that represents the speed in the forward/backward direction?-- Mig Link to comment Share on other sites More sharing options...
Rolig Loon Posted September 19, 2014 Share Posted September 19, 2014 Speed is a scalar quantity, not a vector, so all you need is llVecMag(local_vec), which will give you a float that you may then typecast to an integer as you wish. 2 Link to comment Share on other sites More sharing options...
Miguelito Shilova Posted September 19, 2014 Author Share Posted September 19, 2014 Thanks Rolig! Just now a question of syntax. So I would have to declare ... integer speed; float local_vec; and then in the function set it up like ... speed = llVecMag(local_vec); Is that correct? -- Mig Link to comment Share on other sites More sharing options...
Miguelito Shilova Posted September 19, 2014 Author Share Posted September 19, 2014 Or if I want to round out the speed integer, could I do this? speed = llRound(llVecMag(local_vec)); Link to comment Share on other sites More sharing options...
Rolig Loon Posted September 19, 2014 Share Posted September 19, 2014 No, you already have your local_vel, which is a vector. What you asked about is speed, which is the magnitude of a vector. And you wanted an integer version of that, so .... integer Speed = (integer)llVecMag(local_vel); EDIT: You type too fast. Yes, you could typecast with llRound or llFloor too. :smileywink: Link to comment Share on other sites More sharing options...
Miguelito Shilova Posted September 19, 2014 Author Share Posted September 19, 2014 Ah gotcha - and since this converts it to an integer I don't have to worry about rounding it. Cool! Thanks again! EDIT: haha - yep, I'm a fast typer (apparently not the only one ) I presume since it's typecast as an integer, I would not need to round the value, yes? -- Mig Link to comment Share on other sites More sharing options...
Recommended Posts
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