i was curious about different scripting methods (for aos and rideables and such) for testing avatar movement, speed, and suchlike. i've always suspected that using a timer was less laggy than using other events (like control. or like moving start; did you know, it fires off multiple times while you are walking). so, i devised a test.
(script posted below, unless it happens to contain secret code words that the fool board doesn't allow.)
CODE
//////////////////////////////
//-- Script Firing Test
//-- by bloodsong termagant
//////////////////////////////
//-- wear this, then perform one of the tests
//-- ie: click and hold: must DOUBLE CLICK and hold
//-- or press back to test controls
//-- or move forward to test moving
//-- for ten seconds (until it tells you the count)
//-- tip: hold fwd or back keys while resetting to capture test event promptly
//-- (move starts to fire on some random animations)
integer c = 0; //--the count of how many times the event fires in the ten second period
default
{
state_entry()
{
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
}
run_time_permissions(integer perm)
{
llTakeControls(CONTROL_BACK, TRUE, FALSE);
llOwnerSay("Back Key controlled and locked. Press Back to test control firing.");
}
touch_start(integer total_number)
{
llOwnerSay("Starting Touch Test. Hold for 10 seconds.");
state test_touch;
}
moving_start()
{
llOwnerSay("Starting Move Test. Hold for 10 seconds.");
state test_move;
}
control(key id, integer level, integer edge)
{
llOwnerSay("Starting Control Test. Hold for 10 seconds.");
state test_control;
}
}
state test_touch
{
state_entry()
{
llSetTimerEvent(10.0);
}
touch(integer tn)
{
c++;
}
timer()
{
state end_test;
}
}
state test_move
{
state_entry()
{
llSetTimerEvent(10.0);
}
moving_start()
{
c++;
}
timer()
{
state end_test;
}
}
state test_control
{
state_entry()
{
llSetTimerEvent(10.0);
}
control(key id, integer tn, integer cn)
{
c++;
}
timer()
{
state end_test;
}
}
state end_test
{
state_entry()
{
llSetTimerEvent(0.0);
llOwnerSay("Count Reached "+(string)c+" in 10 seconds.");
llSleep(10.0);
llOwnerSay("Resetting");
llResetScript();
}
}
RESULTS:
the results vary, obviously. and i didnt do any actual mathematical averaging. i just eyeballed it! numbers are number of times the event fired in 10 seconds.
also, the speed/lag of the sim the script is running in has a big impact on the numbers.
Beta Grid:----------------------------------------
control test: 570 564 569 569 (~ 57/sec)
touch test: 270 272 (~27/sec)
move test: 234 238 244 (~23/sec)
Main Grid
Island Sim (with a lotta chickens)-----------------
control test: 289 301 277 (~29/sec)
touch test: 94 90 84 83 (~8-9/sec)
move test: 30 23 75 79 71 (~3-7/sec)
Island Sim with Script Bug Lag----------------------
control test: 351 357 329 (~35/sec)
touch test: 120 114 124 (~12/sec)
move test: 20 54 21 54 (~2-5/sec)
Class 4 Island Sim:-----------------------------------
control test: 187 200 197 (~20/sec)
touch test: 129 128 128 (~13/sec)
move test: 0 2 3 (0-3/sec) ???!
at any rate, a timer of 0.2 fires off 5x per second. 0.25 is 4x. though technically, i should have made a timer test to see how often it fires off, but a timer to test the timer... is kinda iffy.