Posted 17 December 2015 - 12:09 PM
Hi guys, there might be a much easier way around this than I've thought of (and there probably is), but my friend wanted an alarm for his password protected door, so that if the door was broken rather than entered via the correct password, an alarm would go off. How it works is that the dropped item sensor finds the reinforced door on the ground, which in turn sets off the alarm.
It could be adapted so that a dispenser would fire/a tesla coil would activate under the door (?), essentially any trap comprised with redstone. I'm quite new to computercraft and lua in general, so any improvements/alternatives that could be made feel free to comment!
term.clear()
term.setCursorPos(1, 1)
– Replace "" wrap with sensor side from computer –
mySensor = sensor.wrap("")
local Itemlist = mySensor.getTargets()
– Replace "" ItemName with FULL (e.g. for reinforced door item.item.itemDoorAlloy) name –
local ItemName = ""
while true do
Itemlist = mySensor.getTargets()
for value in pairs(Itemlist) do
if ItemName == string.sub(value, 1, -7) then
print("Alert!")
redstone.setOutput("right", true)
sleep(2)
redstone.setOutput("right", false)
else
print(string.sub(value, 1, -7))
end
end
end
Just a small program, but if it was helpful for anyone please mention! I noticed a distinct lack of information about this sensor specifically online, as it doesn't have too many uses :)/>
It could be adapted so that a dispenser would fire/a tesla coil would activate under the door (?), essentially any trap comprised with redstone. I'm quite new to computercraft and lua in general, so any improvements/alternatives that could be made feel free to comment!
term.clear()
term.setCursorPos(1, 1)
– Replace "" wrap with sensor side from computer –
mySensor = sensor.wrap("")
local Itemlist = mySensor.getTargets()
– Replace "" ItemName with FULL (e.g. for reinforced door item.item.itemDoorAlloy) name –
local ItemName = ""
while true do
Itemlist = mySensor.getTargets()
for value in pairs(Itemlist) do
if ItemName == string.sub(value, 1, -7) then
print("Alert!")
redstone.setOutput("right", true)
sleep(2)
redstone.setOutput("right", false)
else
print(string.sub(value, 1, -7))
end
end
end
Just a small program, but if it was helpful for anyone please mention! I noticed a distinct lack of information about this sensor specifically online, as it doesn't have too many uses :)/>