Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("button")
- term.clear()
- local s_mode -- 0 = solo; 1 = do
- local s_auto -- 0 = nonlethal; 1 = slaughter; 2 = crusher
- function loadData()
- local file = io.open("savedata","r")
- local info = file:read()
- s_mode = tonumber(info:sub(1,1))
- s_auto = tonumber(info:sub(2,2))
- file:close()
- end
- function saveData()
- local file = io.open("savedata","w")
- file:write(s_mode..s_auto)
- file:close()
- end
- function fillTable()
- button.setTable("Toggle Mode", mode, 12,24,11,13)
- button.setTable("Switch Auto", auto, 27,41,11,13)
- button.screen()
- end
- function getClick()
- event,side,x,y = os.pullEvent("mouse_click")
- button.checkxy(x,y)
- end
- function update()
- term.setCursorPos(16,4)
- if s_mode == 0 then --solo mode
- term.write("Solo")
- else
- term.write("Duo ")
- end
- term.setCursorPos(22,6)
- if s_auto == 0 then -- nonlethal
- term.setTextColor(colors.red)
- term.write("Disabled ")
- elseif s_auto == 1 then
- term.setTextColor(colors.green)
- term.write("Slaughterer (Meat)")
- elseif s_auto == 2 then
- term.setTextColor(colors.green)
- term.write("Crusher (XP) ")
- end
- term.setTextColor(colors.white)
- end
- function pulse(strength)
- redstone.setAnalogOutput("bottom",strength)
- os.sleep(0.2)
- redstone.setAnalogOutput("bottom",0)
- end
- function mode()
- button.flash("Toggle Mode")
- pulse(5)
- if s_mode == 1 then s_mode = 0 else s_mode = 1 end
- saveData()
- update()
- end
- function auto()
- button.flash("Switch Auto")
- if s_auto == 0 then --if disabled
- s_auto = 1
- pulse(6) --turn on slaughterer
- elseif s_auto == 1 then --if slaughtere
- s_auto = 2
- pulse(6) -- turn off slaughterer
- os.sleep(0.3)
- pulse(7) -- turn on crusher
- elseif s_auto == 2 then --if crusher
- s_auto = 0
- pulse(7) --turn off crusher
- end
- saveData()
- update()
- end
- loadData()
- fillTable()
- update()
- button.heading("Mob Grinder Controller")
- term.setCursorPos(10,4)
- term.write("Mode:")
- term.setCursorPos(10,6)
- term.write("Autokiller:")
- while true do
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement