Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------
- -- 1ng0 © --
- --------------
- mon = peripheral.wrap("top")
- rednet.open("bottom")
- turtleId = 61
- buttons = {}
- function greateButton(mon,text,mob)
- bxmin,bymin = mon.getCursorPos()
- bxmax = bxmin + #text
- bymax = bymin
- buttons[mob.slot] = {["mob"] = mob, ["text"] = text, ["slot"] = mob.slot, ["name"] = mob.name, ["xmin"] = bxmin, ["ymin"] = bymin, ["xmax"] = bxmax, ["ymax"] = bymax}
- mon.setBackgroundColor(colors.blue)
- println (mon, text)
- mon.setBackgroundColor(colors.black)
- end
- function command(cname,args)
- if (args) then
- cmd = {["cname"] = cname, ["args"] = args}
- else
- cmd = {["cname"] = cname}
- end
- rednet.send(turtleId, cmd)
- senderId, message, distance = rednet.receive(5)
- return message
- end
- function println(mon,text)
- cx,cy = mon.getCursorPos()
- mon.write(text)
- mon.setCursorPos(cx,cy+1)
- end
- function essenseStats()
- tankInfo = command("getTankInfo",nil)
- mon.setCursorPos(42,1)
- println(mon,"Stats")
- println(mon,"Essense:")
- if (tankInfo.amount) then
- am = tankInfo.amount
- else
- am = 0
- end
- println(mon,tostring(am))
- if (command("getSpawnExact",nil)) then
- div = 500
- else
- div = 150
- end
- println(mon,"~"..math.floor(am/div).." mobs")
- greateButton(mon,"Exact:",{slot = 100,command = "swapExact"})
- isExact = command("getSpawnExact",nil)
- println(mon,tostring(isExact))
- end
- function init(mon,mobs,currentMob)
- mon.clear()
- mon.setCursorPos(1,1)
- sx,sy = mon.getSize()
- println(mon,"All Available Mobs:")
- numnom = 1
- for i,mob in pairs(mobs) do
- if (i ~= 0) then
- if (numnom == 8) then
- mon.setCursorPos(21,2)
- end
- greateButton(mon,i..": "..mob.name, mob)
- numnom = numnom + 1
- end
- end
- mon.setCursorPos(1,9)
- greateButton(mon,"EMPTY",mobs[0])
- mon.setCursorPos(1,10)
- println(mon,"Currently selected mob:")
- println(mon,currentMob.slot..": "..currentMob.name)
- mon.setBackgroundColor(colors.blue)
- println(mon, "REFRESH")
- mon.setBackgroundColor(colors.black)
- essenseStats()
- end
- function checkButtons(x,y)
- for i,button in pairs(buttons) do
- if (x>=button.xmin and x<=button.xmax and y>=button.ymin and y<=button.ymax) then
- return button.mob
- end
- end
- return false
- end
- while true do
- mobs = command("getAllMobs",nil)
- currentMob = command("getCurrentMob",nil)
- init(mon,mobs,currentMob)
- event,side,posX,posY = os.pullEvent("monitor_touch")
- selectedMob = checkButtons(posX,posY)
- if (selectedMob ~= false) then
- --println(mon,"You clicked on "..selectedMob.name)
- if (selectedMob.command) then
- if (selectedMob.command == "swapExact") then
- currentExact = command("getSpawnExact",nil)
- command("setSpawnExact", {[1] = not(currentExact)})
- end
- else
- command("fromSpawnerToChest",nil)
- command("fromChestToSpawner",{[1] = selectedMob})
- end
- else
- -- println(mon,"You clicked on non button area ("..posX..","..posY..")")
- end
- -- sleep(2.5)
- end
- --print(command("selectMob", {[1] = mob}))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement