Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem = peripheral.wrap("left")
- mon = peripheral.wrap("top")
- mon.setBackgroundColor(colors.lightGray)
- mon.clear()
- mon.setTextScale(2)
- x,y = mon.getSize()
- spawners_on = {}
- --Fonctions
- function create_button(xmin, xmax, ymin, ymax, color, text, tcolor)
- local aire = 0
- local xtemp, ytemp = xmin, ymin
- while aire < (((xmax-xmin)+1)*((ymax-ymin)+1)) do
- mon.setBackgroundColor(color)
- mon.setCursorPos(xtemp,ytemp)
- mon.write(" ")
- if xtemp == xmax then
- xtemp = xmin
- ytemp = ytemp + 1
- else
- xtemp = xtemp + 1
- end
- aire = aire + 1
- end
- mon.setTextColor(tcolor)
- mon.setCursorPos((xmin+xmax)/2 - (string.len(text)/2) + 1, (ymax+ymin)/2)
- mon.write(text)
- mon.setBackgroundColor(colors.blue)
- end
- function setup()
- --boutons
- create_button(math.floor(0.08*x),math.floor(0.25*x),math.floor(0.2*y), math.floor(0.3*y), colors.gray, "Witch", colors.black)
- create_button(math.floor(0.32*x),math.floor(0.48*x),math.floor(0.2*y), math.floor(0.3*y), colors.gray, "Golem", colors.black)
- create_button(math.floor(0.55*x),math.floor(0.73*x),math.floor(0.2*y), math.floor(0.3*y), colors.gray, "Wither", colors.black)
- create_button(math.floor(0.8*x),math.floor(0.99*x),math.floor(0.2*y), math.floor(0.3*y), colors.gray, "Blaze", colors.black)
- create_button(math.floor(0.08*x),math.floor(0.25*x),math.floor(0.52*y), math.floor(0.6*y), colors.gray, "Squid", colors.black)
- create_button(math.floor(0.32*x),math.floor(0.48*x),math.floor(0.52*y), math.floor(0.6*y), colors.gray, "Pigman", colors.black)
- create_button(math.floor(0.55*x),math.floor(0.73*x),math.floor(0.52*y), math.floor(0.6*y), colors.gray, "Enderman", colors.black)
- create_button(math.floor(0.8*x),math.floor(0.99*x),math.floor(0.52*y), math.floor(0.6*y), colors.gray, "Spider", colors.black)
- create_button(math.floor(0.08*x),math.floor(0.25*x),math.floor(0.8*y), math.floor(0.9*y), colors.gray, "Sheep", colors.black)
- create_button(math.floor(0.32*x),math.floor(0.48*x),math.floor(0.8*y), math.floor(0.9*y), colors.gray, "Blizz", colors.black)
- create_button(math.floor(0.55*x),math.floor(0.73*x),math.floor(0.8*y), math.floor(0.9*y), colors.gray, "Creeper", colors.black)
- create_button(math.floor(0.8*x),math.floor(0.99*x),math.floor(0.8*y), math.floor(0.9*y), colors.gray, "Test", colors.black)
- end
- function check_tab(tab,color)
- if tab[1] ~= nil then
- for i,v in ipairs(tab) do
- if v == color then
- table.remove(tab,i)
- return true
- end
- end
- return false
- else
- return false
- end
- end
- function add_spawner(channelcolor)
- if table.getn(spawners_on) <3 then
- table.insert(spawners_on,1,channelcolor)
- else table.insert(spawners_on, 1,channelcolor)
- --check_tab(spawners_on,spawners_on[4])
- table.remove(spawners_on)
- end
- end
- function detection()
- local tevent, cote, xn, yn = os.pullEvent("monitor_touch")
- if yn >= math.floor(0.2*y) and yn<=math.floor(0.3*y) then
- if xn >= math.floor(0.08*x) and xn<= math.floor(0.25*x) then
- if check_tab(spawners_on,colors.orange) == false then
- add_spawner(colors.orange)
- create_button(math.floor(0.08*x),math.floor(0.25*x),math.floor(0.2*y), math.floor(0.3*y), colors.lime, "Witch", colors.black)
- else
- create_button(math.floor(0.08*x),math.floor(0.25*x),math.floor(0.2*y), math.floor(0.3*y), colors.gray, "Witch", colors.black)
- end
- elseif xn>= math.floor(0.32*x) and xn<= math.floor(0.48*x) then
- if check_tab(spawners_on,colors.yellow) == false then
- add_spawner(colors.yellow)
- create_button(math.floor(0.32*x),math.floor(0.48*x),math.floor(0.2*y), math.floor(0.3*y), colors.lime, "Golem", colors.black)
- else
- create_button(math.floor(0.32*x),math.floor(0.48*x),math.floor(0.2*y), math.floor(0.3*y), colors.gray, "Golem", colors.black)
- end
- elseif xn>= math.floor(0.55*x) and xn<= math.floor(0.73*x) then
- if check_tab(spawners_on,colors.red) == false then
- add_spawner(colors.red)
- create_button(math.floor(0.55*x),math.floor(0.73*x),math.floor(0.2*y), math.floor(0.3*y), colors.lime, "Wither", colors.black)
- else
- create_button(math.floor(0.55*x),math.floor(0.73*x),math.floor(0.2*y), math.floor(0.3*y), colors.gray, "Wither", colors.black)
- end
- elseif xn>= math.floor(0.8*x)and xn<= math.floor(0.99*x) then
- if check_tab(spawners_on,colors.magenta) == false then
- add_spawner(colors.magenta)
- create_button(math.floor(0.8*x),math.floor(0.99*x),math.floor(0.2*y), math.floor(0.3*y), colors.lime, "Blaze", colors.black)
- else
- create_button(math.floor(0.8*x),math.floor(0.99*x),math.floor(0.2*y), math.floor(0.3*y), colors.gray, "Blaze", colors.black)
- end
- end
- elseif yn>= math.floor(0.52*y) and yn<=math.floor(0.6*y) then
- if xn >= math.floor(0.08*x) and xn<= math.floor(0.25*x) then
- if check_tab(spawners_on,colors.purple) == false then
- add_spawner(colors.purple)
- create_button(math.floor(0.08*x),math.floor(0.25*x),math.floor(0.52*y), math.floor(0.6*y), colors.lime, "Squid", colors.black)
- else
- create_button(math.floor(0.08*x),math.floor(0.25*x),math.floor(0.52*y), math.floor(0.6*y), colors.gray, "Squid", colors.black)
- end
- elseif xn>= math.floor(0.32*x) and xn<= math.floor(0.48*x) then
- if check_tab(spawners_on,colors.pink) == false then
- add_spawner(colors.pink)
- create_button(math.floor(0.32*x),math.floor(0.48*x),math.floor(0.52*y), math.floor(0.6*y), colors.lime, "Pigman", colors.black)
- else
- create_button(math.floor(0.32*x),math.floor(0.48*x),math.floor(0.52*y), math.floor(0.6*y), colors.gray, "Pigman", colors.black)
- end
- elseif xn>= math.floor(0.55*x) and xn<= math.floor(0.73*x) then
- if check_tab(spawners_on,colors.gray) == false then
- add_spawner(colors.gray)
- create_button(math.floor(0.55*x),math.floor(0.73*x),math.floor(0.52*y), math.floor(0.6*y), colors.lime, "Enderman", colors.black)
- else
- create_button(math.floor(0.55*x),math.floor(0.73*x),math.floor(0.52*y), math.floor(0.6*y), colors.gray, "Enderman", colors.black)
- end
- elseif xn>= math.floor(0.8*x)and xn<= math.floor(0.99*x) then
- if check_tab(spawners_on,colors.lightGray) == false then
- add_spawner(colors.lightGray)
- create_button(math.floor(0.8*x),math.floor(0.99*x),math.floor(0.52*y), math.floor(0.6*y), colors.lime, "Spider", colors.black)
- else
- create_button(math.floor(0.8*x),math.floor(0.99*x),math.floor(0.52*y), math.floor(0.6*y), colors.gray, "Spider", colors.black)
- end
- end
- elseif yn>= math.floor(0.8*y) and yn<= math.floor(0.9*y) then
- if xn >= math.floor(0.08*x) and xn<= math.floor(0.25*x) then
- if check_tab(spawners_on,colors.black) == false then
- create_button(math.floor(0.08*x),math.floor(0.25*x),math.floor(0.8*y), math.floor(0.9*y), colors.lime, "Sheep", colors.black)
- add_spawner(colors.black)
- else
- create_button(math.floor(0.08*x),math.floor(0.25*x),math.floor(0.8*y), math.floor(0.9*y), colors.gray, "Sheep", colors.black)
- end
- elseif xn>= math.floor(0.32*x) and xn<= math.floor(0.48*x) then
- if check_tab(spawners_on,colors.green) == false then
- create_button(math.floor(0.32*x),math.floor(0.48*x),math.floor(0.8*y), math.floor(0.9*y), colors.lime, "Blizz", colors.black)
- add_spawner(colors.green)
- else
- create_button(math.floor(0.32*x),math.floor(0.48*x),math.floor(0.8*y), math.floor(0.9*y), colors.gray, "Blizz", colors.black)
- end
- elseif xn>= math.floor(0.55*x) and xn<= math.floor(0.73*x) then
- if check_tab(spawners_on,colors.lime) == false then
- create_button(math.floor(0.55*x),math.floor(0.73*x),math.floor(0.8*y), math.floor(0.9*y), colors.lime, "Creeper", colors.black)
- add_spawner(colors.lime)
- else
- create_button(math.floor(0.55*x),math.floor(0.73*x),math.floor(0.8*y), math.floor(0.9*y), colors.gray, "Creeper", colors.black)
- end
- elseif xn>= math.floor(0.8*x)and xn<= math.floor(0.99*x) then
- if check_tab(spawners_on,colors.cyan) == false then
- create_button(math.floor(0.8*x),math.floor(0.99*x),math.floor(0.8*y), math.floor(0.9*y), colors.lime, "Test", colors.black)
- add_spawner(colors.cyan)
- else
- create_button(math.floor(0.8*x),math.floor(0.99*x),math.floor(0.8*y), math.floor(0.9*y), colors.gray, "Test", colors.black)
- end
- end
- else
- return false
- end
- end
- function update(tab)
- tampon = 0
- if tab.getn ~= 0 then
- for i,v in ipairs(tab) do
- tampon = tampon + v
- end
- rs.setBundledOutput("bottom", tampon)
- end
- end
- --Main
- setup()
- while true do
- if rs.getAnalogInput("right") == 15 then
- detection()
- update(spawners_on)
- os.sleep(0.1)
- else
- term.setCursorPos(1,1)
- print("Joueur absent, spawners eteints.")
- rs.setBundledOutput("bottom",0)
- os.sleep(60)
- term.setCursorPos(1,1)
- term.clear()
- end
- os.sleep(1)
- end
- --OpenSource, utilisez le comme vous le voulez chez vous.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement