Posted 12 June 2014 - 07:20 AM
Just thought I'd drop a program I wrote for a turtle that when placed directly behind a dropper can be used as a keycard reader of sorts.
Now that I look at it, I think perhaps I should have used a variable at the top to make it easier to change which side is used for unlocking, but there you go, one of my first programs from scratch.
--[[Program name: Keycard Reader
-Programmer: Brach Speicher
-Minecraft: DoomRater
-Purpose: emulate CubeHamster's Keycard reader in a turtle
////////////////////////////]]--
function spitOut()
turtle.drop(1)
rs.setOutput("front",true)
sleep(.1)
rs.setOutput("front",false)
end
function unLock(side)
rs.setOutput(side,true)
sleep(.1)
rs.setOutput(side,false)
end
while true do
while turtle.suck() do
end
--test for item stacking in key slot
while turtle.getItemCount(10)>1 do
turtle.select(10)
unLock("top")
spitOut()
end
for t=1,9 do
turtle.select(t)
while turtle.getItemCount(t)>0 do
--test for non-stacking keys
if turtle.compareTo(10) then
unLock("top")
end
spitOut()
end
end
end
Now that I look at it, I think perhaps I should have used a variable at the top to make it easier to change which side is used for unlocking, but there you go, one of my first programs from scratch.