I have this script that I wrote to control a piston door via redstone and on the other side of the door I have a motion sensor to open the piston door (toggle the redstone signal on). For some reason the motion sensor isn't doing anything, though. I know it's something I did, I'm new to LUA.
local component = require("component")
local sides = require("sides")
local event = require("event")
local gpu = component.gpu
local term = require("term")
local rs = component.redstone
-- Config
local delay = 5
while true do
-- GUI
term.clear()
gpu.setForeground(0x00FF00)
print("--------------------------- ToNELvision MICROSYTEMS ---------------------------\n")
gpu.setForeground(0xFFFFFF)
print("Welcome. Please enter one of the displayed commands. It may take a few seconds for the command to be interpreted.\n")
gpu.setForeground(0xE6AB38)
print("Open")
print("Close")
gpu.setForeground(0xFFFFFF)
term.setCursor(1,9)
local input=io.read()
if input == "Open" then
rs.setOutput(side.right, 15)
os.sleep(delay)
rs.setOutput(side.right, 0)
else
wrong = true
end
-- Motion Sensor
local id, _, x, y, entityName = event.pull("motion")
rs.setOutput(sides.right, 15)
os.sleep(delay)
rs.setOutput(sides.right, 0)
end