Jump to content

Recommended Posts

Posted (edited)

Hello! I want to create a hoverboard (YEAH!) using a Ferd Frederix's open source script. I guess will have a lot of questions about this later. here is the first one.

In addition to the main script, there is such a short script, which seems to be placed in child prim. What is it for and why does it not do anything for me?

integer stuck = 0;

default {

timer() {
if (!llGetStatus(STATUS_PHYSICS)) {
if (stuck < 1) {
llSetStatus(STATUS_PHYSICS, TRUE);
stuck++;
}
else {
llSetPos(llGetPos() + <0.0, 0.0, 0.5>);
llSetStatus(STATUS_PHYSICS, TRUE);
}
}
else {
stuck = 0;
}
}

link_message(integer sender, integer num, string str, key id) {
if (str == "idle") {
llResetScript();
}
else if (str == "get_on") {
llSetTimerEvent(1.0);
}
}
}

Actually it does something. It makes hoverboard physical, when i rez it, but what is the purpose of this? and perhaps it does something else?

Edited by Sunbleached

Share this post


Link to post
Share on other sites
Posted (edited)

There isn't very much to this script to begin with... It only contains two short events: a timer and a link_message event. That right away indicates this is a helper script that won't work on its own - it needs to work in conjunction with the main hoverboard script. Looking through that, you can see there is only one occurrence of the keywords "idle" and "get_on" that are spoken via llMessageLinked. These occur when the user sits on or stands up from the hoverboard. So this stuff is part of the vehicle's startup and shutdown procedures.

All the link_message event does is start a timer when it hears "get_on". When it hears "idle", it resets the helper script, thereby killing the timer.

The timer event has two nested IF-Else clauses. The first one checks whether the vehicle's physics is enabled or not. If physics is NOT enabled, it drops down into the inner IF-ELSE test. But if physics IS enabled, it just sets the value of the "stuck" integer variable to 0. The inner IF-ELSE test looks at the value of the stuck variable. Again, we only get here if the previous test passed, meaning the vehicle's physics is currently disabled. If the stuck variable is less than 1 (note the script initializes it to 0 so it always will be less than 1 at the start), then make the vehicle physical and increment the stuck variable by 1. On the other hand, if the stuck variable is not less than 1 (in other words, greater than or equal to 1), the move the vehicle up along the z axis by half a meter and then make the vehicle physical. If it turns out the vehicle was physical already, then none of the above happens, instead it just sets the value of the stuck variable to 0.

As far as I can tell, I think the point of this helper script is to bump the vehicle upwards a little before enabling its physics. But the way this is all written is (in my opinion) very poor. I think this whole script is completely unnecessary. It's wasteful, because that timer will continue to run as long as the vehicle is in use and only stops when you get off. But after the initial bump and/or setting the physics, it does nothing of consequence.

I really think you could just remove this helper script altogether.

Edited by Fenix Eldritch
  • Thanks 1

Share this post


Link to post
Share on other sites

@Fenix Eldritch

Wow! Thanks for such a comprehensive answer! Yes, I will most likely do it, the more so that the script and without it works perfectly and does what I need.


Until the next question has arisen why the main script does not have an idle running sound, with such a variety of other sounds like jumps, brake, land (6-7 sounds). but most likely i need to ask the author of the script.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...