Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creator: Bolodefchoco
- --Made in: 06/02/2017
- --Last update: 06/08/2017
- --[[ Module ]]--
- local module = {
- _VERSION = "3.8",
- _NAME = "universe",
- _STATUS = "semi-official",
- _AUTHOR = "Bolodefchoco",
- _LICENSE = [[
- MIT LICENSE
- Copyright (c) 2017 @Transformice + @Bolodefchoco
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR
- A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- ]],
- _FREEACCESS = { -- Verified players
- -- 3 : Commands + Room admin + Debug
- Bolodefchoco = 3,
- -- 2 : Commands
- Bodykudo = 2,
- Error_404 = 2,
- Jordynl = 2,
- Laagaadoo = 2,
- Sebafrancuz = 2,
- Tocutoeltuco = 2,
- -- 1 : Some commands
- Artinoe = 1,
- Bapereira = 1,
- Barberserk = 1,
- Byontr = 1,
- Claumiau = 1,
- Drescen = 1,
- Ekull = 1,
- Elvismouse = 1,
- Grastfetry = 1,
- Kimsterjay = 1,
- Mcqv = 1,
- Mescouleur = 1,
- Mquk = 1,
- Reshman = 1,
- Rikkeshang = 1,
- Ruamorangos = 1,
- Sammynya = 1,
- },
- }
- --[[ Optimization ]]--
- --[[ String ]]--
- local stringlen,stringfind,stringgmatch,stringbyte,stringdump,stringreverse,stringupper,stringformat,stringrep,stringlower,stringsub,stringgsub,stringmatch,stringchar = string.len,string.find,string.gmatch,string.byte,string.dump,string.reverse,string.upper,string.format,string.rep,string.lower,string.sub,string.gsub,string.match,string.char
- --[[ Math ]]--
- local mathdeg,mathfmod,mathrandom,mathasin,mathmax,mathmodf,mathfloor,mathcosh,mathldexp,mathatan2,mathpow,mathrandomseed,mathfrexp,mathabs,mathtanh,mathacos,mathlog,mathtan,mathmin,mathceil,mathsinh,mathsqrt,mathhuge,mathrad,mathsin,mathexp,mathcos,mathatan,mathpi = math.deg,math.fmod,math.random,math.asin,math.max,math.modf,math.floor,math.cosh,math.ldexp,math.atan2,math.pow,math.randomseed,math.frexp,math.abs,math.tanh,math.acos,math.log,math.tan,math.min,math.ceil,math.sinh,math.sqrt,math.huge,math.rad,math.sin,math.exp,math.cos,math.atan,math.pi
- --[[ Table ]]--
- local tablepack,tableforeachi,tableforeach,tableremove,tableinsert,tableunpack,tableconcat,tablesort = table.pack,table.foreachi,table.foreach,table.remove,table.insert,table.unpack,table.concat,table.sort
- --[[ API ]]--
- -- Timers
- system.newGameTimer = 0
- -- Control
- system.officialMode = {"",""}
- system.setAdmins = function()
- local out = {}
- for k,v in next,module._FREEACCESS do
- if v > 2 then
- out[k] = true
- end
- end
- return out
- end
- -- Improvements
- table.concat = function(list,sep,f,i,j)
- local txt = ""
- sep = sep or ""
- i,j = i or 1,j or #list
- for k,v in next,list do
- if type(k) ~= "number" and true or (k >= i and k <= j) then
- txt = txt .. (f and f(k,v) or v) .. sep
- end
- end
- return string.sub(txt,1,-1-#sep)
- end
- do
- local newGame = tfm.exec.newGame
- tfm.exec.newGame = function(code)
- if os.time() > system.newGameTimer then
- system.newGameTimer = os.time() + 6000
- newGame(code)
- return true
- end
- return false
- end
- local addImage = tfm.exec.addImage
- local removeImage = tfm.exec.removeImage
- tfm.exec.addImage = function(...)
- local id = addImage(...)
- if id then
- system.objects.image[id] = true
- end
- return id or -1
- end
- tfm.exec.removeImage = function(id)
- removeImage(id)
- if system.objects.image[id] then
- system.objects.image[id] = nil
- end
- end
- local addTextArea = ui.addTextArea
- ui.addTextArea = function(id,...)
- addTextArea(id,...)
- if not system.objects.textarea[id] then
- system.objects.textarea[id] = true
- end
- end
- local chatMessage = tfm.exec.chatMessage
- tfm.exec.chatMessage = function(txt,n)
- if #txt > 1000 then
- local total = 0
- while #txt > total do
- chatMessage(string.sub(txt,total,total + 1000),n)
- total = total + 1001
- end
- else
- chatMessage(txt,n)
- end
- end
- local loadPlayerData = system.loadPlayerData
- system.loadPlayerData = function(n)
- if module._STATUS == "official" then
- return loadPlayerData(n)
- else
- if _G["eventPlayerDataLoaded"] then
- eventPlayerDataLoaded(n,"")
- end
- return true
- end
- end
- local savePlayerData = system.savePlayerData
- system.savePlayerData = function(n,data)
- if module._STATUS == "official" then
- savePlayerData(n,data)
- return true
- else
- return false
- end
- end
- end
- -- Room
- system.isRoom = string.byte(tfm.get.room.name,2) ~= 3
- system.roomAdmins = system.setAdmins()
- system.miscAttrib = 0
- system.roomNumber,system.roomAttributes = (function()
- if system.isRoom then
- local number,attribute = string.match(tfm.get.room.name,"%*?#"..module._NAME.."(%d+)(.*)")
- return tonumber(number) or "",attribute or ""
- else
- return "",""
- end
- end)()
- -- Player
- system.isPlayer = function(n)
- --[[
- The player must not be a souris;
- The player must have played Transformice for at least 5 days
- ]]
- return tfm.get.room.playerList[n] and string.sub(n,1,1) ~= "*" and tfm.get.room.playerList[n].registrationDate and (os.time() - (tfm.get.room.playerList[n].registrationDate or 0) >= 432e6) or false
- end
- system.players = function(alivePlayers)
- local alive,total = 0,0
- if alivePlayers then
- alive = {}
- end
- for k,v in next,tfm.get.room.playerList do
- if system.isPlayer(k) then
- if not v.isDead and not v.isVampire then
- if alivePlayers then
- alive[#alive + 1] = k
- else
- alive = alive + 1
- end
- end
- total = total + 1
- end
- end
- if alivePlayers then
- return alive
- else
- return alive,total
- end
- end
- -- System
- currentTime,leftTime = 0,0
- system.loadTable = function(s)
- -- "a.b.c.1" returns a[b][c][1]
- local list
- for tbl in string.gmatch(s,"[^%.]+") do
- tbl = tonumber(tbl) and tonumber(tbl) or tbl
- list = (list and list[tbl] or _G[tbl])
- end
- return list
- end
- system.getTranslation = function(index,n)
- local t = string.format("mode.%s.translations.%s.%s",system.gameMode,(n and mode[system.gameMode].info[n].langue or mode[system.gameMode].langue),index)
- return system.loadTable(t) or system.loadTable(string.gsub(t,"translations%..-%.",function() return "translations.en." end))
- end
- system.looping = function(f,tick)
- local s = 1000 / tick
- local t = {}
- local fooTimer = function()
- t[#t+1] = system.newTimer(f,1000,true)
- end
- for timer = 0,1000 - s,s do
- system.newTimer(fooTimer,1000 + timer,false)
- end
- return t
- end
- -- Interface
- ui.banner = function(image,aX,aY,n,time)
- time = time or 5
- axis = axis or {100,100}
- local img = tfm.exec.addImage(image .. ".png","&0",aX,aY,n)
- system.newTimer(function()
- tfm.exec.removeImage(img)
- end,time * 1000,false)
- end
- -- Math
- math.isNegative = function(x,iN,iP)
- iN = iN == nil and x or iN
- iP = iP == nil and x or iP
- return (x<0 and iN or iP)
- end
- math.percent = function(x,y,v)
- v = (v or 100)
- local m = x/y * v
- return math.min(m,v)
- end
- math.pythag = function(x1,y1,x2,y2,range)
- return (x1-x2)^2 + (y1-y2)^2 <= (range^2)
- end
- math.setLim = function(value,min,max)
- return math.max(min,math.min(max,value))
- end
- -- String
- string.split = function(value,pattern,f)
- local out = {}
- for v in string.gmatch(value,pattern) do
- out[#out + 1] = (f and f(v) or v)
- end
- return out
- end
- string.nick = function(player)
- return string.gsub(string.lower(player),"%a",string.upper,1)
- end
- -- Table
- table.find = function(list,value,index,f)
- for k,v in next,list do
- local i = (type(v) == "table" and index and v[index] or v)
- if (f and f(i) or i) == value then
- return true,k
- end
- end
- return false,0
- end
- table.turnTable = function(x)
- return (type(x)=="table" and x or {x})
- end
- table.random = function(t)
- return (type(t) == "table" and t[math.random(#t)] or math.random())
- end
- table.shuffle = function(t)
- local randomized = {}
- for v = 1,#t do
- table.insert(randomized,math.random(#randomized),t[v])
- end
- return randomized
- end
- -- Others
- deactivateAccents=function(str)
- local letters = {a = {"á","â","à ","Ã¥","ã","ä"},e = {"é","ê","è","ë"},i = {"Ã","î","ì","ï"},o = {"ó","ô","ò","õ","ö"},u = {"ú","û","ù","ü"}}
- for k,v in next,letters do
- for i = 1,#v do
- str = string.gsub(str,v[i],tostring(k))
- end
- end
- return str
- end
- normalizeTime = function(time)
- return math.floor(time) + ((time - math.floor(time)) >= .5 and .5 or 0)
- end
- disableChatCommand = function(command)
- system.disableChatCommandDisplay(command,true)
- system.disableChatCommandDisplay(string.lower(command),true)
- system.disableChatCommandDisplay(string.upper(command),true)
- end
- normalizeTranslation = function()
- local t = mode[system.gameMode].translations
- for k,v in next,t.en do
- for i,j in next,t do
- if i ~= "en" then
- if not j[k] then
- j[k] = v
- end
- end
- end
- end
- end
- normalizeNumber = function(number)
- number = tostring(math.floor(number))
- number = string.gsub(number,"E(%d+)",function(cn) -- e5 = 00000
- return string.rep("0",tonumber(cn))
- end)
- number = string.gsub(string.reverse(number),"(...)",function(c)
- return c .. " "
- end)
- return string.reverse(number)
- end
- -- XML Dealer
- xml = {}
- xml.parse = function(currentXml)
- currentXml = string.match(currentXml,"<P (.-)/>") or ""
- local out = {}
- for tag,_,value in string.gmatch(currentXml,"([%-%w]+)=([\"'])(.-)%2") do
- out[tag] = value
- end
- return out
- end
- xml.attribFunc = function(currentXml,funcs)
- local attributes = xml.parse(currentXml)
- for k,v in next,funcs do
- if attributes[v.attribute] then
- v.func(attributes[v.attribute])
- end
- end
- end
- xml.addAttrib = function(currentXml,out,launch)
- local parameters = string.match(currentXml,"<P (.-)/>") or ""
- for k,v in next,out do
- if not string.find(parameters,v.tag) then
- currentXml = string.gsub(currentXml,"<P (.-)/>",function(attribs)
- return string.format("<P %s=\"%s\" %s/>",v.tag,v.value,attribs)
- end)
- end
- end
- if launch then
- tfm.exec.newGame(currentXml)
- else
- return currentXml
- end
- end
- xml.getCoordinates = function(s)
- if string.find(s,";") then
- local x,y
- local axis,value = string.match(s,"(%a);(%d+)")
- value = tonumber(value)
- if value then
- if axis == "x" then x = value else y = value end
- end
- return x or 0,y or 0
- else
- local pos = {}
- for x,y in string.gmatch(s,"(%d+) ?, ?(%d+)") do
- pos[#pos+1] = {x = x,y = y}
- end
- return pos
- end
- end
- -- Colors
- color = {
- hexToRgb = function(hex)
- local h = string.format("%06x",hex)
- return tonumber("0x"..string.sub(h,1,2)),tonumber("0x"..string.sub(h,3,4)),tonumber("0x"..string.sub(h,5,6))
- end,
- rgbToHsl = function(r,g,b)
- r,g,b = r/255,g/255,b/255
- local max,min = math.max(r,g,b),math.min(r,g,b)
- local h,s,l
- h = (max + min) / 2
- s,l = h,h
- if max == min then
- h,s = 0,0
- else
- local d = max - min
- local s = l > .5 and (d/(2 - max - min)) or (d/(max + min))
- if max == r then
- h = (g-b)/d
- if g < b then
- h = h + 6
- end
- elseif max == g then
- h = (b-r)/d + 2
- elseif max == b then
- h = (r-g)/d + 4
- end
- h = h/6
- end
- return {h=h,s=s,l=l}
- end,
- hslToRgb = function(h,s,l,a)
- local r,g,b
- if s == 0 then
- r,g,b = l,l,l
- else
- local hueToRgb = function(p,q,t)
- if t < 0 then
- t = t + 1
- end
- if t > 1 then
- t = t - 1
- end
- if t < 1/6 then
- return p + (q - p) * 6 * t
- end
- if t < 1/2 then
- return q
- end
- if t < 2/3 then
- return p + (q - p) * (2/3 - t) * 6
- end
- return p
- end
- local q = l < .5 and (l * (1 + s)) or (l + s - l * s)
- local p = 2 * l - q
- r = hueToRgb(p,q,h + 1/3)
- g = hueToRgb(p,q,h)
- b = hueToRgb(p,q,h - 1/3)
- end
- return r * 255,g * 255,b * 255
- end,
- rgbToHex = function(r,g,b)
- return tonumber(string.format('%02x%02x%02x',r,g,b),16)
- end,
- YELLOW = 0xF9EC27,
- RED = 0xF94226,
- LIGHT_RED = 0xD1605D,
- BLUE = 0x34A4E5,
- DEEP_BLUE = 0x4F7F9A,
- DARK_BLUE = 0x2D80AF,
- GRAY = 0x969696,
- SALMON = 0xAC6C64,
- BROWN = 0x89635A,
- BEIGE = 0x937A53,
- TURQUOISE = 0x59D1C8,
- ROSE = 0x816669,
- MOSS_GREEN = 0x689636,
- }
- --[[ GameMode ]]--
- system.submodes = {}
- system.gameMode = module._NAME
- system.modeChanged = os.time() + 10e3
- system.getGameMode = function(value,notFirst)
- local found,submode = tablefind(system.submodes,stringlower(value),nil,stringlower)
- if found then
- system.gameMode = system.submodes[submode]
- if notFirst then
- eventModeChanged()
- end
- system.modeChanged = os.time() + 10e3
- end
- return found
- end
- --[[ Modes ]]--
- mode = setmetatable({},{
- __newindex = function(list,key,value)
- rawset(list,key,value)
- system.submodes[#system.submodes+1] = key
- end
- })
- --[[ Universe ]]--
- mode.universe = {
- -- Translations
- translations = {
- en = {
- -- Init
- welcome = "Welcome to <font color='#BD5DC5'><B>#Universe</B></font>. Build your own solar system or just enjoy the art.\n\tReport bugs to Bolodefchoco.",
- creator = "Now you are the creator of the universe! Press <B>O</B> and build it all!",
- -- Data
- objects = {
- star = {
- "Yellow Dwarf",
- "Red Dwarf",
- "Red Giant",
- "Blue Giant",
- "Supergiant",
- "White Dwarf",
- "Brown Dwarf",
- },
- planet = {
- "Chthonian",
- "Gas Dwarf",
- "Gas Giant",
- "Ice Giant",
- "Iron",
- "Sillicate",
- "Telluric",
- "Dwarf",
- },
- moon = {
- "Asteroid",
- "Irregular Asteroid",
- },
- },
- menu = {
- class = "Class",
- type = "Type",
- name = "Name",
- color = "Color",
- size = "Size",
- temperature = "Temperature",
- satellite = "Satellite of",
- velocity = "Velocity",
- distance = "Distance",
- rings = "Rings",
- gravity = "Gravity",
- mass = "Mass",
- flow = "Flow",
- luminosity = "Luminosity",
- magnitude = "Magnitude",
- rotation = "Rotation",
- translation = "Translation",
- },
- -- Interface
- buttons = {
- keyboard = {
- "submit",
- "backspace",
- "clear"
- },
- classes = {
- "Star",
- "Planet",
- "Moon"
- },
- main = {
- create = "Create",
- reset = "Reset",
- destroy = "Destroy",
- recreate = "Recreate",
- },
- },
- color = {
- previous = "Previous Color",
- next = "Next Color"
- },
- profile = {
- profiles = "profiles",
- exTime = "Existence Time",
- information = "Information",
- main = "Main",
- planets = "Planets",
- life = "Life",
- periods = "Periods",
- orbit = "Orbit",
- satellites = "Satellites",
- },
- exit = "Exit",
- choose = "Choose",
- yes = "Yes",
- no = "No",
- -- Warning
- newObject = {
- "New <B>%s star</B> created!",
- "New <B>%s planet</B> created!",
- "New <B>%s moon</B> orbiting %s!",
- },
- checkProfile = "Check its profile using the command <B>!profile %s</B>",
- fail = "The attributes %s are invalid!",
- nameExist = "There's already an object named \"%s\"!",
- destroyConfirm = "Are you sure you want to delete the %s \"%s\"?",
- cantDestroy = "You cannot destroy this object!",
- moonDestroyed = "All the moons of this planet were destroyed too!",
- systemDestroyed = "This Solar System was destroyed!",
- moonRecreated = "The moons of this planet were recreated!",
- planetRecreated = "The planet which the recreated moon orbits was also recreated (also the other moons, if exists)!",
- systemRecreated = "The System was recreated!",
- sysName = {
- choose = "Set below a name for the Solar System. (20- characters)",
- new = "This Solar System has been renamed to \"%s\"! \o/",
- },
- },
- br = {
- welcome = "Bem-vindo ao <font color='#BD5DC5'><B>#Universe</B></font>. Construa seu próprio sistema solar or apenas aproveite a arte.\n\tReporte bugs a Bolodefchoco.",
- creator = "Agora você é o criador do universo! Pressione <B>O</B> e construa isso tudo!",
- objects = {
- star = {
- "Anã Amarela",
- "Anã Vermelha",
- "Gigante Vermelha",
- "Gigante Azul",
- "Super Gigante",
- "Anã Branca",
- "Anã Marrom",
- },
- planet = {
- "Ctoniano",
- "Anão Gasoso",
- "Gigante Gasoso",
- "Gigante Gelado",
- "Ferro",
- "Silicato",
- "Telúrico",
- "Anão",
- },
- moon = {
- "Asteróide",
- "Asteróide Irregular",
- },
- },
- menu = {
- class = "Classe",
- type = "Tipo",
- name = "Nome",
- color = "Cor",
- size = "Tamanho",
- temperature = "Temperatura",
- satellite = "Satélite de",
- velocity = "Velocidade",
- distance = "Distância",
- rings = "Anéis",
- gravity = "Gravidade",
- mass = "Massa",
- flow = "Fluxo",
- luminosity = "Luminosidade",
- magnitude = "Magnitude",
- rotation = "Rotação",
- translation = "Translação",
- },
- buttons = {
- keyboard = {
- "enviar",
- "apagar",
- "limpar"
- },
- classes = {
- "Estrela",
- "Planeta",
- "Lua"
- },
- main = {
- create = "Criar",
- reset = "Resetar",
- destroy = "Destruir",
- recreate = "Recriar",
- },
- },
- color = {
- previous = "Cor Anterior",
- next = "Próxima Cor"
- },
- profile = {
- profiles = "perfis",
- exTime = "Tempo de Existência",
- information = "Informação",
- main = "Principal",
- planets = "Planetas",
- life = "Vida",
- periods = "PerÃodo",
- orbit = "Órbita",
- satellites = "Satélites",
- },
- exit = "Sair",
- choose = "Escolher",
- yes = "Sim",
- no = "Não",
- newObject = {
- "Nova <B>%s estrela</B> criada!",
- "Novo <B>%s planeta</B> criado!",
- "Nova <B>%s lua</B> orbitando %s!",
- },
- checkProfile = "Cheque seu perfil usando o comando <B>!profile %s</B>",
- fail = "Os atributos %s são inválidos!",
- nameExist = "Já existe um objeto nomeado \"%s\"!",
- destroyConfirm = "Você tem certeza de que quer destruir a/o %s \"%s\"?",
- cantDestroy = "Você não pode destruir este objeto!",
- systemDestroyed = "Este Sistema Solar foi destruido!",
- moonRecreated = "As luas deste planeta foram recriadas!",
- planetRecreated = "O planeta do qual a lua recriada orbita também foi recriado (também as outras luas, se existirem)!",
- systemRecreated = "O Sistema foi recriado!",
- sysName = {
- choose = "Defina abaixo um nome para o Sistema Solar. (20- caracteres)",
- new = "Este Sistema Solar foi renomeado para \"%s\"! \o/",
- },
- },
- },
- langue = "en",
- -- Data
- info = {},
- cosmos = {}, -- Objects
- stuff = {},
- orbit = {0,0,0,0}, -- All Stars, All Planets, All Moons, All Objects
- star = false, -- Exist main star
- tab = " ",
- systemName = "Solar System",
- images = {
- background = {"15db9f4a44f","15db9f50264","15db9f54ea6","15db9f59aad","15db9f5efb4","15db9f64e66","15db9f6a13a","15db9f6ef03","15db9f7421f","15db9f7aaa8","15db9f80f07","15db9f87630","15db9f8d13b","15db9f93278","15db9f98bca","15db9f9d34d","15db9fa1d2f","15db9fa7ad3","15db9fae62e","15db9fb676f","15db9fbbdd5","15db9fc1b41","15db9fc709d","15db9fcc98d","15db9fd2208","15db9fd7961","15db9fde6ff","15db9fe6bb8","15db9fec6fa","15db9ff2ba4","15db9ff8560","15db9ffe293","15dba00379e","15dba008b05","15dba00f91c","15dba015ac7","15dba01a707","15dba01f8b7","15dba024274","15dba029d5b","15dba02d979","15dba032a4f","15dba0385b5","15dba03e3fc","15dba0424ef","15dba048372","15dba04cb9a","15dba04fd20","15dba053be1","15dba058fb2","15dba05d5ce","15dba063b0e","15dba06a0c7","15dba070036","15dba074e9d","15dba0799df","15dba07e421","15dba083354","15dba087775","15dba08bbba","15dba0914fd","15dba096cb2","15dba09c513","15dba0a1d3e"},
- ufos = {"15dbf1c1b08","15dbf1c6f9d","15dbf1cb752","15dbf20a2c1","15dbf20e553"},
- },
- -- New Game Settings
- canInsertBackground = false,
- -- Other settings
- ufoId = -1,
- -- Objects
- data = {
- objects = {
- star = {
- --[[
- Name;
- Color accuracy;
- Size range
- ]]
- {"Yellow Dwarf",{color.YELLOW},"40:100"},
- {"Red Dwarf",{color.RED},"40:100"},
- {"Red Giant",{color.RED},"80:160"},
- {"Blue Giant",{color.BLUE},"80:160"},
- {"Supergiant",{color.YELLOW,color.RED,color.BLUE},"80:160"},
- {"White Dwarf",{color.GRAY},"30:60"},
- {"Brown Dwarf",{color.BROWN},"30:60"},
- },
- planet = {
- --[[
- Name;
- Color accuracy;
- Size range;
- Lifeable;
- Queue Limit (where positive = not > x ; negative = not < abs(x) and 0 is free)
- ]]
- {"Chthonian",{color.BROWN,color.TURQUOISE,color.BEIGE},"15:35",false,2},
- {"Gas Dwarf",{color.GRAY,color.BEIGE,color.TURQUOISE,color.LIGHT_RED},"20:30",false,-2},
- {"Gas Giant",{color.GRAY,color.BEIGE,color.TURQUOISE,color.LIGHT_RED},"25:60",false,-2},
- {"Ice Giant",{color.DEEP_BLUE,color.TURQUOISE,color.DARK_BLUE},"20:45",false,-3},
- {"Iron",{color.GRAY,color.BEIGE,color.ROSE},"15:25",true,0},
- {"Sillicate",{color.BEIGE,color.ROSE,color.MOSS_GREEN,color.DARK_BLUE},"20:30",true,0},
- {"Telluric",{color.BEIGE,color.ROSE,color.MOSS_GREEN,color.DARK_BLUE},"15:35",true,0},
- {"Dwarf",{color.GRAY,color.BEIGE},"5:12",true,-1},
- },
- moon = {
- --[[
- Name;
- Color accuracy;
- Size range
- ]]
- {"Asteroid",{color.GRAY},"5:8"},
- {"Irregular Asteroid",{color.GRAY,color.BEIGE},"2:6"},
- },
- },
- classes = {
- },
- menu = {
- },
- },
- -- Meta
- meta = {
- add = {
- __add = function(listOne,listTwo) -- Link two tables in one
- local out = {}
- for k,v in next,{listOne,listTwo} do
- for i,j in next,v do
- out[(type(i) == "string" and i or #out+1)] = j
- end
- end
- return setmetatable(out,getmetatable(listOne))
- end
- },
- },
- -- Keyboard system
- keyboard = function()
- local k = ""
- local key = "<a href='event:keyboard.@.insert.%s'>%s</a> "
- for i = string.byte("A"),string.byte("Z") do -- Letters
- k = k .. string.format(key,i,string.char(i))
- end
- k = k .. "\n"
- for i = string.byte("0"),string.byte("9") do -- Numbers
- k = k .. string.format(key,i,string.char(i))
- end
- k = k .. "\n"
- for i,j in next,{string.byte("-_",1,2)} do -- Characters
- k = k .. string.format(key,j,string.char(j))
- end
- return k
- end,
- -- Monochromatic System
- paletteMonochromatic = function(hex,amount,period,reversed)
- local hsl = color.rgbToHsl(color.hexToRgb(hex))
- local colors = {}
- local final = 1
- if reversed then
- final = hsl.l - amount
- period = -period
- end
- for i = hsl.l,final,period do
- colors[#colors+1] = color.rgbToHex(color.hslToRgb(hsl.h,hsl.s,i))
- amount = amount - 1
- if amount == 0 then
- break
- end
- end
- if reversed then
- table.remove(colors,1)
- end
- return colors
- end,
- -- UI
- uinew = function(id,text,player,x,y,w,h,hasBg,color)
- w,h = w or 100,h or 100
- x,y = ((x or 400) - (w/2)),((y or 400) - (h/2))
- id = id>0 and id*5 or id
- if hasBg then
- ui.addTextArea(id,"",player,5,5,790,400,1,1,.5,true)
- end
- ui.addTextArea(id+1,"",player,x,y,w,h,0x0C191C,0x0C191C,1,true)
- ui.addTextArea(id+2,"",player,x+1,y+1,w-2,h-2,0x24474D,0x24474D,1,true)
- ui.addTextArea(id+3,"",player,x+2,y+2,w-4,h-4,0x183337,0x183337,1,true)
- ui.addTextArea(id+4,text,player,x+2,y+3,w-4,h-5,color or 0x122528,color or 0x122528,1,true)
- end,
- uiremove = function(id,player)
- id = id>0 and id*5 or id
- for i = id + 4,id,-1 do
- ui.removeTextArea(i,player)
- end
- end,
- -- UI Colors
- uipaletteMono = function(hex,n)
- mode.universe.info[n].settings.palette[1] = mode.universe.info[n].settings.palette[1] < 1 and #hex or mode.universe.info[n].settings.palette[1] > #hex and 1 or mode.universe.info[n].settings.palette[1]
- local darker = mode.universe.paletteMonochromatic(hex[mode.universe.info[n].settings.palette[1]],5,0.07,true)
- local lighter = mode.universe.paletteMonochromatic(hex[mode.universe.info[n].settings.palette[1]],5,0.07,false)
- local colors = setmetatable(darker,mode.universe.meta.add)
- colors = colors + lighter
- table.sort(colors)
- local div = mode.universe.tab .. "<BL>|<V>" .. mode.universe.tab
- mode.universe.uinew(10,string.format("<font size='11'><V><a href='event:palette.left'>« %s</a>%s<a href='event:palette.right'>%s »</a>%s<a href='event:palette.exit'>%s</a>",system.getTranslation("color.previous"),div,system.getTranslation("color.next"),div,system.getTranslation("exit")),n,400,200,450,80,true)
- for i = 1,#colors do
- local color = colors[i]
- mode.universe.uinew(i + 10,color and ("<font size='7'>\n<p align='center'><font size='13' color='#"..string.format("%X",0xFFFFFF-color).."'><a href='event:item.color." .. color .. "'>â– </a>"),n,150 + (50*i) or "",215,40,40,false,color)
- end
- end,
- -- UI Hrefs
- uiitems = function(text,n,h)
- mode.universe.uinew(10,text,n,400,200,180,h or 180,true)
- end,
- -- UI Keyboard
- uikeyboard = function(id,str,n)
- mode.universe.uinew(10,table.concat(system.getTranslation("buttons.keyboard"),"\n",function(k,v)
- return string.format("<%s><a href='event:keyboard.%s.%s'>%s</a>",k==1 and "J" or "R",id,v,string.upper(v))
- end) .. "\n\n<p align='center'><PT>" .. string.gsub(mode.universe.keyboard,"@",id) .. "\n\n<font size='15'><T>" .. table.concat(str),n,400,200,320,150,true)
- end,
- -- UI Conter
- uicounter = function(id,range,n,limit,increment)
- local min,max = string.match(range,"(%-?%d+):(%-?%d+)")
- min,max = tonumber(min),tonumber(max)
- if mode.universe.info[n].settings[id][1] == -math.huge then
- mode.universe.info[n].settings[id][1] = math.ceil((min+max)/2)
- else
- mode.universe.info[n].settings[id][1] = math.setLim(mode.universe.info[n].settings[id][1],min,max)
- end
- limit = limit or 10
- increment = string.gsub(tostring(increment or 1),"%.","%%s")
- mode.universe.info[n].settings[id][2] = math.setLim(mode.universe.info[n].settings[id][2],.1,limit)
- mode.universe.uinew(10,"<p align='center'><font size='20'><V><B>"..string.upper(id).."</B><font size='7'>\n\n<font size='12'><p align='left'><J><a href='event:counter."..id..".submit'>SUBMIT</a>"..string.rep(mode.universe.tab,3).."<PT><a href='event:counter."..id..".add."..increment.."'><B>+</B></a> <J>" .. mode.universe.info[n].settings[id][2] .. " <R><a href='event:counter."..id..".sub."..increment.."'><B>-</B></a>\n\n\n<p align='center'><font size='16'><S><a href='event:item."..id..".add'>â–²</a> <PS>" .. mode.universe.info[n].settings[id][1] .. " <S><a href='event:item."..id..".sub'>â–¼</a>",n,400,200,180,130,true)
- end,
- -- UI Close
- uicloseSplash = function(n,close)
- for i = 10,19 do
- mode.universe.uiremove(i,n)
- end
- if not close then
- mode.universe.uicreator(n)
- end
- end,
- -- UI Creator
- uicreator = function(n)
- mode.universe.uinew(0,table.concat(mode.universe.info[n].settings.create,"\n<font size='4'>\n</font>",function(k,v)
- return string.format(v[1],tostring(v[2](n)))
- end),n,400,200,540,300,true)
- mode.universe.uinew(1,"<p align='center'><VI><a href='event:main.create'>" .. system.getTranslation("buttons.main.create") .. "</a>",n,180,338,100,24,false)
- mode.universe.uinew(2,"<p align='center'><VI><a href='event:main.recreate'>" .. system.getTranslation("buttons.main.recreate") .. "</a>",n,290,338,100,24,false)
- mode.universe.uinew(3,"<p align='center'><R><a href='event:main.destroy'>" .. system.getTranslation("buttons.main.destroy") .. "</a>",n,400,338,100,24,false)
- mode.universe.uinew(4,"<p align='center'><BV><a href='event:main.reset'>" .. system.getTranslation("buttons.main.reset") .. "</a>",n,510,338,100,24,false)
- mode.universe.uinew(5,"<p align='center'><VP><a href='event:main.exit'>" .. system.getTranslation("exit") .. "</a>",n,620,338,100,24,false)
- mode.universe.info[n].creatorOpen = true
- end,
- -- UI Clear Creator List
- uiclearCreator = function(n,range)
- for i = 1,#mode.universe.info[n].settings.create do
- if i > (range or 1) then
- mode.universe.info[n].settings.create[i] = nil
- end
- end
- end,
- -- UI Clear Creator
- uiresetCreator = function(n)
- mode.universe.info[n].settings.palette = {1,{},1}
- mode.universe.info[n].settings.size = {-math.huge,5}
- mode.universe.info[n].settings.temperature = {-math.huge,5,true}
- mode.universe.info[n].settings.velocity = {-math.huge,1,true}
- mode.universe.info[n].settings.distance = {-math.huge,5,true}
- mode.universe.info[n].settings.rings = false
- mode.universe.info[n].settings.satellite = 0
- end,
- -- UI Menu Bar
- infoBar = function()
- local out = {
- {"<font color='#CF50DB'>%s",mode.universe.systemName},
- {system.getTranslation("buttons.classes.1") .. " : <V>%s",mode.universe.orbit[1]},
- {system.getTranslation("buttons.classes.2") .. " : <V>%s",mode.universe.orbit[2]},
- {system.getTranslation("buttons.classes.3") .. " : <V>%s",mode.universe.orbit[3]},
- {system.getTranslation("profile.exTime") .. " : <V>%s",(_G.currentTime / 25)},
- }
- return table.concat(out," <G>| <N>",function(k,v)
- return string.format(v[1],v[2])
- end) .. "<"
- end,
- -- Background
- insertion = function(n)
- local y = 0
- for i = 0,63 do
- if i > 0 and i % 8 == 0 then
- y = y + 1000
- end
- tfm.exec.addImage(mode.universe.images.background[i + 1] .. ".png","?" .. i,(i%8) * 1000,y,n)
- if i % 10 == 0 then
- coroutine.yield()
- end
- end
- tfm.exec.addImage("15db9e67479.png","?64",3970,3973,n)
- end,
- setBackground = function(n)
- local timerId
- local insert = coroutine.create(mode.universe.insertion)
- timerId = system.newTimer(function()
- coroutine.resume(insert,n)
- if coroutine.status(insert) == "dead" then
- system.removeTimer(timerId)
- end
- end,1000,true)
- end,
- -- Profiles
- profile = {
- uiprofile = function(n)
- mode.universe.uiitems("<p align='center'><font size='20'><V><B>" .. string.upper(system.getTranslation("profile.profiles")) .. "</B><font size='12'>\n<a href='event:profile.exit'>" .. system.getTranslation("exit") .. "</a><p align='left'>\n\n<S>" .. table.concat(mode.universe.cosmos,"\n",function(k,v)
- return string.format("%s <a href='event:profile.open.%s.%s'>%s</a>",(v.id == mode.universe.cosmos[1].id and "<a:active>★</a:active>" or "<CE>[" .. v.className .."]</CE>"),v.className,k,v.name)
- end),n,300)
- end,
- uiremoveprofile = function(n)
- for i = 1,41 do
- ui.removeTextArea(-i,n)
- end
- end,
- profileStar = function(obj,n)
- mode.universe.profile.uiremoveprofile(n)
- obj = mode.universe.cosmos[tonumber(obj)]
- local objColor = string.upper(string.format("%x",obj.color))
- --tfm.exec.addImage("15d509ca726.png","?0",-110,-120,n)
- ui.addTextArea(-1,"",n,150,40,540,350,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-2,"",n,155,45,340,33,0x242F42,0x242F42,1,true)
- ui.addTextArea(-3,"<font size='16'><p align='center'><V>" .. (obj.id == mode.universe.cosmos[1].id and "<a:active>★</a:active>" or "") .. " <B>" .. obj.name .. "</B><font size='12'><p align='right'>\n<a href='event:profile.exit'>[" .. system.getTranslation("exit") .. "]</a>",n,158,42,340,45,1,1,0,true)
- ui.addTextArea(-4,"",n,170,127,122,23,0x242F42,0x242F42,1,true)
- ui.addTextArea(-5,"",n,180,100,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-6,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("menu.class"),n,181,101,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-7,"<p align='center'><V>" .. obj.className,n,171,128,120,25,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-8,"",n,180,195,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-9,"",n,170,222,122,23,0x242F42,0x242F42,1,true)
- ui.addTextArea(-10,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("menu.type"),n,181,196,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-11,"<p align='center'><V>" .. obj.typeName,n,171,223,120,25,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-12,"",n,180,305,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-13,"",n,170,332,122,23,0x242F42,0x242F42,1,true)
- ui.addTextArea(-14,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("profile.exTime"),n,181,306,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-15,"<p align='center'><V>" .. obj.time / 1e7,n,171,333,120,25,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-16,"",n,360,100,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-17,"",n,350,127,122,143,0x242F42,0x242F42,1,true)
- ui.addTextArea(-18,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("profile.information"),n,361,101,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-19,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.size") .. " : <V>" .. obj.size,n,351,128,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-20,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.color") .. " : <font color='#" .. objColor.. "'>#" .. objColor,n,351,152,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-21,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.gravity") .. " : <V>" .. obj.gravity,n,351,177,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-22,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.mass") .. " : <V>" .. obj.mass / 1e8,n,351,202,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-23,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.temperature") .. " : <V>" .. obj.temperature .. "°C",n,351,227,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-24,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("profile.main") .. " : <V>" .. (obj.id == mode.universe.cosmos[1].id and system.getTranslation("yes") or system.getTranslation("no")),n,351,252,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-25,"",n,360,290,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-26,"",n,350,316,122,40,0x242F42,0x242F42,1,true)
- ui.addTextArea(-27,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("menu.flow") .. " : <V>" .. obj.flow,n,361,291,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-28,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.luminosity") .. " : <V>" .. obj.luminosity,n,351,317,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-29,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.magnitude") .. " : <V>" .. obj.magnitude,n,351,342,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-30,"",n,550,46,102,20,0x242f42,0x242f42,1,true)
- ui.addTextArea(-31,"",n,540,72,122,288,0x242f42,0x242f42,1,true)
- ui.addTextArea(-32,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("profile.planets"),n,551,47,100,20,0x0f242e,0x0f242e,1,true)
- ui.addTextArea(-33,"<p align='center'><V>" .. table.concat(mode.universe.cosmos,"",function(k,v)
- return v.class == 2 and string.format("<a href='event:profile.open.Planet.%s'>%s</a>\n\n",k,v.name) or ""
- end),n,541,73,120,290,0x0f242e,0x0f242e,1,true)
- end,
- profilePlanet = function(obj,n)
- mode.universe.profile.uiremoveprofile(n)
- obj = mode.universe.cosmos[tonumber(obj)]
- local objColor = string.upper(string.format("%x",obj.color))
- --tfm.exec.addImage("15d509cc1ab.png","?0",-20,30,n)
- ui.addTextArea(-1,"",n,150,40,540,350,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-2,"",n,155,45,340,33,0x242F42,0x242F42,1,true)
- ui.addTextArea(-3,"<font size='16'><p align='center'><V><B>" .. obj.name .. "</B><font size='12'><p align='right'>\n<a href='event:profile.exit'>[" .. system.getTranslation("exit") .. "]</a>",n,158,42,340,45,1,1,0,true)
- ui.addTextArea(-4,"",n,180,100,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-5,"",n,170,127,122,23,0x242F42,0x242F42,1,true)
- ui.addTextArea(-6,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("menu.class"),n,181,101,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-7,"<p align='center'><V>" .. obj.className,n,171,128,120,25,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-8,"",n,180,170,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-9,"",n,170,197,122,23,0x242F42,0x242F42,1,true)
- ui.addTextArea(-10,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("menu.type"),n,181,171,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-11,"<p align='center'><V>" .. obj.typeName,n,171,198,120,25,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-12,"",n,180,240,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-13,"",n,170,267,122,23,0x242F42,0x242F42,1,true)
- ui.addTextArea(-14,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("profile.life"),n,181,241,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-15,"<p align='center'><V>" .. obj.life .. "%",n,171,268,120,25,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-16,"",n,180,315,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-17,"",n,170,342,122,23,0x242F42,0x242F42,1,true)
- ui.addTextArea(-18,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("menu.rings"),n,181,316,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-19,"<p align='center'><V>" .. (obj.rings and system.getTranslation("yes") or system.getTranslation("no")),n,171,343,120,25,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-20,"",n,360,100,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-21,"",n,350,127,122,143,0x242F42,0x242F42,1,true)
- ui.addTextArea(-22,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("profile.information"),n,361,101,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-23,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.size") .. " : <V>" .. obj.size,n,351,128,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-24,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.color") .. " : <font color='#" .. objColor.. "'>#" .. objColor,n,351,152,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-25,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.gravity") .. " : <V>" .. obj.gravity,n,351,177,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-26,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.mass") .. " : <V>" .. obj.mass / 1e8,n,351,202,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-27,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.temperature") .. " : <V>" .. obj.temperature .. "°C",n,351,227,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-28,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.velocity") .. " : <V>" .. obj.velocity,n,351,252,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-29,"",n,360,290,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-30,"",n,350,316,122,40,0x242F42,0x242F42,1,true)
- ui.addTextArea(-31,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("profile.periods"),n,361,291,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-32,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.rotation") .. " : <V>" .. obj.period.rotation,n,351,317,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-33,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.translation") .. " : <V>" .. obj.period.translation / 1e10,n,351,342,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-34,"",n,550,41,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-35,"",n,540,67,122,23,0x242F42,0x242F42,1,true)
- ui.addTextArea(-36,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("profile.orbit"),n,551,42,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-37,"<p align='center'><V>#" .. obj.planetPosition,n,541,68,120,25,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-38,"",n,550,116,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-39,"",n,540,142,122,214,0x242F42,0x242F42,1,true)
- ui.addTextArea(-40,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("profile.satellites"),n,551,117,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-41,"<p align='center'><V>" .. table.concat(obj.moons,"",function(k,v)
- return string.format("<a href='event:profile.open.Moon.%s'>%s</a>\n\n",mode.universe.cosmos[v].position,mode.universe.cosmos[v].name)
- end),n,541,143,120,216,0x0F242E,0x0F242E,1,true)
- end,
- profileMoon = function(obj,n)
- mode.universe.profile.uiremoveprofile(n)
- obj = mode.universe.cosmos[tonumber(obj)]
- local objColor = string.upper(string.format("%x",obj.color))
- --tfm.exec.addImage("15d41dcea87.png","?0",380,90,n)
- ui.addTextArea(-1,"",n,150,40,350,350,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-2,"",n,155,45,340,33,0x242F42,0x242F42,1,true)
- ui.addTextArea(-3,"<font size='16'><p align='center'><V><B>" .. obj.name .. "</B><font size='12'><p align='right'>\n<a href='event:profile.exit'>[" .. system.getTranslation("exit") .. "]</a>",n,158,42,340,45,1,1,0,true)
- ui.addTextArea(-4,"",n,170,127,122,23,0x242F42,0x242F42,1,true)
- ui.addTextArea(-5,"",n,180,100,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-6,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("menu.class"),n,181,101,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-7,"<p align='center'><V>" .. obj.className,n,171,128,120,25,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-8,"",n,180,170,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-9,"",n,170,197,122,23,0x242F42,0x242F42,1,true)
- ui.addTextArea(-10,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("menu.type"),n,181,171,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-11,"<p align='center'><V>" .. obj.typeName,n,171,198,120,25,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-12,"",n,180,240,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-13,"",n,170,267,122,23,0x242F42,0x242F42,1,true)
- ui.addTextArea(-14,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("profile.life"),n,181,241,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-15,"<p align='center'><V>" .. obj.life .. "%",n,171,268,120,25,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-16,"",n,180,315,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-17,"",n,170,342,122,23,0x242F42,0x242F42,1,true)
- ui.addTextArea(-18,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("menu.satellite"),n,181,316,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-19,"<p align='center'><V><a href='event:profile.open.Planet." .. obj.satelliteOf .. "'>" .. mode.universe.cosmos[obj.satelliteOf].name,n,171,343,120,25,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-20,"",n,360,100,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-21,"",n,350,127,122,143,0x242F42,0x242F42,1,true)
- ui.addTextArea(-22,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("profile.information"),n,361,101,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-23,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.size") .. " : <V>" .. obj.size,n,351,128,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-24,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.color") .. " : <font color='#" .. objColor.. "'>#" .. objColor,n,351,152,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-25,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.gravity") .. " : <V>" .. obj.gravity,n,351,177,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-26,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.mass") .. " : <V>" .. obj.mass / 1e8,n,351,202,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-27,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.temperature") .. " : <V>" .. obj.temperature .. "°C",n,351,227,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-28,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.velocity") .. " : <V>" .. obj.velocity,n,351,252,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-29,"",n,360,290,102,20,0x242F42,0x242F42,1,true)
- ui.addTextArea(-30,"",n,350,316,122,40,0x242F42,0x242F42,1,true)
- ui.addTextArea(-31,"<p align='center'><font color='#32C3CC'>" .. system.getTranslation("profile.periods"),n,361,291,100,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-32,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.rotation") .. " : <V>" .. obj.period.rotation,n,351,317,120,20,0x0F242E,0x0F242E,1,true)
- ui.addTextArea(-33,"<p align='center'><font color='#31AAB2'>" .. system.getTranslation("menu.translation") .. " : <V>" .. obj.period.translation,n,351,342,120,20,0x0F242E,0x0F242E,1,true)
- end,
- },
- -- Get
- getID = coroutine.wrap(function(class)
- local id,i = 0
- while true do
- i = ({2,4,3})[class]
- class = coroutine.yield(id)
- id = id + i
- end
- end),
- -- Get all classes
- getGravity = function(class,orbit)
- -- G * M / r²
- -- 6.67e-11 * mass / (size/2)^2
- if class == 1 then
- return 6.67e-11 * ((orbit * .49) * 1.3e6)
- elseif class == 2 then
- -- g will be (orbit * 0.49), since the distance Star-Earth(1) = 20 and 20/9.8 (its gravity) = 0.49
- return (orbit * .49)
- elseif class == 3 then
- return (orbit * .15)
- end
- end,
- getMass = function(gravity,size)
- -- g * r² / G
- -- gravity * (size/2)^2 / 6.67e-11
- -- Size is improved
- size = size * 5
- return (gravity * (size/2)^2) / 6.67e-11
- end,
- getTemperature = function(class,orbit)
- -- Unknown Algorithm Method
- if class == 1 then
- return math.random(1e3,1e4)
- else
- return math.log(orbit,mode.universe.cosmos[1].luminosity)
- end
- end,
- -- Get star
- getLuminosity = function(size,temperature)
- -- 4Ï€R^2sT^4
- -- 4 * 3.14 * size^2 * 5.67e-8 * temperature^4
- return 4 * 3.14 * size^2 * 5.67e-8 * temperature^4
- end,
- getFlow = function(luminosity,size)
- -- L / 4πr²
- -- luminosity / 4 * 3.14 * (size/2)^2
- return (luminosity / (4 * 3.14 * (size/2)^2))^.25
- end,
- getMagnitude = function(flow)
- local this = mode.universe.cosmos[id]
- -- –2.5 log(F1 / F2)
- -- -2.5 log(flow / -1.6)
- -- F2 will be –1.6 from Sirius, but it should be 0.00, from Vega
- return -2.5 * math.log(flow / -1.6)
- end,
- -- Get planet
- getVelocity = function(mass,size,orbit)
- -- sqrt (G * M) / R
- -- sqrt (6.67e-11 * mass) / R
- -- R will be (objectRadius * orbitRadius)
- return (((6.67e-11 * mass) / ((size/2) * (orbit/2)))^.5)^.25
- end,
- -- Get planet and moon
- getRotation = function(velocity)
- -- velocity * 365 * 24
- return velocity * 365 * 24
- end,
- getTranslation = function(mass,size)
- -- (4 * π^2 / G * M) * r^3
- -- (4 * 9.85 / 6.67e-11 * mass) * (size/2)^3
- return ((4 * 9.85 / 6.67e-11 * mass) * ((size/2)^3))^.5
- end,
- getDistance = function(class,data,size)
- if class == 2 then
- local id = data
- if mode.universe.orbit[2] > 0 then
- local current
- repeat
- id = id - 1
- current = mode.universe.cosmos[id]
- until current.class == 2
- return current.distance + (#current.moons * 3.1) + size
- else
- return size / 3
- end
- else -- Moon
- return mode.universe.cosmos[data].distance + mode.universe.cosmos[data].size/2 + #mode.universe.cosmos[data].moons * 2.3
- end
- end,
- getLifePossibility = function(this)
- local possibility = 0
- if this.class == 2 then
- if not mode.universe.data.objects[string.lower(this.className)][this.type][4] then
- return 0
- else
- possibility = possibility + 10
- if #this.moons > 0 then
- possibility = possibility + 10
- end
- if this.velocity > 0.7 and this.velocity < 2.4 then
- possibility = possibility + 10
- end
- end
- elseif this.class == 3 then
- if mode.universe.cosmos[this.satelliteOf].life >= 40 then
- possibility = possibility + 5
- end
- if string.find(string.lower(mode.universe.cosmos[this.satelliteOf].typeName),"gas") then
- possibility = possibility + 10
- end
- if this.velocity == 2.5 then
- possibility = possibility + 10
- end
- end
- local dist = this.distance
- local starSize = mode.universe.cosmos[1].size / 100
- if dist > (10 * starSize) then
- if dist > (50 * starSize) then
- if dist > (100 * starSize) then
- if dist > (200 * starSize) then
- if dist > (350 * starSize) then
- possibility = possibility + 10
- end
- else
- possibility = possibility + 45
- end
- else
- possibility = possibility + 60
- end
- else
- possibility = possibility + 5
- end
- end
- return possibility
- end,
- -- Objects
- object = {
- new = function(self,info)
- mode.universe.orbit[4] = mode.universe.orbit[4] + 1
- local data = {
- position = mode.universe.orbit[4],
- name = #info.name>0 and info.name or "?",
- class = info.class,
- type = info.type,
- size = info.size,
- color = info.color,
- display = false,
- }
- data.className = mode.universe.translations.en.buttons.classes[data.class] or "?"
- data.typeName = mode.universe.data.objects[string.lower(data.className)][data.type][1] or "?"
- data.gravity = mode.universe.getGravity(data.class,data.position)
- data.mass = mode.universe.getMass(data.gravity,data.size)
- data.temperature = (info.temperature == "auto" and mode.universe.getTemperature(data.class,data.position) or info.temperature)
- data.id = mode.universe.getID(data.class)
- if data.class == 1 then -- Star
- data.luminosity = mode.universe.getLuminosity(data.size,data.temperature)
- data.flow = mode.universe.getFlow(data.luminosity,data.size)
- data.magnitude = mode.universe.getMagnitude(data.flow)
- data.time = os.time()
- if not mode.universe.star then
- mode.universe.star = true
- end
- mode.universe.orbit[1] = mode.universe.orbit[1] + 1
- else
- if data.class == 2 then -- Planet
- data.moons = {}
- data.rings = info.rings
- data.orbit = mode.universe.orbit[2] + 1
- data.distance = (info.distance == "auto" and math.ceil(mode.universe.getDistance(data.class,data.position,data.size)) or math.ceil(info.distance))
- data.velocity = (info.velocity == "auto" and mode.universe.getVelocity(data.mass,data.size,data.orbit) or (info.velocity == 0 and .5 or info.velocity))
- elseif data.class == 3 then -- Moon
- data.satelliteOf = info.satelliteOf
- data.distance = math.ceil(mode.universe.getDistance(data.class,data.satelliteOf))
- data.velocity = 7 * table.random({.5,.3,.2,.1})
- mode.universe.cosmos[data.satelliteOf].moons[#mode.universe.cosmos[data.satelliteOf].moons + 1] = data.position
- end
- data.life = mode.universe.getLifePossibility(data)
- data.period = {
- rotation = mode.universe.getRotation(data.velocity),
- translation = mode.universe.getTranslation(data.mass,data.size)
- }
- if data.class == 2 then
- mode.universe.orbit[2] = mode.universe.orbit[2] + 1
- data.planetPosition = mode.universe.orbit[2]
- elseif data.class == 3 then
- mode.universe.orbit[3] = mode.universe.orbit[3] + 1
- end
- end
- mode.universe.cosmos[data.position] = data
- mode.universe.stuff[data.name] = true
- self.__index = self
- return setmetatable(data,self)
- end,
- destroy = function(self)
- if self.class > 1 then
- if self.class == 2 then -- Planet
- if #self.moons > 0 then
- for k,v in next,self.moons do
- mode.universe.cosmos[v]:destroy()
- end
- end
- if self.rings then
- tfm.exec.removeJoint(self.id + 3)
- end
- end
- -- Below: Planet and Moon
- tfm.exec.removeJoint(self.id + 2) -- Object's JR
- end
- tfm.exec.removeJoint(self.id + 1) -- Object's JD
- tfm.exec.removePhysicObject(self.id) -- Object
- self.display = false
- end,
- create = function(self)
- local x = 4e3
- local y = x - (mode.universe.star and (mode.universe.cosmos[1].id == self.id and 0 or (mode.universe.cosmos[1].size + (self.distance * 4))) or 0)
- local center = mode.universe.cosmos[1].id
- if self.class == 3 then -- Resets the satellite
- center = mode.universe.cosmos[self.satelliteOf].id
- end
- tfm.exec.addPhysicObject(self.id,x,y,{ -- Object
- type = 14, -- Used to be 13
- color = 1,
- width = 1,
- groundCollision = false,
- miceCollision = false,
- mass = 1,
- dynamic = (self.class ~= 1),
- })
- tfm.exec.addJoint(self.id + 1,self.id,self.id,{ -- JD (Color)
- type = 0,
- point1 = string.format("%s,%s",x,y),
- point2 = string.format("%s,%s",x,y+1),
- line = self.size,
- color = self.color,
- alpha = 1,
- foreground = true,
- })
- if self.class ~= 1 then -- Rotation
- tfm.exec.addJoint(self.id + 2,center,self.id,{
- type = 3,
- forceMotor = self.class == 3 and 10 or 9999,
- speedMotor = self.velocity
- })
- end
- if self.rings then
- tfm.exec.addJoint(self.id + 3,self.id,self.id,{
- type = 0,
- point1 = string.format("%s,%s",x - self.size,y + math.floor(self.rings.inclination * 1.5)),
- point2 = string.format("%s,%s",x + self.size,y - math.floor(self.rings.inclination * 1.5)),
- line = self.rings.volume,
- color = self.color,
- alpha = .7,
- foreground = 1
- })
- end
- if self.moons then
- for k,v in next,self.moons do
- mode.universe.object.create(mode.universe.cosmos[v])
- end
- end
- self.display = true
- end,
- },
- -- Set Admin
- newCreator = function(n)
- -- Data
- mode.universe.info[n] = {
- action = 0,
- creatorOpen = false,
- settings = {
- palette = {1,{},1}, -- Current Page, Color List, Selected Color
- -- For all bellow: [1]=Value,[2]=Counter,[[3] = isAutomatic]
- size = {-math.huge,5},
- temperature = {-math.huge,5,true},
- velocity = {-math.huge,1,true},
- distance = {-math.huge,5,true},
- -- Settings
- class = 0,
- type = 0,
- name = {},
- rings = false,
- satellite = 0,
- -- List
- create = setmetatable(
- {
- mode.universe.data.menu.class
- },
- mode.universe.meta.add
- ),
- },
- }
- -- Controls
- system.bindKeyboard(n,string.byte("O"),true,true)
- -- Message
- tfm.exec.chatMessage("<font color='#CF50DB'>[•] " .. system.getTranslation("creator"),n)
- end,
- -- Set dataMenu
- getDataMenus = function()
- mode.universe.data.menu = {
- class = {
- "<N2>" .. system.getTranslation("menu.class") .. " : <V><a href='event:newObject.class'>%s</a>",function(n)
- if mode.universe.info[n].settings.class > 0 then
- return mode.universe.data.classes[mode.universe.info[n].settings.class]
- else
- return system.getTranslation("choose")
- end
- end
- },
- type = {
- "<N2>" .. system.getTranslation("menu.type") .. " : <V><a href='event:newObject.type'>%s</a>",function(n)
- if mode.universe.info[n].settings.type > 0 then
- return mode.universe.data.objects[string.lower(mode.universe.translations.en.buttons.classes[mode.universe.info[n].settings.class])][mode.universe.info[n].settings.type][1]
- else
- return system.getTranslation("choose")
- end
- end
- },
- name = {
- "<N2>" .. system.getTranslation("menu.name") .. " : <V><a href='event:newObject.name'>%s</a>",function(n)
- if #mode.universe.info[n].settings.name > 0 then
- return table.concat(mode.universe.info[n].settings.name)
- else
- return system.getTranslation("choose")
- end
- end
- },
- color = {
- "<N2>" .. system.getTranslation("menu.color") .. " : <V><a href='event:newObject.color'>%s</a>",function(n)
- if mode.universe.info[n].settings.palette[3] ~= 1 then
- local color = string.format("%X",mode.universe.info[n].settings.palette[3])
- return string.format("<font color='#%s'>#%s</font>",color,color)
- else
- return system.getTranslation("choose")
- end
- end
- },
- size = {
- "<N2>" .. system.getTranslation("menu.size") .. " : <V><a href='event:newObject.size'>%s</a>",function(n)
- if mode.universe.info[n].settings.size[1] > -math.huge then
- return mode.universe.info[n].settings.size[1]
- else
- return system.getTranslation("choose")
- end
- end
- },
- temperature = {
- "<N2>" .. system.getTranslation("menu.temperature") .. " : <V><a href='event:options.temperature'>%s</a>",function(n)
- if mode.universe.info[n].settings.temperature[3] then
- return "Auto"
- else
- return mode.universe.info[n].settings.temperature[1] .. " °C"
- end
- end
- },
- satellite = {
- "<N2>" .. system.getTranslation("menu.satellite") .. " : <V><a href='event:newObject.moon'>%s</a>",function(n)
- if mode.universe.info[n].settings.satellite > 0 and mode.universe.cosmos[mode.universe.info[n].settings.satellite].name then
- return mode.universe.cosmos[mode.universe.info[n].settings.satellite].name
- else
- return system.getTranslation("choose")
- end
- end
- },
- velocity = {
- "<N2>" .. system.getTranslation("menu.velocity") .. " : <V><a href='event:options.velocity'>%s</a>",function(n)
- if mode.universe.info[n].settings.velocity[3] then
- return "Auto"
- else
- return mode.universe.info[n].settings.velocity[1]
- end
- end
- },
- distance = {
- "<N2>" .. system.getTranslation("menu.distance") .. " : <V><a href='event:options.distance'>%s</a>",function(n)
- if mode.universe.info[n].settings.distance[3] then
- return "Auto"
- else
- return mode.universe.info[n].settings.distance[1]
- end
- end
- },
- rings = {
- "<N2>" .. system.getTranslation("menu.rings") .. " : <V><a href='event:alternate.rings'>%s</a>",function(n)
- return mode.universe.info[n].settings.rings and system.getTranslation("yes") or system.getTranslation("no")
- end
- }
- }
- end,
- -- Init
- reset = function()
- table.foreach(system.roomAdmins,mode.universe.newCreator)
- end,
- init = function()
- -- Translation
- mode.universe.translations.pt = mode.universe.translations.br
- if mode.universe.translations[tfm.get.room.community] then
- mode.universe.langue = tfm.get.room.community
- end
- -- Keyboard
- mode.universe.keyboard = mode.universe.keyboard()
- -- Translations
- -- Set object translated names
- if mode.universe.langue ~= "en" then
- for k,v in next,mode.universe.data.objects do
- for i,j in next,v do
- j[1] = system.getTranslation("objects." .. k .. "." .. i)
- end
- end
- end
- -- Set class translations
- mode.universe.data.classes = system.getTranslation("buttons.classes")
- -- Menus
- mode.universe.getDataMenus()
- -- Loops
- system.newTimer(function()
- ui.setMapName(mode.universe.infoBar())
- end,1000,true)
- -- Admin
- if system.roomAttributes ~= 1 and system.roomNumber ~= 801 then
- table.foreach(system.roomAdmins,mode.universe.newCreator)
- end
- -- Settings
- tfm.exec.setRoomMaxPlayers(12)
- for _,f in next,{"AutoShaman","AutoNewGame","DebugCommand"} do
- tfm.exec["disable"..f]()
- end
- -- Map
- tfm.exec.newGame('<C><P L="8000" G="0," H="8000" /><Z><S><S P="1,,.3,.2,,,," L="3000" o="0" X="-1500" c="4" Y="-1000" T="12" H="3000" /><S H="3000" L="3000" o="0" X="-1500" c="4" Y="2000" T="12" P="1,,.3,.2,,,," /><S P="1,,.3,.2,,,," L="3000" o="0" X="-1500" c="4" Y="5000" T="12" H="3000" /><S H="3000" L="3000" o="0" X="1500" c="4" Y="9500" T="12" P="0,,.3,.2,,,," /><S P="1,,.3,.2,,,," L="3000" o="0" X="4500" c="4" Y="9500" T="12" H="3000" /><S H="3000" L="3000" o="0" X="9500" c="4" Y="5000" T="12" P="1,,.3,.2,,,," /><S H="3000" L="3000" o="0" X="7500" c="4" Y="9500" T="12" P="1,,.3,.2,,,," /><S P="1,,.3,.2,,,," L="3000" o="0" X="9500" c="4" Y="2000" T="12" H="3000" /><S H="3000" L="3000" o="0" X="9500" c="4" Y="-1000" T="12" P="1,,.3,.2,,,," /><S P="1,,.3,.2,,,," L="3000" o="0" X="-1500" c="4" Y="8000" T="12" H="3000" /><S P="1,,.3,.2,,,," L="3000" o="0" X="1500" c="4" Y="-1500" T="12" H="3000" /><S H="3000" L="3000" o="0" X="4500" c="4" Y="-1500" T="12" P="1,,.3,.2,,,," /><S P="1,,.3,.2,,,," L="3000" o="0" X="6500" c="4" Y="-1500" T="12" H="3000" /><S P="1,,.3,.2,,,," L="3000" o="0" X="9500" c="4" Y="8000" T="12" H="3000" /></S><D><DS Y="4000" X="4000" /></D><O /></Z></C>')
- end,
- -- NewPlayer
- eventNewPlayer = function(n)
- system.bindKeyboard(n,string.byte("P"),true,true)
- system.bindKeyboard(n,46,true,true) -- Delete
- tfm.exec.chatMessage("<font color='#CF50DB'>[•] " .. system.getTranslation("welcome"),n)
- ui.banner("15db5b6ab36",210,120,n,10)
- if system.roomAdmins[n] then
- mode.universe.newCreator(n)
- end
- tfm.exec.addImage("15db9e67479.png","&1",5,30,n)
- if mode.universe.canInsertBackground then
- tfm.exec.respawnPlayer(n)
- mode.universe.setBackground(n)
- end
- end,
- -- Keyboard
- eventKeyboard = function(n,k)
- if k == string.byte("O") and system.roomAdmins[n] then
- if mode.universe.info[n].creatorOpen then
- mode.universe.eventTextAreaCallback(i,n,"main.exit")
- else
- mode.universe.uicreator(n)
- end
- return
- elseif k == string.byte("P") then
- local allowed = true
- if mode.universe.info[n] and mode.universe.info[n].creatorOpen then
- allowed = false
- end
- if allowed then
- mode.universe.profile.uiprofile(n)
- end
- return
- elseif k == 46 then
- tfm.exec.respawnPlayer(n)
- --tfm.exec.killPlayer(n)
- return
- end
- end,
- -- Callback
- eventTextAreaCallback = function(i,n,c)
- local p = string.split(c,"[^%.]+")
- -- Keyboard
- if p[1] == "keyboard" then
- if p[2] == "name" then
- if p[3] == "submit" then
- mode.universe.uicloseSplash(n)
- else
- if p[3] == "backspace" then
- table.remove(mode.universe.info[n].settings.name)
- elseif p[3] == "clear" then
- mode.universe.info[n].settings.name = {}
- elseif p[3] == "insert" then
- if #mode.universe.info[n].settings.name < 16 then
- mode.universe.info[n].settings.name[#mode.universe.info[n].settings.name + 1] = string.char(p[4])
- end
- end
- mode.universe.uikeyboard(p[2],mode.universe.info[n].settings.name,n)
- end
- end
- return
- end
- -- Counter
- if p[1] == "counter" then
- if table.find({"size","temperature","velocity","distance"},p[2]) then
- if p[3] == "submit" then
- mode.universe.uicloseSplash(n)
- else
- local increment = tonumber(string.format(p[4],"."))
- if p[3] == "add" then
- mode.universe.info[n].settings[p[2]][2] = mode.universe.info[n].settings[p[2]][2] + increment
- elseif p[3] == "sub" then
- mode.universe.info[n].settings[p[2]][2] = mode.universe.info[n].settings[p[2]][2] - increment
- end
- mode.universe.eventTextAreaCallback(i,n,"newObject." .. p[2])
- end
- end
- return
- end
- -- Palette
- if p[1] == "palette" then
- if p[2] == "exit" then
- for i = 11,19 do
- mode.universe.uiremove(i,n)
- end
- mode.universe.info[n].settings.palette[1] = 1
- mode.universe.uicreator(n)
- else
- if p[2] == "left" then
- mode.universe.info[n].settings.palette[1] = mode.universe.info[n].settings.palette[1] - 1
- elseif p[2] == "right" then
- mode.universe.info[n].settings.palette[1] = mode.universe.info[n].settings.palette[1] + 1
- end
- mode.universe.eventTextAreaCallback(i,n,"newObject.color")
- end
- return
- end
- -- New Object
- if p[1] == "newObject" then
- -- Class
- if p[2] == "class" then
- mode.universe.uiitems("<p align='center'><font size='20'><V><B>" .. string.upper(p[2]) .. "</B><font size='12'><p align='left'>\n\n<S>" .. table.concat(mode.universe.data.classes,"\n",function(k,v)
- local out = true
- if k == 1 then
- out = not mode.universe.star
- end
- if k == 2 then
- out = mode.universe.star
- end
- if k == 3 then
- if mode.universe.orbit[2] == 0 then
- out = false
- end
- end
- return out and string.format("%s<a href='event:item.class.%s'>%s</a>",mode.universe.tab,k,v) or string.format("%s<N2>%s</N2>",mode.universe.tab,v)
- end),n)
- return
- end
- -- Type
- if p[2] == "type" then
- if mode.universe.info[n].settings.class > 0 then
- mode.universe.uiitems("<p align='center'><font size='20'><V><B>" .. string.upper(p[2]) .. "</B><font size='12'><p align='left'>\n\n<S>" .. table.concat(mode.universe.data.objects[string.lower(mode.universe.translations.en.buttons.classes[mode.universe.info[n].settings.class])],"\n",function(k,v)
- local out = true
- if mode.universe.info[n].settings.class == 2 then
- local orbit = mode.universe.orbit[2] + 1
- if v[5] ~= 0 and not math.isNegative(v[5],orbit > math.abs(v[5]),orbit <= v[5]) then
- out = false
- end
- end
- return out and string.format("%s<a href='event:item.type.%s'>%s</a>",mode.universe.tab,k,v[1]) or string.format("%s<N2>%s</N2>",mode.universe.tab,v[1])
- end),n)
- end
- return
- end
- -- Name
- if p[2] == "name" then
- mode.universe.uikeyboard(p[2],mode.universe.info[n].settings.name,n)
- return
- end
- -- Size, Color, Temperature, Velocity, Distance, Moon, Respectively. [There must be a type]
- if mode.universe.info[n].settings.type > 0 then
- if p[2] == "size" then
- mode.universe.uicounter(p[2],mode.universe.data.objects[string.lower(mode.universe.translations.en.buttons.classes[mode.universe.info[n].settings.class])][mode.universe.info[n].settings.type][3],n)
- elseif p[2] == "color" then
- mode.universe.uipaletteMono(mode.universe.data.objects[string.lower(mode.universe.translations.en.buttons.classes[mode.universe.info[n].settings.class])][mode.universe.info[n].settings.type][2],n)
- elseif p[2] == "temperature" then
- mode.universe.uicounter(p[2],"-200:1000",n,100) -- Unknown, yet.
- elseif p[2] == "velocity" then
- mode.universe.uicounter(p[2],"-8:8",n,2,.1) -- Unknown, yet.
- elseif p[2] == "distance" then
- mode.universe.uicounter(p[2],"0:250",n,20) -- Unknown, yet.
- elseif p[2] == "moon" then
- mode.universe.uiitems("<p align='center'><font size='20'><V><B>" .. string.upper(system.getTranslation("menu.satellite")) .. "</B><font size='12'><p align='left'>\n\n<S>" .. table.concat(mode.universe.cosmos,"\n",function(k,v)
- return v.class == 2 and string.format("%s<a href='event:item.satellite.%s'>%s</a>",mode.universe.tab,k,v.name) or ""
- end),n)
- end
- return
- end
- return
- end
- -- Items
- if p[1] == "item" then
- -- Class
- if p[2] == "class" then
- mode.universe.info[n].settings.class = tonumber(p[3])
- mode.universe.info[n].settings.type = 0
- mode.universe.uiresetCreator(n)
- mode.universe.uiclearCreator(n)
- mode.universe.info[n].settings.create = mode.universe.info[n].settings.create + {mode.universe.data.menu.type,mode.universe.data.menu.name}
- mode.universe.uicloseSplash(n)
- return
- end
- -- Type
- if p[2] == "type" then
- mode.universe.info[n].settings.type = tonumber(p[3])
- mode.universe.uiresetCreator(n)
- mode.universe.uiclearCreator(n,3)
- mode.universe.info[n].settings.palette[2] = mode.universe.data.objects[string.lower(mode.universe.translations.en.buttons.classes[mode.universe.info[n].settings.class])][mode.universe.info[n].settings.type][2]
- local implement = setmetatable({
- mode.universe.data.menu.color,
- mode.universe.data.menu.size,
- mode.universe.data.menu.temperature
- },mode.universe.meta.add)
- if mode.universe.info[n].settings.class == 2 then
- implement = implement + {mode.universe.data.menu.velocity,mode.universe.data.menu.distance,mode.universe.data.menu.rings}
- end
- if mode.universe.info[n].settings.class == 3 then
- implement = implement + {mode.universe.data.menu.satellite}
- end
- mode.universe.info[n].settings.create = mode.universe.info[n].settings.create + implement
- mode.universe.uicloseSplash(n)
- return
- end
- -- Size, Temperature, Velocity, Distance
- if table.find({"size","temperature","velocity","distance"},p[2]) then
- if p[3] == "add" then
- mode.universe.info[n].settings[p[2]][1] = mode.universe.info[n].settings[p[2]][1] + mode.universe.info[n].settings[p[2]][2]
- elseif p[3] == "sub" then
- mode.universe.info[n].settings[p[2]][1] = mode.universe.info[n].settings[p[2]][1] - mode.universe.info[n].settings[p[2]][2]
- end
- mode.universe.eventTextAreaCallback(i,n,"newObject." .. p[2])
- return
- end
- -- Color
- if p[2] == "color" then
- mode.universe.info[n].settings.palette[3] = tonumber(p[3])
- mode.universe.eventTextAreaCallback(i,n,"palette.exit")
- return
- end
- -- Satellite
- if p[2] == "satellite" then
- mode.universe.info[n].settings.satellite = tonumber(p[3])
- mode.universe.uicloseSplash(n)
- return
- end
- return
- end
- -- Options
- if p[1] == "options" then
- if mode.universe.info[n].settings[p[2]][3] then
- mode.universe.info[n].settings[p[2]][3] = false
- mode.universe.eventTextAreaCallback(i,n,"newObject." .. p[2])
- else
- mode.universe.info[n].settings[p[2]][3] = true
- mode.universe.uicreator(n)
- end
- return
- end
- -- Alternate (Yes/No)
- if p[1] == "alternate" then
- if p[2] == "rings" then
- mode.universe.info[n].settings[p[2]] = not mode.universe.info[n].settings[p[2]]
- mode.universe.uicreator(n)
- end
- return
- end
- -- Close splash
- if p[1] == "closeSplash" then
- mode.universe.uicloseSplash(n)
- end
- -- Main
- if p[1] == "main" then
- -- Exit
- if p[2] == "exit" then
- mode.universe.uicloseSplash(n)
- for i = 0,9 do
- mode.universe.uiremove(i,n)
- end
- mode.universe.info[n].creatorOpen = false
- return
- end
- -- Reset
- if p[2] == "reset" then
- mode.universe.info[n].settings.class = 0
- mode.universe.info[n].settings.type = 0
- mode.universe.info[n].settings.name = {}
- mode.universe.uiresetCreator(n)
- mode.universe.uiclearCreator(n)
- if not p[3] then
- mode.universe.uicreator(n)
- end
- return
- end
- -- Create
- if p[2] == "create" then
- local fails = {}
- if mode.universe.info[n].settings.class <= 0 then
- fails[#fails + 1] = "class"
- end
- if #mode.universe.info[n].settings.name == 0 then
- fails[#fails + 1] = "name"
- end
- if mode.universe.info[n].settings.type <= 0 then
- fails[#fails + 1] = "type"
- end
- if mode.universe.info[n].settings.size[1] == -math.huge then
- fails[#fails + 1] = "size"
- end
- if mode.universe.info[n].settings.palette[3] == 1 then
- fails[#fails + 1] = "color"
- end
- if mode.universe.info[n].settings.class == 3 then
- if mode.universe.info[n].settings.satellite == 0 then
- fails[#fails + 1] = "satellite"
- end
- end
- local create = #fails == 0
- local concatenedName = table.concat(mode.universe.info[n].settings.name)
- if not create then
- tfm.exec.chatMessage("<R>" .. string.format(system.getTranslation("fail"),table.concat(fails,", ",function(k,v)
- return system.getTranslation("menu." .. v)
- end)),n)
- end
- if mode.universe.stuff[concatenedName] then
- create = false
- tfm.exec.chatMessage("<R>" .. string.format(system.getTranslation("nameExist"),concatenedName),n)
- end
- if create and (os.time() > mode.universe.info[n].action) then
- mode.universe.info[n].action = os.time() + 2500
- local this = mode.universe.object:new({
- name = concatenedName,
- class = mode.universe.info[n].settings.class,
- type = mode.universe.info[n].settings.type,
- size = mode.universe.info[n].settings.size[1],
- color = mode.universe.info[n].settings.palette[3],
- velocity = mode.universe.info[n].settings.velocity[3] and "auto" or mode.universe.info[n].settings.velocity[1],
- temperature = mode.universe.info[n].settings.temperature[3] and "auto" or mode.universe.info[n].settings.temperature[1],
- rings = mode.universe.info[n].settings.rings and {inclination = 6.5} or false,
- distance = mode.universe.info[n].settings.distance[3] and "auto" or mode.universe.info[n].settings.distance[1],
- satelliteOf = mode.universe.info[n].settings.satellite,
- })
- if this.class == 3 then
- mode.universe.object.destroy(mode.universe.cosmos[this.satelliteOf])
- mode.universe.object.create(mode.universe.cosmos[this.satelliteOf])
- else
- this:create()
- end
- local type = mode.universe.data.objects[string.lower(mode.universe.translations.en.buttons.classes[this.class])][this.type][1]
- tfm.exec.chatMessage("<S>" .. string.format(system.getTranslation("newObject." .. this.class),type,(this.satelliteOf and mode.universe.cosmos[this.satelliteOf].name or "")) .. "\n\t" .. string.format(system.getTranslation("checkProfile"),this.name))
- mode.universe.eventTextAreaCallback(i,n,"main.reset.not")
- mode.universe.eventTextAreaCallback(i,n,"main.exit")
- end
- return
- end
- -- Destroy
- if p[2] == "destroy" then
- if p[3] then
- p[3] = tonumber(p[3])
- ui.addPopup(p[3],1,"<p align='center'><font color='#2ECF73'>" .. string.format(system.getTranslation("destroyConfirm"),mode.universe.cosmos[p[3]].className,mode.universe.cosmos[p[3]].name),n,200,150,400,true)
- else
- mode.universe.uiitems("<p align='center'><font size='20'><V><B>" .. string.upper(system.getTranslation("buttons.main.destroy")) .. "</B><font size='12'>\n<a href='event:closeSplash'>" .. system.getTranslation("exit") .. "</a><p align='left'>\n\n<S>" .. table.concat(mode.universe.cosmos,"",function(k,v)
- return v.display and string.format("%s%s <a href='event:main.destroy.%s'>%s</a>\n",mode.universe.tab,(v.id == mode.universe.cosmos[1].id and "<a:active>★</a:active>" or "<CE>[" .. v.className .."]</CE>"),k,v.name) or ""
- end),n,200)
- end
- return
- end
- -- Recreate
- if p[2] == "recreate" then
- if p[3] then
- p[3] = tonumber(p[3])
- if mode.universe.cosmos[p[3]].id == mode.universe.cosmos[1].id then
- for i = 1,mode.universe.orbit[4] do
- if mode.universe.cosmos[p[3]].class < 3 then
- mode.universe.cosmos[i]:create()
- end
- end
- tfm.exec.chatMessage("<R>" .. system.getTranslation("systemRecreated"),n)
- else
- if mode.universe.cosmos[p[3]].class == 3 then
- if mode.universe.cosmos[mode.universe.cosmos[p[3]].satelliteOf].display then
- mode.universe.cosmos[mode.universe.cosmos[p[3]].satelliteOf]:destroy()
- else
- tfm.exec.chatMessage("<R>" .. system.getTranslation("planetRecreated"),n)
- end
- mode.universe.cosmos[mode.universe.cosmos[p[3]].satelliteOf]:create()
- else
- mode.universe.cosmos[p[3]]:create()
- if mode.universe.cosmos[p[3]].class == 2 then
- if #mode.universe.cosmos[p[3]].moons > 0 then
- tfm.exec.chatMessage("<R>" .. system.getTranslation("moonRecreated"),n)
- end
- end
- end
- end
- mode.universe.uicloseSplash(n,true)
- else
- mode.universe.uiitems("<p align='center'><font size='20'><V><B>" .. string.upper(system.getTranslation("buttons.main.recreate")) .. "</B><font size='12'>\n<a href='event:closeSplash'>" .. system.getTranslation("exit") .. "</a><p align='left'>\n\n<S>" .. table.concat(mode.universe.cosmos,"",function(k,v)
- return v.display and "" or string.format("%s%s <a href='event:main.recreate.%s'>%s</a>\n",mode.universe.tab,(v.id == mode.universe.cosmos[1].id and "<a:active>★</a:active>" or "<CE>[" .. v.className .."]</CE>"),k,v.name)
- end),n,200)
- end
- return
- end
- return
- end
- -- Profile
- if p[1] == "profile" then
- local allowed = true
- if mode.universe.info[n] and mode.universe.info[n].creatorOpen then
- allowed = false
- end
- if allowed then
- -- Open, Exit, Respectively.
- if p[2] == "open" then
- mode.universe.profile.uiremoveprofile(n)
- mode.universe.profile["profile" .. p[3]](p[4],n)
- elseif p[2] == "exit" then
- mode.universe.uicloseSplash(n,true)
- mode.universe.profile.uiremoveprofile(n)
- end
- end
- return
- end
- end,
- -- Chat Commands
- eventChatCommand = function(n,c)
- local p = string.split(c,"[^%s]+")
- if p[1] == "profile" then
- if p[2] then
- p[2] = string.lower(p[2])
- for k,v in next,mode.universe.cosmos do
- if string.lower(v.name) == p[2] then
- mode.universe.eventTextAreaCallback(nil,n,"profile.open." .. v.className .. "." .. k)
- break
- end
- end
- else
- mode.universe.eventKeyboard(n,string.byte("P"))
- end
- return
- end
- if system.roomAdmins[n] then
- if p[1] == "name" then
- if p[2] then
- mode.universe.eventPopupAnswer(0,n,table.concat(p," ",nil,2))
- else
- ui.addPopup(0,2,"<p align='center'><font color='#CF50DB'>" .. system.getTranslation("sysName.choose"),n,200,150,400,true)
- end
- return
- end
- end
- end,
- -- Popup Answer
- eventPopupAnswer = function(i,n,a)
- if i == 0 then
- if a ~= "" then
- mode.universe.systemName = string.sub(a,1,20)
- tfm.exec.chatMessage("<font color='#CF50DB'>" .. string.format(system.getTranslation("sysName.new"),mode.universe.systemName))
- end
- else
- if a == "yes" then
- local destroyable,moonMessage = true,false
- if mode.universe.cosmos[i].id == mode.universe.cosmos[1].id then
- for id = 2,mode.universe.orbit[4] do
- --[[if mode.universe.cosmos[id].class < 3 then
- mode.universe.cosmos[id]:destroy()
- end]]
- if mode.universe.cosmos[id].display then
- destroyable = false
- break
- end
- end
- else
- if mode.universe.cosmos[i].class == 2 then
- if #mode.universe.cosmos[i].moons > 0 then
- moonMessage = true
- end
- end
- end
- if destroyable then
- mode.universe.cosmos[i]:destroy()
- if moonMessage then
- tfm.exec.chatMessage("<R>" .. system.getTranslation("moonDestroyed"),n)
- end
- else
- tfm.exec.chatMessage("<R>" .. system.getTranslation("cantDestroy"),n)
- end
- end
- mode.universe.uicloseSplash(n,true)
- end
- end,
- -- New Game
- eventNewGame = function()
- mode.universe.canInsertBackground = true
- mode.universe.setBackground()
- -- Solar System
- if system.roomNumber == 801 or not string.find(tfm.get.room.name,"@") then
- local system = {
- [1] = {
- name = "Sun",
- class = 1,
- className = "Star",
- type = 1,
- typeName = "Yellow Dwarf",
- size = 90,
- color = 0xF8B55F,
- temperature = 5500,
- },
- [2] = {
- name = "Mercury",
- class = 2,
- className = "Planet",
- type = 5,
- typeName = "Iron",
- size = 18,
- color = 0x929292,
- velocity = 4,
- temperature = 200,
- rings = false,
- distance = 1,
- },
- [3] = {
- name = "Venus",
- class = 2,
- className = "Planet",
- type = 5,
- typeName = "Telluric",
- size = 32,
- color = 0xCFB181,
- velocity = -.5,
- temperature = 450,
- rings = false,
- distance = 20,
- },
- [4] = {
- name = "Earth",
- class = 2,
- className = "Planet",
- type = 5,
- typeName = "Telluric",
- size = 35,
- color = 0x3E7B9D,
- velocity = 1,
- temperature = 20,
- rings = false,
- distance = 70,
- },
- [5] = {
- name = "Moon",
- class = 3,
- className = "Moon",
- type = 1,
- typeName = "Asteroid",
- size = 6.5,
- color = 0x848484,
- temperature = -30,
- satelliteOf = 4
- },
- [6] = {
- name = "Mars",
- class = 2,
- className = "Planet",
- type = 6,
- typeName = "Sillicate",
- size = 24,
- color = 0xEF6B3E,
- velocity = .6,
- temperature = -17,
- rings = false,
- distance = 120,
- },
- [7] = {
- name = "Phobos",
- class = 3,
- className = "Moon",
- type = 2,
- typeName = "Irregular Asteroid",
- size = 3.3,
- color = 0x73572B,
- temperature = -58,
- satelliteOf = 6
- },
- [8] = {
- name = "Deimos",
- class = 3,
- className = "Moon",
- type = 2,
- typeName = "Irregular Asteroid",
- size = 2.2,
- color = 0xB9B9B9,
- temperature = -40,
- satelliteOf = 6
- },
- [9] = {
- name = "Jupiter",
- class = 2,
- className = "Planet",
- type = 3,
- typeName = "Gas Giant",
- size = 55,
- color = 0xE39492,
- velocity = .4,
- temperature = -170,
- rings = {
- inclination = .6,
- },
- distance = 185,
- },
- [10] = {
- name = "Io",
- class = 3,
- className = "Moon",
- type = 1,
- typeName = "Asteroid",
- size = 5.5,
- color = 0xE7D587,
- temperature = -100,
- satelliteOf = 9
- },
- [11] = {
- name = "Europa",
- class = 3,
- className = "Moon",
- type = 1,
- typeName = "Asteroid",
- size = 4.5,
- color = 0xB4BCBE,
- temperature = -180,
- satelliteOf = 9
- },
- [12] = {
- name = "Ganymede",
- class = 3,
- className = "Moon",
- type = 1,
- typeName = "Asteroid",
- size = 10,
- color = 0x907E6D,
- temperature = -150,
- satelliteOf = 9
- },
- [13] = {
- name = "Callisto",
- class = 3,
- className = "Moon",
- type = 1,
- typeName = "Asteroid",
- size = 8,
- color = 0xB9A89F,
- temperature = -180,
- satelliteOf = 9
- },
- [14] = {
- name = "Saturn",
- class = 2,
- className = "Planet",
- type = 3,
- typeName = "Gas Giant",
- size = 50,
- color = 0xCAAB7B,
- velocity = .3,
- temperature = -170,
- rings = {
- inclination = .3,
- volume = 7
- },
- distance = 280,
- },
- [15] = {
- name = "Titan",
- class = 3,
- className = "Moon",
- type = 1,
- typeName = "Asteroid",
- size = 9,
- color = 0xCF892A,
- temperature = -180,
- satelliteOf = 14
- },
- [16] = {
- name = "Enceladus",
- class = 3,
- className = "Moon",
- type = 1,
- typeName = "Asteroid",
- size = 6.5,
- color = 0xAEBBC3,
- temperature = -200,
- satelliteOf = 14
- },
- [17] = {
- name = "Uranus",
- class = 2,
- className = "Planet",
- type = 4,
- typeName = "Ice Giant",
- size = 36,
- color = 0x57D2C9,
- velocity = .2,
- temperature = -216,
- rings = {
- inclination = 2,
- volume = 1
- },
- distance = 360,
- },
- [18] = {
- name = "Neptune",
- class = 2,
- className = "Planet",
- type = 4,
- typeName = "Ice Giant",
- size = 30,
- color = 0x183241,
- velocity = .17,
- temperature = -210,
- rings = false,
- distance = 430,
- },
- [19] = {
- name = "Pluto",
- class = 2,
- className = "Planet",
- type = 8,
- typeName = "Dwarf",
- size = 6,
- color = 0x40181C,
- velocity = .08,
- temperature = -230,
- rings = false,
- distance = 500,
- },
- [20] = {
- name = "Charon",
- class = 3,
- className = "Moon",
- type = 1,
- typeName = "Asteroid",
- size = 3.8,
- color = 0xA7A7A7,
- temperature = -220,
- satelliteOf = 19
- },
- }
- for i = 1,#system do
- mode.universe.object:new(system[i])
- end
- for i = 1,#mode.universe.cosmos do
- if mode.universe.cosmos[i].class ~= 3 then
- mode.universe.cosmos[i]:create()
- end
- end
- end
- end,
- -- Loop
- eventLoop = function()
- if _G.currentTime % 5 == 0 then
- for k,v in next,system.players(true) do
- tfm.exec.killPlayer(v)
- end
- end
- if _G.currentTime % 80 == 0 then
- if mode.universe.ufoId > -1 then
- tfm.exec.removeImage(mode.universe.ufoId)
- end
- mode.universe.ufoId = tfm.exec.addImage(table.random(mode.universe.images.ufos) .. ".png","!65",math.random(200,7800),math.random(200,7800))
- end
- end
- }
- --[[ ModeChanged ]]--
- system.objects = {
- image = {},
- textarea = {}
- }
- eventModeChanged = function()
- -- Remove content
- for k in next,system.objects.image do
- tfm.exec.removeImage(k)
- end
- for k in next,system.objects.textarea do
- ui.removeTextArea(k,nil)
- end
- system.objects = {
- image = {},
- textarea = {}
- }
- ui.addPopup(0,0,"",nil,-1500,-1500)
- -- Unbind keyboard and mouse, also normalize color name and scores
- for k in next,tfm.get.room.playerList do
- for i = 0,255 do
- for v = 0,1 do
- system.bindKeyboard(k,i,v == 0,false)
- end
- end
- system.bindMouse(k,false)
- tfm.exec.setNameColor(k,-1)
- tfm.exec.setPlayerScore(k,0)
- end
- -- Set admin back
- system.roomAdmins = system.setAdmins()
- -- Reset settings
- for k,v in next,{"AutoScore","WatchCommand","AutoNewGame","AutoShaman","AllShamanSkills","MortCommand","DebugCommand","MinimalistMode","AfkDeath","PhysicalConsumables","AutoTimeLeft"} do
- tfm.exec["disable" .. v](false)
- end
- tfm.exec.setAutoMapFlipMode()
- tfm.exec.setRoomMaxPlayers(25)
- tfm.exec.setRoomPassword("")
- end
- --[[ Events ]]--
- events = {}
- events.eventLoop = function(currentTime,leftTime)
- _G.currentTime = normalizeTime(currentTime / 1e3)
- _G.leftTime = normalizeTime(leftTime / 1e3)
- end
- events.eventChatCommand = function(n,c)
- disableChatCommand(c)
- if module._FREEACCESS[n] then
- if c == "refresh" and (not system.isRoom or module._FREEACCESS[n] > 1) then
- eventModeChanged()
- system.init(true)
- elseif stringsub(c,1,4) == "room" and (not system.isRoom or module._FREEACCESS[n] > 1) then
- system.roomNumber = tonumber(stringsub(c,6)) or 0
- if _G["eventChatCommand"] then
- eventChatCommand(n,"refresh")
- end
- elseif stringsub(c,1,4) == "load" and (not system.isRoom or module._FREEACCESS[n] > 2) then
- if os.time() > system.modeChanged and os.time() > system.newGameTimer then
- local newMode = system.getGameMode(stringsub(c,6),true)
- if newMode then
- system.init(system.isRoom)
- end
- end
- end
- end
- if stringsub(c,1,6) == "module" then
- c = stringupper(stringsub(c,8))
- if module["_" .. c] then
- tfm.exec.chatMessage(c .. " : " .. tableconcat(tableturnTable(module["_" .. c]),"\n",function(k,v)
- return (c == "FREEACCESS" and stringformat("%s(%s)",k,v) or v)
- end),n)
- else
- tfm.exec.chatMessage(stringformat("VERSION : %s\nNAME : %s\nSTATUS : %s\nAUTHOR : %s\n\nMODE : %s",module._VERSION,module._NAME,module._STATUS,module._AUTHOR,system.gameMode),n)
- end
- elseif c == "modes" then
- tfm.exec.chatMessage(tableconcat(system.submodes,"\n",function(k,v)
- return "#" .. v
- end),n)
- elseif c == "admin" then
- tfm.exec.chatMessage(tableconcat(system.roomAdmins,", ",tostring),n)
- elseif c == "stop" and system.roomAdmins[n] then
- system.exit()
- elseif stringsub(c,1,3) == "adm" and (system.roomAdmins[n] or module._FREEACCESS[n] > 2) then
- system.roomAdmins[stringnick(stringsub(c,5))] = true
- end
- end
- events.eventNewPlayer = function(n)
- tfm.exec.lowerSyncDelay(n)
- if system.officialMode[2] ~= "" then
- tfm.exec.chatMessage(system.officialMode[2],n)
- end
- end
- --[[ RoomSettings ]]--
- system.roomSettings = {
- ["@"] = function(n)
- system.roomAdmins[stringnick(n)] = true
- end,
- ["#"] = function(id)
- system.miscAttrib = tonumber(id) or 1
- system.miscAttrib = mathsetLim(system.miscAttrib,1,99) -- mathmax(1,mathmin(system.miscAttrib,99))
- end,
- ["*"] = function(name)
- local game = system.getGameMode(name)
- if not game then
- system.gameMode = module._NAME
- end
- end
- }
- system.setRoom = function()
- if system.isRoom and system.roomAttributes then
- local chars = ""
- for k in next,system.roomSettings do
- chars = chars .. k
- end
- for char,value in stringgmatch(system.roomAttributes,"(["..chars.."])([^"..chars.."]+)") do
- value = stringmatch(value,"[^%s]+")
- for k,v in next,system.roomSettings do
- if k == char then
- v(value)
- break
- end
- end
- end
- local officialModes = {
- {"vanilla","<VP>Enjoy your vanilla (: .. okno"},
- {"survivor","<R>Aw, you cannot play survivor on #grounds"},
- {"racing","<CH>Uh, racing? Good luck!"},
- {"music","<BV>Music? Nice choice! Why don't you try a rock'n'roll?"},
- {"bootcamp","<PT>Bootcamp? Ok. This is unfair and your data won't be saved out of the room."},
- {"defilante","<R>Aw, you cannot play defilante on #grounds"},
- {"village","<R>You cannot play village on #grounds. Please, change your room."},
- }
- for k,v in next,officialModes do
- if stringfind(system.roomAttributes,v[1] .. "$") then
- system.officialMode = {v[1],v[2]}
- break
- end
- end
- end
- end
- --[[ Initialize ]]--
- execute = {}
- system.setRoom()
- system.init = function(refresh)
- normalizeTranslation()
- mode[system.gameMode].init()
- for i,event in next,{"Loop","NewGame","PlayerDied","PlayerGetCheese","PlayerVampire","PlayerWon","PlayerLeft","EmotePlayed","Keyboard","Mouse","PopupAnswer","TextAreaCallback","ChatCommand","ChatMessage","SummoningStart","SummoningEnd","SummoningCancel","NewPlayer","PlayerRespawn","ColorPicked"} do
- local e = "event" .. event
- local found = false
- for k,v in next,mode[system.gameMode] do
- if k == e then
- execute[e] = v
- found = true
- break
- end
- end
- if not found then
- execute[e] = function() end
- end
- _G[e] = function(...)
- if events[e] then
- events[e](...)
- end
- execute[e](...)
- end
- end
- if refresh then
- if mode[system.gameMode].reset then
- mode[system.gameMode].reset()
- end
- end
- if _G["eventNewPlayer"] then
- tableforeach(tfm.get.room.playerList,eventNewPlayer)
- end
- end
- system.init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement