Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- coords[n]={}
- coords[n][1]={}
- --button to choose player for coord
- function fillCoords()
- buttonAPI.clearTable()
- mon.setTextScale(1.5)
- players = length(list)
- local npp = 3 --names per page
- local currLength = 24
- pages = math.ceil(players/npp)
- local currName = 0
- for k in pairs(numbers) do
- currName = currName + 1
- if currName > npp*(page-1) and currName < npp*page+1 then
- buttonAPI.setTable(numbers[k], coordsOptions, numbers[k], currLength, currLength + string.len(numbers[k])+4 ,2 ,4)
- currLength = currLength + string.len(numbers[k])+8
- end
- end
- buttonAPI.setTable("Home", fillButton, "", 2, 7, 2, 4)
- buttonAPI.setTable("Next Page", nextPage, "", 10, 20, 1, 2)
- buttonAPI.setTable("Prev Page", prevPage, "", 10, 20, 4, 5)
- refresh()
- label(2,2,"Player:")
- label(25,2,"Coordinates")
- local y = 4
- for k in pairs(list) do
- mon.setCursorPos(3,y)
- mon.write(numbers[k])
- for i in pairs(coords) do
- mon.setCursorPos(26,y)
- mon.write(coords[k][i]["name"])
- mon.setCursoePos(32,y)
- mon.write(coords[k][i]["xCoord"])
- mon.write(coords[k][i]["yCoord"])
- mon.setCursoePos(38,y)
- mon.write(coords[k][i]["zCoord"])
- y=y+1
- end
- end
- buttonAPI.label(11,3, "Page: "..page.. "/"..pages)
- filled = "coords"
- end
- function goBack2()
- fillCoords()
- end
- function newCoords(player,name,x,y,z)
- local n = getNumber(player)
- local m = length(coords[n])+1
- chat.say("Please write 'NameofthePlace x-coords y-coords z-coords'")
- chat.say("For example 'Base 12 85 943")
- event, player, message = os.pullEvent("chat")
- local string = message
- local x = 0
- for word in string.gmatch(string, "%w+") do
- if x == 0 then
- name = word
- elseif x == 1 then
- xCoord = word
- elseif x == 2 then
- yCoord= word
- elseif x == 3 then
- zCoord = word
- end
- x=x+1
- end
- coords[n][m] = {}
- coords[n][m]["name"] = name
- coords[n][m]["xCoord"] = xCoord
- coords[n][m]["yCoord"] = yCoord
- coords[n][m]["zCoord"] = zCoord
- end
- function deleteCoords(player)
- chat.say("Please write the number of the place you want to delete.")
- event, player, message = os.pullEvent("chat")
- local n = getNumber(player)
- table.remove(coords[n], [tonumber(message)])
- end
- function coordsOptions(player)
- buttonAPI.clearTable()
- buttonAPI.setTable("Home", fillButton, player, 2, 7, 2, 4)
- buttonAPI.setTable("Back", goBack2, "", 9, 14, 2, 4)
- buttonAPI.setTable("New", newCoords,player,18,23,2,4)
- buttonAPI.setTable("Delete", deleteCoords,player,32,37,2,4)
- refresh()
- end
Advertisement
Add Comment
Please, Sign In to add comment