Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Made by Rnen10
- -- If problems/questions feel free to contact me
- -- https://twitter.com/Rnen10
- -- rnen. (Evan#7181) on discord
- -- Iron golem murder counter program.
- -- Auto-Update program for this and display can be found at https://pastebin.com/WsVbRvmL (download as startup)
- -- WriteToMon "display" = https://pastebin.com/FxkS233S
- term.clear()
- term.setCursorPos(1,1)
- print("Started counting murder...")
- local count = 0
- local function WriteToMon(Int)
- if fs.exists("display") then
- shell.run("display "..Int)
- end
- end
- local function ReadFile()
- if fs.exists("countFile") then
- print("Existing count found! Resuming...")
- local file = fs.open("countFile","r")
- sleep(0.1)
- local data = file.readAll()
- sleep(0.1)
- file.close()
- sleep(0.1)
- count = textutils.unserialize(data)
- print("I've murdered "..count.." innocent golems")
- WriteToMon(count)
- else
- local file = fs.open("countFile","w")
- sleep(0.1)
- file.write(textutils.serialize(count))
- sleep(0.1)
- file.close()
- end
- end
- local function SaveFile()
- local file = fs.open("countFile","w")
- sleep(0.1)
- file.write(textutils.serialize(count))
- sleep(0.1)
- file.close()
- end
- --Main Loop
- ReadFile()
- while true do
- os.pullEvent("redstone")
- if redstone.getInput("right") then
- count = count + 1
- end
- SaveFile()
- print("I've murdered "..count.." innocent golems")
- WriteToMon(count)
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment