Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Local functions (only usable in the program itself not in the api)
- local object = {}
- object.__index = object
- --local scoreboard = commands.scoreboard
- local titleObj
- local orri
- local colorTable = {
- mcColor = {
- "black",
- "dark_blue",
- "dark_green",
- "dark_aqua",
- "dark_red",
- "dark_purple",
- "gold",
- "gray",
- "dark_gray",
- "blue",
- "green",
- "aqua",
- "red",
- "light_purple",
- "yellow",
- "white",
- },
- ccColor = {
- [colors.lightGray] = "gray",
- [colors.green] = "dark_green",
- [colors.lime] = "green",
- [colors.blue] = "blue",
- [colors.lightBlue] = "aqua",
- [colors.gray] = "dark_gray",
- [colors.pink] = "light_purple",
- [colors.black] = "black",
- [colors.purple] = "dark_purple",
- [colors.red] = "red",
- [colors.white] = "white",
- }
- }
- local match = false
- local function getTeam(team)
- ret = scoreboard("teams join "..team.." test")
- if ret then
- scoreboard("teams leave "..team.." test")
- end
- return ret
- end
- -- klaar soort van
- function new(type)
- if type == "line" then
- return function (text,value,color)
- local raw = {}
- setmetatable(raw,object)
- raw.text = text
- raw.value = value
- raw.color = color
- raw.type = "line"
- function raw:getValue()
- return self.value
- end
- function raw:getText()
- return self.text
- end
- function raw:getColor()
- return self.color
- end
- function raw:getType()
- return self.type
- end
- return raw
- end
- elseif type == "title" then
- return function (text)
- local raw = {}
- setmetatable(raw,object)
- raw.text = text
- raw.type = "title"
- function raw:getText()
- return self.text
- end
- function raw:getType()
- return self.type
- end
- return raw
- end
- elseif type == "board" then
- return function (obj)
- local raw = {}
- setmetatable(raw,object)
- raw.text = text
- raw.type = "board"
- raw.objects = obj
- raw.title = checkForTitle(obj):getText()
- function raw:generate()
- scoreboard("objectives add "..self.title.." dummy")
- for k,v in pairs(objects) do
- if v:getType() == "line" then
- scoreboard("players set "..v:getText().." "..self.title.." "..v:getValue())
- setColor(v)
- end
- end
- return true
- end
- function raw:delete()
- scoreboard("objectives remove "..self.title)
- return true
- end
- function raw:showTo(playerTable)
- playerTable = playerTable or {"@a"}
- for k,v in pairs(playerTable) do
- scoreboard("objectives setdisplay sidebar "..v)
- end
- return true
- end
- return raw
- end
- end
- end
- function checkForTitle(objects)
- for k,v in pairs(objects) do
- if objects[k]:getType() == "title" then
- return objects[k]
- end
- end
- return false
- end
- function setColor(obj)
- local name = obj:getText()
- local color = obj:getColor()
- for k,v in pairs(colorTable.mcColor) do
- if color == v then
- match = true
- else
- match = false
- end
- if match then break end
- end
- if not match then
- if colorTable.ccColor[color] then
- color = colorTable.ccColor[color]
- match = true
- end
- end
- if match then
- scoreboard("teams join "..color.." "..name)
- match = false
- else
- error("Color: "..color.." does not exist!",2)
- end
- end
- function init()
- for k,v in pairs(colorTable.mcColor) do
- if not getTeam(v) then
- scoreboard("teams add "..v)
- scoreboard("teams option "..v.." color "..v)
- end
- end
- end
- function removeTeams()
- for k,v in pairs(colorTable.mcColor) do
- scoreboard("teams remove "..v)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement