forked from KCA/alarm-system
Update
# v1.2.2 - Add a way to disable datastore usage. Just set the dataStoreKey to nothing - Add "CHIME" text when chime enabled
This commit is contained in:
parent
4f5e6616de
commit
a1407a8e40
Binary file not shown.
|
@ -1,14 +1,31 @@
|
||||||
|
local defaultCodes = {"1234"}
|
||||||
|
|
||||||
|
local dataStore = nil
|
||||||
local DataStoreService = game:GetService("DataStoreService")
|
local DataStoreService = game:GetService("DataStoreService")
|
||||||
local dataStore = DataStoreService:GetDataStore('securityCodes-' .. script.Parent.dataStoreKey.Value or "XP-99")
|
dataStoreKey = script.Parent.dataStoreKey.Value
|
||||||
|
if dataStoreKey ~= "" then
|
||||||
|
dataStore = DataStoreService:GetDataStore('securityCodes-' .. script.Parent.dataStoreKey.Value or "XP-99")
|
||||||
|
else
|
||||||
|
-- Make virtual datastore for offline use
|
||||||
|
dataStore = {
|
||||||
|
_data = {},
|
||||||
|
GetAsync = function(self, key)
|
||||||
|
return self._data[key]
|
||||||
|
end,
|
||||||
|
SetAsync = function(self, key, value)
|
||||||
|
self._data[key] = value
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
function setup(parentScript)
|
function setup(parentScript)
|
||||||
-- dont touch
|
-- dont touch
|
||||||
version = "v1.2.1"
|
local version = "v1.2.2"
|
||||||
|
|
||||||
-- 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")
|
||||||
if not codes then
|
if not codes then
|
||||||
codes = {"1234"}
|
codes = defaultCodes
|
||||||
dataStore:SetAsync("codes", codes)
|
dataStore:SetAsync("codes", codes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -201,7 +218,11 @@ delay
|
||||||
else
|
else
|
||||||
ux.setLEDs(keypads, "ready", true)
|
ux.setLEDs(keypads, "ready", true)
|
||||||
ux.setLEDs(keypads, "armed", false)
|
ux.setLEDs(keypads, "armed", false)
|
||||||
ux.setDisplays(keypads, "****DISARMED****", " READY TO ARM ")
|
if not chime then
|
||||||
|
ux.setDisplays(keypads, "****DISARMED****", " READY TO ARM ")
|
||||||
|
else
|
||||||
|
ux.setDisplays(keypads, " DISARMED CHIME ", " READY TO ARM *")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif armState == 1 then -- We are armed stay
|
elseif armState == 1 then -- We are armed stay
|
||||||
ux.setLEDs(keypads, "armed", true)
|
ux.setLEDs(keypads, "armed", true)
|
||||||
|
@ -328,6 +349,7 @@ delay
|
||||||
elseif key == "8" then
|
elseif key == "8" then
|
||||||
-- If the code used was code 1, and the system is disarmed, Set inputMode to 2 (code change)
|
-- If the code used was code 1, and the system is disarmed, Set inputMode to 2 (code change)
|
||||||
-- See what index the code is at, if its index 1, its the right code, set mode to 2. do NOT hardcode the code here
|
-- See what index the code is at, if its index 1, its the right code, set mode to 2. do NOT hardcode the code here
|
||||||
|
print(codes[1] .. " : " .. authedUser)
|
||||||
if codes[1] == authedUser then
|
if codes[1] == authedUser then
|
||||||
inputMode = 2
|
inputMode = 2
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue