diff --git a/light-server.lua b/light-server.lua index c7826b4..1536a48 100644 --- a/light-server.lua +++ b/light-server.lua @@ -1,3 +1,5 @@ +local rs = require('libs/rs.lua') + local MAIN_DELAY_ON = 0.25 local MAIN_DELAY_OFF = 0 local SECONDARY_DELAY_ON = 0.75 @@ -9,6 +11,8 @@ local MAIN_OUTPUT_SIDE = 'left' local SECONDARY_INPUT_SIDE = 'back' local SECONDARY_OUTPUT_SIDE = 'front' +local VERSION = '1.0.0' + local function getMainColorsOrder() return { colors.white, @@ -70,7 +74,7 @@ local function mainLoop() local secondaryColorsOrder = getSecondaryColorsOrder() while true do - local _, lightIsOn, typeOfRoom = os.pullEvent('light_command') + local _, typeOfRoom, lightIsOn = os.pullEvent('light_command') if typeOfRoom == 'main' then if lightIsOn then @@ -100,16 +104,17 @@ local function redstoneLoop() if mainState ~= newMainState then mainState = newMainState - os.queueEvent('main', newMainState) + os.queueEvent('light_command', 'main', newMainState) end if secondaryState ~= newSecondaryState then secondaryState = newSecondaryState - os.queueEvent('secondary', newSecondaryState) + os.queueEvent('light_command', 'secondary', newSecondaryState) end os.pullEvent('redstone') end end +print('> Starting light server v' .. VERSION) parallel.waitForAny(mainLoop, redstoneLoop) \ No newline at end of file