southpole

tempstuff

Dec 19th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.51 KB | None | 0 0
  1. coords[n]={}
  2. coords[n][1]={}
  3.  
  4.  
  5. --button to choose player for coord
  6. function fillCoords()
  7.   buttonAPI.clearTable()
  8.   mon.setTextScale(1.5)
  9.   players = length(list)
  10.   local npp = 3 --names per page
  11.   local currLength = 24
  12.   pages = math.ceil(players/npp)
  13.   local currName = 0
  14.   for k in pairs(numbers) do
  15.     currName = currName + 1
  16.     if currName > npp*(page-1) and currName < npp*page+1 then
  17.       buttonAPI.setTable(numbers[k], coordsOptions, numbers[k], currLength, currLength + string.len(numbers[k])+4 ,2 ,4)
  18.       currLength = currLength + string.len(numbers[k])+8
  19.     end
  20.   end
  21.   buttonAPI.setTable("Home", fillButton, "", 2, 7, 2, 4)
  22.   buttonAPI.setTable("Next Page", nextPage, "", 10, 20, 1, 2)
  23.   buttonAPI.setTable("Prev Page", prevPage, "", 10, 20, 4, 5)
  24.   refresh()
  25.   label(2,2,"Player:")
  26.   label(25,2,"Coordinates")
  27.   local y = 4
  28.   for k in pairs(list) do
  29.     mon.setCursorPos(3,y)
  30.     mon.write(numbers[k])
  31.     for i in pairs(coords) do
  32.       mon.setCursorPos(26,y)
  33.       mon.write(coords[k][i]["name"])
  34.       mon.setCursoePos(32,y)
  35.       mon.write(coords[k][i]["xCoord"])
  36.       mon.write(coords[k][i]["yCoord"])
  37.       mon.setCursoePos(38,y)
  38.       mon.write(coords[k][i]["zCoord"])
  39.       y=y+1
  40.     end
  41.   end
  42.   buttonAPI.label(11,3, "Page: "..page.. "/"..pages)
  43.   filled = "coords"
  44. end
  45.  
  46. function goBack2()
  47.   fillCoords()
  48. end
  49.  
  50. function newCoords(player,name,x,y,z)
  51.   local n = getNumber(player)
  52.   local m = length(coords[n])+1
  53.   chat.say("Please write 'NameofthePlace x-coords y-coords z-coords'")
  54.   chat.say("For example 'Base 12 85 943")
  55.   event, player, message =  os.pullEvent("chat")
  56.   local string = message
  57.   local x = 0
  58.   for word in string.gmatch(string, "%w+") do
  59.     if x == 0 then
  60.       name = word
  61.     elseif x == 1 then  
  62.       xCoord = word
  63.     elseif x == 2 then
  64.       yCoord= word
  65.     elseif x == 3 then
  66.       zCoord = word
  67.     end
  68.     x=x+1
  69.   end
  70.   coords[n][m] = {}
  71.   coords[n][m]["name"] = name
  72.   coords[n][m]["xCoord"] = xCoord
  73.   coords[n][m]["yCoord"] = yCoord
  74.   coords[n][m]["zCoord"] = zCoord
  75. end
  76.  
  77.  
  78. function deleteCoords(player)
  79.   chat.say("Please write the number of the place you want to delete.")
  80.   event, player, message =  os.pullEvent("chat")
  81.   local n = getNumber(player)
  82.   table.remove(coords[n], [tonumber(message)])
  83. end
  84.  
  85. function coordsOptions(player)
  86.   buttonAPI.clearTable()
  87.   buttonAPI.setTable("Home", fillButton, player, 2, 7, 2, 4)
  88.   buttonAPI.setTable("Back", goBack2, "", 9, 14, 2, 4)
  89.   buttonAPI.setTable("New", newCoords,player,18,23,2,4)
  90.   buttonAPI.setTable("Delete", deleteCoords,player,32,37,2,4)
  91. refresh()
  92. end
Advertisement
Add Comment
Please, Sign In to add comment