Advertisement
ReBraLaCC

Scoreboard v0.3

Aug 12th, 2016
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.91 KB | None | 0 0
  1. -- COPYRIGHT REBRALA 12/8/2016!!! pls don't copy it around :)
  2.  
  3. O4C = {"black",
  4.        "dark_blue",
  5.        "dark_green",
  6.        "dark_aqua",
  7.        "dark_red",
  8.        "dark_purple",
  9.        "gold",
  10.        "gray",
  11.        "dark_gray",
  12.        "blue",
  13.        "green",
  14.        "aqua",
  15.        "red",
  16.        "light_purple",
  17.        "yellow",
  18.        "white"}
  19.  
  20. board = { -- An 'empty' scoreboard to start with
  21.     ["title"] = "Null",
  22.     ["lines"] = {
  23.         ["first"] = {
  24.             ["label"] = "Null",
  25.             ["value"] = 0,
  26.             ["color"] = "white",
  27.         },
  28.     }
  29. }
  30.  
  31.  
  32.  
  33. Args = {...}
  34.  
  35. if Args[1] == "init" then
  36.     commands.gamerule("commandBlockOutput false")
  37.     for k,v in pairs(O4C) do
  38.         commands.scoreboard("teams add "..v)
  39.         commands.scoreboard("teams option "..v.." color "..v)
  40.         print("Added "..v)
  41.     end
  42.     print("Init Complete! Run the program without any arguments to test")
  43.     return
  44. end
  45.  
  46. if Args[1] == "de-init" then
  47.     for k,v in pairs(O4C) do
  48.         commands.scoreboard("teams remove "..v)
  49.     end
  50.     print("Removed all colors")
  51.     return
  52. end
  53.  
  54. if Args[1] == "load" then
  55.     if Args[2] ~= nil and fs.exists(Args[2]) then
  56.         file = fs.open(Args[2],"r")
  57.         board = textutils.unserialise(file.readAll())
  58.     end
  59. end
  60.  
  61. --file = fs.open("","r")
  62. --board = textutils.unserialise(file.readAll())
  63.  
  64. function makeLine(name,label,value)
  65.     commands.scoreboard("players set "..label.." "..name.." "..value)
  66. end
  67.  
  68. function setColor(name,color)
  69.     commands.scoreboard("teams join "..color.." "..name)
  70.     print("Set "..name.."'s color to "..color)
  71. end
  72.  
  73. function removeBoard(name)
  74.     commands.scoreboard("objectives remove "..name)
  75. end
  76.  
  77. function makeBoard(name)
  78.     removeBoard(name)
  79.     commands.scoreboard("objectives add "..name.." dummy "..board.title)
  80.     for k,v in pairs(board.lines) do
  81.         makeLine(name,v.label,v.value)
  82.         setColor(v.label,v.color)
  83.     end
  84.     commands.scoreboard("objectives setdisplay sidebar "..name)
  85. end
  86.  
  87. print("made by ReBraLa")
  88. commands.gamerule("commandBlockOutput false")
  89. makeBoard("boardd")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement