Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Created by Pixelmnkey, modified by NessieHC
- --(possibly save in a local variable?)
- --load-from-file TEST
- --load-from-file ToggleTest
- local mon = peripheral.wrap("top")
- mon.setTextScale(1)
- mon.setTextColor(colors.white)
- local button={}
- mon.setBackgroundColor(colors.black)
- function setTable(name, func, xmin, xmax, ymin, ymax)
- button[name] = {}
- button[name]["func"] = func
- button[name]["active"] = false
- button[name]["xmin"] = xmin
- button[name]["ymin"] = ymin
- button[name]["xmax"] = xmax
- button[name]["ymax"] = ymax
- end
- --function test()
- -- print("test")
- -- if ToggleValueTEST == 0 do
- -- ToggleValueTEST = 1
- -- save-to-file TEST
- -- newValue (colourNumber) + ValueOfMob(colour)
- -- save-to-file ToggleTest
- -- else
- -- ToggleValueTEST = 0
- -- save-to-file TEST
- -- newValue (colournumber) - ValueOfMob(colour=
- -- save-to-file ToggleTest
- -- end
- function zombie()
- print("Zombie")
- redstone.setBundledOutput("bottom", colors.white)
- os.sleep(.1)
- redstone.setBundledOutput("bottom", 0)
- end
- function angryZombie()
- print("Angry Zombie")
- redstone.setBundledOutput("bottom", colors.orange)
- os.sleep(.1)
- redstone.setBundledOutput("bottom", 0)
- end
- function skeleton()
- print("Skeleton")
- redstone.setBundledOutput("bottom", colors.magenta)
- os.sleep(.1)
- redstone.setBundledOutput("bottom", 0)
- end
- function witherSkeleton()
- print("Wither Skeleton")
- redstone.setBundledOutput("bottom", colors.lightBlue)
- os.sleep(.1)
- redstone.setBundledOutput("bottom", 0)
- end
- function creeper()
- print("Creeper")
- redstone.setBundledOutput("bottom", colors.yellow)
- os.sleep(.1)
- redstone.setBundledOutput("bottom", 0)
- end
- function enderman()
- print("Enderman")
- redstone.setBundledOutput("bottom", colors.lime)
- os.sleep(.1)
- redstone.setBundledOutput("bottom", 0)
- end
- function slime()
- print("Slime")
- redstone.setBundledOutput("bottom", colors.pink)
- os.sleep(.1)
- redstone.setBundledOutput("bottom", 0)
- end
- function magmaCube()
- print("Magma Cube")
- redstone.setBundledOutput("bottom", colors.gray)
- os.sleep(.1)
- redstone.setBundledOutput("bottom", 0)
- end
- function zombiePigman()
- print("Zombie Pigman")
- redstone.setBundledOutput("bottom", colors.lightGray)
- os.sleep(.1)
- redstone.setBundledOutput("bottom", 0)
- end
- function witch()
- print("Witch")
- redstone.setBundledOutput("bottom", colors.cyan)
- os.sleep(.1)
- redstone.setBundledOutput("bottom", 0)
- end
- function fillTable()
- setTable("Zombie", zombie, 2, 17, 2, 2)
- setTable("Angry Zombie", angryZombie, 2, 17, 4, 4)
- setTable("Skeleton", skeleton, 2, 17, 6, 6)
- setTable("Wither Skeleton", witherSkeleton, 2, 17, 8, 8)
- setTable("Creeper", creeper, 2, 17, 10, 10)
- setTable("Enderman", enderman, 2, 17, 12, 12)
- setTable("Slime", slime, 2, 17, 14, 14)
- setTable("Magma Cube", magmaCube, 2, 17, 16, 16)
- setTable("Zombie Pigman", zombiePigman, 2, 17, 18, 18)
- setTable("Witch", witch, 2, 17, 20, 20)
- end
- function fill(text, color, bData)
- mon.setBackgroundColor(color)
- local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2)
- local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(text)) /2) +1
- for j = bData["ymin"], bData["ymax"] do
- mon.setCursorPos(bData["xmin"], j)
- if j == yspot then
- for k = 0, bData["xmax"] - bData["xmin"] - string.len(text) +1 do
- if k == xspot then
- mon.write(text)
- else
- mon.write(" ")
- end
- end
- else
- for i = bData["xmin"], bData["xmax"] do
- mon.write(" ")
- end
- end
- end
- mon.setBackgroundColor(colors.black)
- end
- function screen()
- local currColor
- for name,data in pairs(button) do
- local on = data["active"]
- if on == true then currColor = colors.lime else currColor = colors.red end
- fill(name, currColor, data)
- end
- end
- function checkxy(x, y)
- for name, data in pairs(button) do
- if y>=data["ymin"] and y <= data["ymax"] then
- if x>=data["xmin"] and x<= data["xmax"] then
- data["func"]()
- data["active"] = not data["active"]
- print(name)
- end
- end
- end
- end
- function heading(text)
- w, h = mon.getSize()
- mon.setCursorPos((w-string.len(text))/2+1, 1)
- mon.write(text)
- end
- fillTable()
- while true do
- mon.clear()
- heading("Mob Control")
- screen()
- local e,side,x,y = os.pullEvent("monitor_touch")
- print(x..":"..y)
- checkxy(x,y)
- sleep(.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment