v1.2.4
- Add setting to enable/disable exit delay countdown!
This commit is contained in:
parent
37e62c514a
commit
684767fe86
|
@ -30,6 +30,13 @@ local demoLoop = function()
|
||||||
repeat wait() until armState == 3
|
repeat wait() until armState == 3
|
||||||
wait(5)
|
wait(5)
|
||||||
disarm()
|
disarm()
|
||||||
|
wait(5)
|
||||||
|
script.Parent.Zones["2"].Sensors.Demo.Alarm.Value = true
|
||||||
|
wait(1)
|
||||||
|
script.Parent.Zones["2"].Sensors.Demo.Alarm.Value = false
|
||||||
|
repeat wait() until armState == 4
|
||||||
|
wait(5)
|
||||||
|
disarm()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
task.spawn(demoLoop)
|
task.spawn(demoLoop)
|
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,4 @@
|
||||||
local defaultCodes = {"1234"}
|
local defaultCodes = require(script.DefaultCodes)
|
||||||
|
|
||||||
local dataStore = nil
|
local dataStore = nil
|
||||||
local DataStoreService = game:GetService("DataStoreService")
|
local DataStoreService = game:GetService("DataStoreService")
|
||||||
|
@ -20,7 +20,7 @@ end
|
||||||
|
|
||||||
function setup(parentScript)
|
function setup(parentScript)
|
||||||
-- dont touch
|
-- dont touch
|
||||||
local version = "v1.2.2"
|
local version = "v1.2.4"
|
||||||
|
|
||||||
-- codes object, will be swapped for data store later
|
-- codes object, will be swapped for data store later
|
||||||
codes = dataStore:GetAsync("codes")
|
codes = dataStore:GetAsync("codes")
|
||||||
|
@ -46,6 +46,8 @@ function setup(parentScript)
|
||||||
fires = {}
|
fires = {}
|
||||||
zones = {}
|
zones = {}
|
||||||
keypads = {}
|
keypads = {}
|
||||||
|
countdown = nil
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
armState
|
armState
|
||||||
0 is disarmed
|
0 is disarmed
|
||||||
|
@ -135,71 +137,44 @@ delay
|
||||||
3 slow pulse (entry/exit delay main)
|
3 slow pulse (entry/exit delay main)
|
||||||
4 fast pulse (end of exit/entry delay and trouble)
|
4 fast pulse (end of exit/entry delay and trouble)
|
||||||
]]
|
]]
|
||||||
|
function switchKeypadAudio(enabled)
|
||||||
|
for i,e in ipairs(script.KeypadAudio:GetChildren()) do
|
||||||
|
if e.Name ~= enabled then
|
||||||
|
e.Disabled = true
|
||||||
|
else
|
||||||
|
e.Enabled = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
function audioLoop()
|
function audioLoop()
|
||||||
while true do
|
while true do
|
||||||
wait()
|
wait()
|
||||||
if not power then curTone = 0 end
|
if not power then curTone = 0 end
|
||||||
if curTone == 0 then -- Stop tone
|
if curTone == 0 then -- Stop tone
|
||||||
for i, keypad in ipairs(keypads) do
|
switchKeypadAudio("off")
|
||||||
stopAud(keypad.Display.hi)
|
|
||||||
stopAud(keypad.Display.lo)
|
|
||||||
end
|
|
||||||
elseif curTone == 1 then -- Constant tone
|
elseif curTone == 1 then -- Constant tone
|
||||||
for i, keypad in ipairs(keypads) do
|
switchKeypadAudio("constant")
|
||||||
playAud(keypad.Display.hi)
|
|
||||||
stopAud(keypad.Display.lo)
|
|
||||||
end
|
|
||||||
elseif curTone == 2 then -- Slow pulse tone
|
elseif curTone == 2 then -- Slow pulse tone
|
||||||
for i, keypad in ipairs(keypads) do
|
switchKeypadAudio("slowpulse")
|
||||||
stopAud(keypad.Display.hi)
|
|
||||||
stopAud(keypad.Display.lo)
|
|
||||||
end
|
|
||||||
wait(0.5)
|
|
||||||
for i, keypad in ipairs(keypads) do
|
|
||||||
playAud(keypad.Display.hi)
|
|
||||||
end
|
|
||||||
wait(0.5)
|
|
||||||
elseif curTone == 3 then -- Fast pulse tone
|
elseif curTone == 3 then -- Fast pulse tone
|
||||||
for i, keypad in ipairs(keypads) do
|
switchKeypadAudio("fastpulse")
|
||||||
stopAud(keypad.Display.hi)
|
|
||||||
stopAud(keypad.Display.lo)
|
|
||||||
end
|
|
||||||
wait(0.065)
|
|
||||||
for i, keypad in ipairs(keypads) do
|
|
||||||
playAud(keypad.Display.hi)
|
|
||||||
end
|
|
||||||
wait(0.065)
|
|
||||||
elseif curTone == 4 then -- HiLo tone alarm
|
elseif curTone == 4 then -- HiLo tone alarm
|
||||||
for i, keypad in ipairs(keypads) do
|
switchKeypadAudio("hilo")
|
||||||
playAud(keypad.Display.hi)
|
|
||||||
stopAud(keypad.Display.lo)
|
|
||||||
end
|
|
||||||
wait(0.5)
|
|
||||||
for i, keypad in ipairs(keypads) do
|
|
||||||
stopAud(keypad.Display.hi)
|
|
||||||
playAud(keypad.Display.lo)
|
|
||||||
end
|
|
||||||
wait(0.5)
|
|
||||||
elseif curTone == 5 then -- Fire alarm tone
|
elseif curTone == 5 then -- Fire alarm tone
|
||||||
-- Make this do temporal 3
|
switchKeypadAudio("fire")
|
||||||
for i = 1, 3 do
|
|
||||||
for i, keypad in ipairs(keypads) do
|
|
||||||
playAud(keypad.Display.hi)
|
|
||||||
stopAud(keypad.Display.lo)
|
|
||||||
end
|
|
||||||
wait(.5)
|
|
||||||
for i, keypad in ipairs(keypads) do
|
|
||||||
stopAud(keypad.Display.hi)
|
|
||||||
stopAud(keypad.Display.lo)
|
|
||||||
end
|
|
||||||
wait(.5)
|
|
||||||
end
|
|
||||||
wait(1)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function alignText(leftText, rightText, totalWidth)
|
||||||
|
local leftLength = #leftText
|
||||||
|
local rightLength = #rightText
|
||||||
|
local spaceBetween = totalWidth - (leftLength + rightLength)
|
||||||
|
|
||||||
|
-- If the total length of both texts exceeds the totalWidth, return concatenated textif spaceBetween < 0thenreturn leftText .. rightText
|
||||||
|
return leftText .. string.rep(" ", spaceBetween) .. rightText
|
||||||
|
end
|
||||||
|
|
||||||
function displayLoop()
|
function displayLoop()
|
||||||
while true do
|
while true do
|
||||||
wait()
|
wait()
|
||||||
|
@ -238,7 +213,12 @@ delay
|
||||||
ux.setLEDs(keypads, "armed", true)
|
ux.setLEDs(keypads, "armed", true)
|
||||||
ux.setLEDs(keypads, "ready", false)
|
ux.setLEDs(keypads, "ready", false)
|
||||||
if delay == 1 then
|
if delay == 1 then
|
||||||
ux.setDisplays(keypads, "ARMED ***AWAY***", "You may exit now")
|
if settings.showCountdown then
|
||||||
|
ln2 = alignText("May Exit Now", tostring(settings.exitDelay - countdown), 16)
|
||||||
|
else
|
||||||
|
ln2 = "You may exit now"
|
||||||
|
end
|
||||||
|
ux.setDisplays(keypads, "ARMED ***AWAY***", ln2)
|
||||||
elseif delay == 2 then
|
elseif delay == 2 then
|
||||||
ux.setDisplays(keypads, "DISARM SYSTEM", "Or alarm occurs.")
|
ux.setDisplays(keypads, "DISARM SYSTEM", "Or alarm occurs.")
|
||||||
else
|
else
|
||||||
|
@ -265,7 +245,12 @@ delay
|
||||||
ux.setLEDs(keypads, "armed", true)
|
ux.setLEDs(keypads, "armed", true)
|
||||||
ux.setLEDs(keypads, "ready", false)
|
ux.setLEDs(keypads, "ready", false)
|
||||||
if delay == 1 then
|
if delay == 1 then
|
||||||
ux.setDisplays(keypads, "ARMED *MAXIMUM*", "You may exit now")
|
if settings.showCountdown then
|
||||||
|
ln2 = alignText("May Exit Now", tostring(settings.exitDelay - countdown), 16)
|
||||||
|
else
|
||||||
|
ln2 = "You may exit now"
|
||||||
|
end
|
||||||
|
ux.setDisplays(keypads, "ARMED *MAXIMUM*", ln2)
|
||||||
else
|
else
|
||||||
ux.setDisplays(keypads, "ARMED *MAXIMUM*", "***ALL SECURE***")
|
ux.setDisplays(keypads, "ARMED *MAXIMUM*", "***ALL SECURE***")
|
||||||
end
|
end
|
||||||
|
@ -448,10 +433,12 @@ delay
|
||||||
for i = 1, settings.exitDelay do
|
for i = 1, settings.exitDelay do
|
||||||
if armState ~= 1 then
|
if armState ~= 1 then
|
||||||
delay = 0
|
delay = 0
|
||||||
|
countdown = 0
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
countdown = i
|
||||||
wait(1)
|
wait(1)
|
||||||
if i >= settings.exitDelay then delay = 0 end
|
if i >= settings.exitDelay then delay = 0 countdown = 0 end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -469,13 +456,16 @@ delay
|
||||||
if armState ~= 2 then
|
if armState ~= 2 then
|
||||||
changeTone(0)
|
changeTone(0)
|
||||||
delay = 0
|
delay = 0
|
||||||
|
countdown = 0
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
countdown = i
|
||||||
wait(1)
|
wait(1)
|
||||||
if i >= settings.exitDelay - 10 then changeTone(3) end
|
if i >= settings.exitDelay - 10 then changeTone(3) end
|
||||||
if i >= settings.exitDelay then
|
if i >= settings.exitDelay then
|
||||||
changeTone(0)
|
changeTone(0)
|
||||||
delay = 0
|
delay = 0
|
||||||
|
countdown = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -494,13 +484,16 @@ delay
|
||||||
if armState ~= 6 then
|
if armState ~= 6 then
|
||||||
changeTone(0)
|
changeTone(0)
|
||||||
delay = 0
|
delay = 0
|
||||||
|
countdown = 0
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
countdown = i
|
||||||
wait(1)
|
wait(1)
|
||||||
if i >= settings.exitDelay - 10 then changeTone(3) end
|
if i >= settings.exitDelay - 10 then changeTone(3) end
|
||||||
if i >= settings.exitDelay then
|
if i >= settings.exitDelay then
|
||||||
changeTone(0)
|
changeTone(0)
|
||||||
delay = 0
|
delay = 0
|
||||||
|
countdown = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -518,10 +511,12 @@ delay
|
||||||
for i = 1, settings.exitDelay do
|
for i = 1, settings.exitDelay do
|
||||||
if armState ~= 5 then
|
if armState ~= 5 then
|
||||||
delay = 0
|
delay = 0
|
||||||
|
countdown = 0
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
countdown = i
|
||||||
wait(1)
|
wait(1)
|
||||||
if i >= settings.exitDelay then delay = 0 end
|
if i >= settings.exitDelay then delay = 0 countdown = 0 end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue