Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local iniFile = "/.settings/ZombieLeader"
- local test = os.getComputerID() == 21
- local LightController = peripheral.wrap(test and "computer_12" or "computer_608")
- local DisplayMonitor = test and "monitor_7" or "monitor_206"
- if fs.exists(iniFile) then
- settings.load(iniFile)
- end
- local state = settings.get("ZombieLeader.state",true)
- local light = settings.get("ZombieLeader.light",false)
- settings.set("ZombieLeader.state",state)
- settings.set("ZombieLeader.light",light)
- settings.save(iniFile)
- local function setLight(b)
- if b then
- LightController.turnOn()
- else
- LightController.shutdown()
- end
- end
- rs.setOutput("top",state)
- setLight(light)
- local mon = peripheral.wrap(DisplayMonitor)
- mon.setTextScale(1)
- local w,h = mon.getSize()
- local tw,th = term.getSize()
- local function output(line,str)
- term.setCursorPos(1,line)
- term.clearLine()
- term.write(str)
- end
- local function strTime(sec)
- sec = sec or os.clock()
- local str,d,h,m,s=""
- d=math.floor(sec/86400)
- h=math.floor(sec/3600)%24
- m=math.floor(sec/60)%60
- s=math.floor(sec%60)
- if d>0 then str = d>1 and d.." days " or "1 day" end
- if h>0 then str = str..h.."h" end
- if m>0 then str = str..(m>9 and m or "0"..m) end
- if h==0 then str = m>0 and str..":"..(s>9 and s or "0"..s) or s.."s" end
- return str
- end
- local eacute = string.char(233)
- local function stats(_d,_g,_z,_v,_m)
- _d = _d or ""
- _g = _g or ""
- _z = _z or ""
- _v = _v or ""
- _m = _m or ""
- local txt = {
- "D"..eacute.."lai: ".._d,
- "G"..eacute.."n"..eacute.."ration: ".._g,
- "Zombie: ".._z,
- "Villageois: ".._v,
- "Mioche: ".._m,
- }
- local _y
- for _y=1,#txt do
- mon.setCursorPos(2,_y)
- mon.clearLine()
- mon.write(txt[_y])
- end
- end
- local function setC(fg,bg)
- mon.setTextColor(fg)
- mon.setBackgroundColor(bg)
- end
- local function box()
- mon.setCursorPos(2,6)
- mon.clearLine()
- setC(colors.black, colors.white)
- mon.write(string.char(159)..string.rep(string.char(143),6))
- setC(colors.white, colors.black)
- mon.write(string.char(144))
- local i
- for i=7,11 do
- mon.setCursorPos(2,i)
- mon.clearLine()
- if i%2==1 then
- setC(colors.black, colors.white)
- mon.write(string.char(149))
- setC(colors.white, colors.black)
- mon.write(string.rep(" ",6)..string.char(149))
- else
- setC(colors.black, colors.white)
- mon.write(string.char(157)..string.rep(string.char(140),6))
- setC(colors.white, colors.black)
- mon.write(string.char(145))
- end
- end
- mon.setCursorPos(2,12)
- mon.clearLine()
- mon.write(string.char(130)..string.rep(string.char(131),6)..string.char(129))
- end
- --[[FT: 18x12
- 123456789012345678
- 1 > Délai: <
- 2 > Génération: <
- 3 > Zombie: <
- 4 > Villageois: <
- 5 > Mioche: <
- 6 > +------+ <
- 7 > | Mode |tueur <
- 8 > +------+ <
- 9 > |Turtle|attack <
- 10 > +------+ <
- 11 > |Lampes|on <
- 12 > +------+ <
- --]]
- local btn_txt = {
- [7]= " Mode ",
- [9]= "Turtle",
- [11]="Lampes",
- }
- local function btn(mouse_y)
- mouse_y = mouse_y or 0
- local ts=os.clock()
- mon.setCursorPos(3,7)
- setC(mouse_y==7 and colors.black or colors.gray, mouse_y==7 and colors.yellow or colors.lightGray)
- mon.write(btn_txt[7])
- mon.setCursorPos(3,9)
- setC(mouse_y==9 and colors.black or colors.gray, mouse_y==9 and colors.yellow or colors.lightGray)
- mon.write(btn_txt[9])
- mon.setCursorPos(3,11)
- setC(mouse_y==11 and colors.black or colors.gray, mouse_y==11 and colors.yellow or colors.lightGray)
- mon.write(btn_txt[11])
- --(Mode) Switch Direction
- if mouse_y==7 then
- state = not state
- rs.setOutput("top",state)
- settings.set("ZombieLeader.state",state)
- settings.save(iniFile)
- mon.setCursorPos(10,7)
- setC(colors.white,colors.black)
- mon.write(state and "Trieur" or "Tueur ")
- --(Turtle) Toggle On/Off Grinder
- elseif mouse_y==9 then
- --(Lampes) Toogle lights
- elseif mouse_y==11 then
- light = not light
- setLight(light)
- settings.set("ZombieLeader.light",light)
- settings.save(iniFile)
- mon.setCursorPos(10,11)
- setC(colors.white,colors.black)
- mon.write(light and "On " or "Off")
- else
- return
- end
- if os.clock()<ts+.1 then
- sleep(.1)
- end
- mon.setCursorPos(3,mouse_y)
- setC(colors.gray, colors.lightGray)
- mon.write(btn_txt[mouse_y])
- end
- local function header()
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- output(1,"#"..os.getComputerID().." - "..os.getComputerLabel())
- output(2,"Running: "..strTime())
- term.setBackgroundColor(colors.black)
- term.setTextColour(colors.gray)
- output(3,string.rep(string.char(131),tw))
- term.setTextColor(colors.white)
- end
- term.clear()
- header()
- setC(colors.white,colors.black)
- stats()
- box()
- local t = os.startTimer(1)
- while true do
- btn()
- mon.setCursorPos(10,7)
- setC(colors.white,colors.black)
- mon.write(state and "Trieur" or "Tueur " )
- mon.setCursorPos(10,11)
- mon.setTextColor(LightController.isOn() and colors.white or colors.gray)
- mon.write(LightController.isOn() and "On " or "Off")
- mon.setTextColor(colors.white)
- local e,p,x,y = os.pullEventRaw()
- if e=="terminate" then
- print("")
- print("/ZombieLeader - "..string.char(169).." SukaiPoppuGo")
- error("Terminated",0)
- return
- elseif e=="timer" then
- t = os.startTimer(1)
- header()
- --Toggle direction
- elseif e=="monitor_touch" then
- btn(y)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment