Converted to state-based approach, fixed all known bugs

This commit is contained in:
Eric Renfro 2020-10-01 13:14:09 -04:00
parent 3dac7b989a
commit 41b402a74e
Signed by: psi-jack
GPG key ID: 14977F3A50D9A5BF

View file

@ -150,7 +150,6 @@ default
// if (llDetectedType(0) & AGENT)
// if (!doorLock && doorClosed && configCollide) door();
//}
}
state loading
@ -266,7 +265,10 @@ state loading
} else {
if (settingsSection == 1) {
llSay(0, "Settings loaded.");
loadSettings(2);
if (!loadSettings(2)) {
if (doorClosed) state closed;
else state opened;
}
} else {
llSay(0, "Access List loaded. " + (string)llGetListLength(Keys) + " with access.");
if (doorClosed) state closed;
@ -281,6 +283,7 @@ state closed
{
state_entry()
{
llPassTouches(0);
doorClosed = TRUE;
}
@ -381,6 +384,7 @@ state opened
{
state_entry()
{
llPassTouches(0);
doorClosed = FALSE;
if (configSensor && doorActUID != NULL_KEY) {
if (configAxisCenter) llSensorRepeat("", doorActUID, AGENT, doorActDist + 1.5, TWO_PI, 1.0);
@ -399,10 +403,36 @@ state opened
}
}
touch_start(integer total_number)
{
if (configDistance > 0.0) {
if (llVecDist(llGetPos(), llDetectedPos(0)) <= configDistance) {
llResetTime();
if (touchDrag) touchDrag = FALSE;
}
}
}
touch(integer total_number)
{
if (configDistance > 0.0) {
if (llVecDist(llGetPos(), llDetectedPos(0)) <= configDistance) {
if (llGetTime() >= 0.25 && !touchDrag) {
touchDrag = TRUE;
}
}
}
}
touch_end(integer total_number)
{
if (configDistance > 0.0) {
if (llVecDist(llGetPos(), llDetectedPos(0)) <= configDistance) {
if (touchDrag) {
llSetTimerEvent(0.0);
llSensorRemove();
touchDrag = FALSE;
} else {
doorControl = TRUE;
state closing;
//if (doorClosed) door(llDetectedKey(0), llVecDist(llGetPos(), llDetectedPos(0)));
@ -410,6 +440,7 @@ state opened
}
}
}
}
link_message(integer sender, integer num, string name, key id)
{
@ -567,4 +598,3 @@ state opening
state opened;
}
}