Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --globals
- local iniFile="/.settings/kill"
- --ini
- local align,mon,i=false
- for i=1,4 do
- print("align")
- mon = peripheral.wrap("back")
- if not mon then
- turtle.turnRight()
- else
- print("align confirm")
- align = true
- break
- end
- end
- if not align then
- error("La turtle est désorientée.",0)
- return
- end
- if fs.exists(iniFile) then
- settings.load(iniFile)
- end
- local state = settings.get("Kill.state",true)
- settings.set("Kill.state",state)
- settings.save(iniFile)
- --display
- mon.setTextScale(1)
- local _w,_h = term.getSize()
- local w,h = mon.getSize()
- local function output(line,str,m)
- m = m or term
- m.setCursorPos(1,line)
- m.clearLine()
- m.write(str)
- end
- local function dots(str,n)
- local c = math.floor(os.clock()*2)
- return string.rep(str,c%n+1)
- 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 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),_w))
- term.setTextColor(colors.white)
- end
- term.clear()
- header()
- --process
- local function kill()
- local continue = true
- while continue do
- local i,kick = 1,0
- for i=1,4 do
- output(4,"Attack"..dots("!",3))
- mon.setCursorPos(10,9)
- mon.setTextColor(colors.red)
- mon.setBackgroundColor(colors.black)
- mon.write("Attack"..dots("!",3).." ")
- mon.setTextColor(colors.white)
- if turtle.attack() then
- kick = kick+1
- end
- header()
- sleep(.5)
- end
- continue = kick>0
- end
- end
- while true do
- if state and turtle.attack() then
- kill()
- end
- header()
- output(4,state and "Waiting" or "Off")
- mon.setCursorPos(10,9)
- mon.setTextColor(state and colors.white or colors.gray)
- mon.setBackgroundColor(colors.black)
- mon.write(state and "Waiting " or "Off ")
- local t = os.startTimer(1)
- local e,p,x,y = os.pullEventRaw()
- if e=="terminate" then
- print("")
- print("/kill - "..string.char(169).." SukaiPoppuGo")
- error("Terminated",0)
- return
- elseif e=="timer" then
- header()
- elseif e=="monitor_touch"
- and p=="back"
- and y == 9 then
- state = not state
- settings.set("Kill.state",state)
- settings.save(iniFile)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment