Commit 0fd03ceb authored by Kyrah Abattoir's avatar Kyrah Abattoir

Remove state-entry shaft sync because that's obnoxious when editing.

Fixes a timer bug in toggle shaft valves & toggle gearbox valves.
Adds one-time owner report on shaft position (for configuring/min maxes).
Ensure that gearboxes & shafts prims have been found before touching them.
parent 693cdf65
......@@ -161,7 +161,9 @@ default
if(step > 1.0) //Valve is opened completely.
{
step = 1.0;
llSetLinkPrimitiveParamsFast(gearbox_link,[PRIM_TEXTURE,GEARBOX_FACE,GEAR_TEXTURE,GEAR_REPEAT,<gear,0,0>,PI_BY_TWO]);
if(gearbox_link) llSetLinkPrimitiveParamsFast(gearbox_link,[PRIM_TEXTURE,GEARBOX_FACE,GEAR_TEXTURE,GEAR_REPEAT,<gear,0,0>,PI_BY_TWO]);
llTargetOmega(axis,0,0);
Report(TRUE);
return;
......@@ -169,14 +171,17 @@ default
else if(step < 0) //Valve is closed completely.
{
step = 0.0;
llSetLinkPrimitiveParamsFast(gearbox_link,[PRIM_TEXTURE,GEARBOX_FACE,GEAR_TEXTURE,GEAR_REPEAT,<gear,0,0>,PI_BY_TWO]);
if(gearbox_link) llSetLinkPrimitiveParamsFast(gearbox_link,[PRIM_TEXTURE,GEARBOX_FACE,GEAR_TEXTURE,GEAR_REPEAT,<gear,0,0>,PI_BY_TWO]);
llTargetOmega(axis,0,0);
Report(TRUE);
return;
}
//Update gearbox & wheel speed, report new position.
llSetLinkPrimitiveParamsFast(gearbox_link,[PRIM_TEXTURE,GEARBOX_FACE,GEAR_TEXTURE,GEAR_REPEAT,<gear,0,0>,PI_BY_TWO]);
if(gearbox_link) llSetLinkPrimitiveParamsFast(gearbox_link,[PRIM_TEXTURE,GEARBOX_FACE,GEAR_TEXTURE,GEAR_REPEAT,<gear,0,0>,PI_BY_TWO]);
llTargetOmega(axis,rot_rate,1.0);
Report(FALSE);
}
......
......@@ -90,8 +90,13 @@ default
ReportPosition();
update_links();
llSetLinkPrimitiveParamsFast(shaft_link,[PRIM_POS_LOCAL,CLOSED_POSITION]);
llTargetOmega(llRot2Up(llGetLocalRot()),0,0);
//This is to help configuration, it is only shown when the script boots.
if(shaft_link)
llOwnerSay("Shaft link '"+SHAFT_NAME+"' was found (pos: "+(string)llGetLinkPrimitiveParams(shaft_link,[PRIM_POS_LOCAL])+").");
else
llOwnerSay("No shaft link named: '"+SHAFT_NAME+"' was found.");
}
changed(integer change)
{
......@@ -157,7 +162,9 @@ default
if(step > 1.0) //Valve is opened completely.
{
step = 1.0;
llSetLinkPrimitiveParamsFast(shaft_link,[PRIM_POS_LOCAL,OPEN_POSITION]);
if(shaft_link) llSetLinkPrimitiveParamsFast(shaft_link,[PRIM_POS_LOCAL,OPEN_POSITION]);
llTargetOmega(axis,0,0);
Report(TRUE);
return;
......@@ -165,14 +172,17 @@ default
else if(step < 0) //Valve is closed completely.
{
step = 0.0;
llSetLinkPrimitiveParamsFast(shaft_link,[PRIM_POS_LOCAL,CLOSED_POSITION]);
if(shaft_link) llSetLinkPrimitiveParamsFast(shaft_link,[PRIM_POS_LOCAL,CLOSED_POSITION]);
llTargetOmega(axis,0,0);
Report(TRUE);
return;
}
//Update shaft & wheel speed, report new position.
llSetLinkPrimitiveParamsFast(shaft_link,[PRIM_POS_LOCAL,vLerp(CLOSED_POSITION,OPEN_POSITION, step)]);
if(shaft_link) llSetLinkPrimitiveParamsFast(shaft_link,[PRIM_POS_LOCAL,vLerp(CLOSED_POSITION,OPEN_POSITION, step)]);
llTargetOmega(axis,move*ROTATION_SPEED,1.0);
Report(FALSE);
}
......
......@@ -123,7 +123,10 @@ default
gear -= (integer)gear;
move = 0;
llTargetOmega(axis,0,0);
llSetLinkPrimitiveParamsFast(gearbox_link,[PRIM_TEXTURE,GEARBOX_FACE,GEAR_TEXTURE,GEAR_REPEAT,<gear,0,0>,PI_BY_TWO]);
if(gearbox_link) llSetLinkPrimitiveParamsFast(gearbox_link,[PRIM_TEXTURE,GEARBOX_FACE,GEAR_TEXTURE,GEAR_REPEAT,<gear,0,0>,PI_BY_TWO]);
llSetTimerEvent(0);
if(MESSAGE_ENABLED)
ReportPosition();
......@@ -138,7 +141,10 @@ default
gear -= (integer)gear;
move = 0;
llTargetOmega(axis,0,0);
llSetLinkPrimitiveParamsFast(gearbox_link,[PRIM_TEXTURE,GEARBOX_FACE,GEAR_TEXTURE,GEAR_REPEAT,<gear,0,0>,PI_BY_TWO]);
if(gearbox_link) llSetLinkPrimitiveParamsFast(gearbox_link,[PRIM_TEXTURE,GEARBOX_FACE,GEAR_TEXTURE,GEAR_REPEAT,<gear,0,0>,PI_BY_TWO]);
llSetTimerEvent(0);
if(MESSAGE_ENABLED)
ReportPosition();
......@@ -148,6 +154,7 @@ default
//Update gearbox.
gear = step * GEAR_TURN_RATE;
gear -= (integer)gear;
llSetLinkPrimitiveParamsFast(gearbox_link,[PRIM_TEXTURE,GEARBOX_FACE,GEAR_TEXTURE,GEAR_REPEAT,<gear,0,0>,PI_BY_TWO]);
if(gearbox_link) llSetLinkPrimitiveParamsFast(gearbox_link,[PRIM_TEXTURE,GEARBOX_FACE,GEAR_TEXTURE,GEAR_REPEAT,<gear,0,0>,PI_BY_TWO]);
}
}
......@@ -74,8 +74,13 @@ default
ReportPosition();
update_links();
llSetLinkPrimitiveParamsFast(shaft_link,[PRIM_POS_LOCAL,CLOSED_POSITION]);
llTargetOmega(llRot2Up(llGetLocalRot()),0,0);
//This is to help configuration, it is only shown when the script boots.
if(shaft_link)
llOwnerSay("Shaft link '"+SHAFT_NAME+"' was found (pos: "+(string)llGetLinkPrimitiveParams(shaft_link,[PRIM_POS_LOCAL])+").");
else
llOwnerSay("No shaft link named: '"+SHAFT_NAME+"' was found.");
}
changed(integer change)
{
......@@ -120,7 +125,10 @@ default
step = 1;
move = 0;
llTargetOmega(axis,0,0);
llSetLinkPrimitiveParamsFast(shaft_link,[PRIM_POS_LOCAL,OPEN_POSITION]);
if(shaft_link) llSetLinkPrimitiveParamsFast(shaft_link,[PRIM_POS_LOCAL,OPEN_POSITION]);
llSetTimerEvent(0);
if(MESSAGE_ENABLED)
ReportPosition();
......@@ -133,13 +141,17 @@ default
step = 0;
move = 0;
llTargetOmega(axis,0,0);
llSetLinkPrimitiveParamsFast(shaft_link,[PRIM_POS_LOCAL,CLOSED_POSITION]);
if(shaft_link) llSetLinkPrimitiveParamsFast(shaft_link,[PRIM_POS_LOCAL,CLOSED_POSITION]);
llSetTimerEvent(0);
if(MESSAGE_ENABLED)
ReportPosition();
return;
}
llSetLinkPrimitiveParamsFast(shaft_link,[PRIM_POS_LOCAL,vLerp(CLOSED_POSITION,OPEN_POSITION, step)]);
if(shaft_link) llSetLinkPrimitiveParamsFast(shaft_link,[PRIM_POS_LOCAL,vLerp(CLOSED_POSITION,OPEN_POSITION, step)]);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment