Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local level = 0
- local direction = "up"
- local function writeLevel()
- h = fs.open("level", "w")
- h.writeLine(level)
- h.close()
- end
- local function readLevel()
- h = fs.open("level", "r")
- level = tostring(h.readLine())
- h.close()
- end
- local function up()
- redstone.setOutput("left", true)
- os.sleep(1/10)
- redstone.setOutput("left", false)
- level = level + 1
- writeLevel()
- os.sleep(1)
- end
- local function down()
- redstone.setOutput("right", true)
- os.sleep(1/10)
- redstone.setOutput("right", false)
- level = level - 1
- writeLevel()
- os.sleep(1)
- end
- readLevel()
- while true do
- if level == 180 then
- direction = "down"
- elseif level == 0 then
- direction = "up"
- end
- if direction == "up" then
- up()
- else
- down()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment