Converted to state-based approach, fixed all known bugs

master
Eric Renfro 2 years ago
parent 3dac7b989a
commit 41b402a74e
Signed by: psi-jack
GPG Key ID: 14977F3A50D9A5BF
  1. 46
      Simple Doors.lsl

@ -150,7 +150,6 @@ default
// if (llDetectedType(0) & AGENT)
// if (!doorLock && doorClosed && configCollide) door();
//}
}
state loading
@ -159,7 +158,7 @@ state loading
{
loadSettings();
}
dataserver(key qid, string data)
{
if (qid == settingsKey) {
@ -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,14 +403,41 @@ 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) {
doorControl = TRUE;
state closing;
//if (doorClosed) door(llDetectedKey(0), llVecDist(llGetPos(), llDetectedPos(0)));
//else door();
if (touchDrag) {
llSetTimerEvent(0.0);
llSensorRemove();
touchDrag = FALSE;
} else {
doorControl = TRUE;
state closing;
//if (doorClosed) door(llDetectedKey(0), llVecDist(llGetPos(), llDetectedPos(0)));
//else door();
}
}
}
}
@ -567,4 +598,3 @@ state opening
state opened;
}
}

Loading…
Cancel
Save