Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local t={}local n={}local o=require
- local function a(e,...)if n[e]then
- return n[e].value
- end
- if t[e]then
- local t=t[e]n[e]={value=(select("#",...)>0)and t(...)or t(e)}return n[e].value
- else
- if o then
- return o(e)else
- error("module '"..e.."' not found")end
- end
- end
- t={["lualib_bundle"]=function(...)local function y(e)return type(e)=="table"and(e[1]~=nil or next(e)==nil)end
- local function be(o,...)local n={...}local t={}local e=0
- for n=1,#o do
- e=e+1
- t[e]=o[n]end
- for o=1,#n do
- local n=n[o]if y(n)then
- for o=1,#n do
- e=e+1
- t[e]=n[o]end
- else
- e=e+1
- t[e]=n
- end
- end
- return t
- end
- local u,n
- do
- local e={__tostring=function(e)return("Symbol("..(e.description or""))..")"end}function u(t)return setmetatable({description=t},e)end
- n={iterator=u("Symbol.iterator"),hasInstance=u("Symbol.hasInstance"),species=u("Symbol.species"),toStringTag=u("Symbol.toStringTag")}end
- local function ye(t)local e=0
- return{[n.iterator]=function(e)return e
- end,next=function(n)local n={done=t[e+1]==nil,value={e,t[e+1]}}e=e+1
- return n
- end}end
- local function me(e,t,o)for n=1,#e do
- if not t(o,e[n],n-1,e)then
- return false
- end
- end
- return true
- end
- local function ge(e,r,l)local o={}local n=0
- for t=1,#e do
- if r(l,e[t],t-1,e)then
- n=n+1
- o[n]=e[t]end
- end
- return o
- end
- local function pe(e,t,o)for n=1,#e do
- t(o,e[n],n-1,e)end
- end
- local function _e(e,l,o)for n=1,#e do
- local t=e[n]if l(o,t,n-1,e)then
- return t
- end
- end
- return nil
- end
- local function Be(n,o,t)for e=1,#n do
- if o(t,n[e],e-1,n)then
- return e-1
- end
- end
- return-1
- end
- local r
- do
- local function o(e)local n=e.____coroutine
- local t,e=coroutine.resume(n)if not t then
- error(e,0)end
- if coroutine.status(n)=="dead"then
- return
- end
- return true,e
- end
- local function t(e)local e=e:next()if e.done then
- return
- end
- return true,e.value
- end
- local function l(n,e)e=e+1
- if e>#n then
- return
- end
- return e,string.sub(n,e,e)end
- function r(e)if type(e)=="string"then
- return l,e,0
- elseif e.____coroutine~=nil then
- return o,e
- elseif e[n.iterator]then
- local e=e[n.iterator](e)return t,e
- else
- return ipairs(e)end
- end
- end
- local j
- do
- local function t(n,e)e=e+1
- if e>n.length then
- return
- end
- return e,n[e]end
- local function n(e)if type(e.length)=="number"then
- return t,e,0
- end
- return r(e)end
- function j(t,o,l)local e={}if o==nil then
- for t,n in n(t)do
- e[#e+1]=n
- end
- else
- for n,t in n(t)do
- e[#e+1]=o(l,t,n-1)end
- end
- return e
- end
- end
- local function Fe(o,l,e)if e==nil then
- e=0
- end
- local t=#o
- local n=e
- if e<0 then
- n=t+e
- end
- if n<0 then
- n=0
- end
- for e=n+1,t do
- if o[e]==l then
- return true
- end
- end
- return false
- end
- local function ze(t,o,e)if e==nil then
- e=0
- end
- local n=#t
- if n==0 then
- return-1
- end
- if e>=n then
- return-1
- end
- if e<0 then
- e=n+e
- if e<0 then
- e=0
- end
- end
- for e=e+1,n do
- if t[e]==o then
- return e-1
- end
- end
- return-1
- end
- local function xe(t,e)if e==nil then
- e=","end
- local n={}for e=1,#t do
- n[e]=tostring(t[e])end
- return table.concat(n,e)end
- local function we(e,o,l)local t={}for n=1,#e do
- t[n]=o(l,e[n],n-1,e)end
- return t
- end
- local function ve(n,...)local t={...}local e=#n
- for o=1,#t do
- e=e+1
- n[e]=t[o]end
- return e
- end
- local function Te(n,t)local e=#n
- for o=1,#t do
- e=e+1
- n[e]=t[o]end
- return e
- end
- local function s(...)return select("#",...)end
- local function Se(n,l,...)local t=#n
- local o=0
- local e=nil
- if s(...)~=0 then
- e=...elseif t>0 then
- e=n[1]o=1
- else
- error("Reduce of empty array with no initial value",0)end
- for t=o+1,t do
- e=l(nil,e,n[t],t-1,n)end
- return e
- end
- local function ke(n,l,...)local o=#n
- local t=o-1
- local e=nil
- if s(...)~=0 then
- e=...elseif o>0 then
- e=n[t+1]t=t-1
- else
- error("Reduce of empty array with no initial value",0)end
- for t=t+1,1,-1 do
- e=l(nil,e,n[t],t-1,n)end
- return e
- end
- local function Ce(e)local n=1
- local t=#e
- while n<t do
- local o=e[t]e[t]=e[n]e[n]=o
- n=n+1
- t=t-1
- end
- return e
- end
- local function I(e,...)local t={...}local n=#t
- if n==0 then
- return#e
- end
- for t=#e,1,-1 do
- e[t+n]=e[t]end
- for n=1,n do
- e[n]=t[n]end
- return#e
- end
- local function se(e,n)if n~=nil then
- table.sort(e,function(t,e)return n(nil,t,e)<0 end)else
- table.sort(e)end
- return e
- end
- local function ue(l,e,n)local t=#l
- e=e or 0
- if e<0 then
- e=t+e
- if e<0 then
- e=0
- end
- else
- if e>t then
- e=t
- end
- end
- n=n or t
- if n<0 then
- n=t+n
- if n<0 then
- n=0
- end
- else
- if n>t then
- n=t
- end
- end
- local o={}e=e+1
- n=n+1
- local t=1
- while e<n do
- o[t]=l[e]e=e+1
- t=t+1
- end
- return o
- end
- local function fe(e,o,t)for n=1,#e do
- if o(t,e[n],n-1,e)then
- return true
- end
- end
- return false
- end
- local function ie(n,...)local a={...}local o=#n
- local r=s(...)local t=a[1]local i=a[2]if t<0 then
- t=o+t
- if t<0 then
- t=0
- end
- elseif t>o then
- t=o
- end
- local l=r-2
- if l<0 then
- l=0
- end
- local e
- if r==0 then
- e=0
- elseif r==1 then
- e=o-t
- else
- e=i or 0
- if e<0 then
- e=0
- end
- if e>o-t then
- e=o-t
- end
- end
- local i={}for e=1,e do
- local t=t+e
- if n[t]~=nil then
- i[e]=n[t]end
- end
- if l<e then
- for t=t+1,o-e do
- local e=t+e
- local t=t+l
- if n[e]then
- n[t]=n[e]else
- n[t]=nil
- end
- end
- for e=o-e+l+1,o do
- n[e]=nil
- end
- elseif l>e then
- for t=o-e,t+1,-1 do
- local e=t+e
- local t=t+l
- if n[e]then
- n[t]=n[e]else
- n[t]=nil
- end
- end
- end
- local t=t+1
- for e=3,r do
- n[t]=a[e]t=t+1
- end
- for e=#n,o-e+l+1,-1 do
- n[e]=nil
- end
- return i
- end
- local function ce(t)local n={}for e=1,#t do
- n[e-1]=t[e]end
- return n
- end
- local function X(t,n)if n==nil then
- n=1
- end
- local l={}local e=0
- for o=1,#t do
- local t=t[o]if n>0 and y(t)then
- local o
- if n==1 then
- o=t
- else
- o=X(t,n-1)end
- for n=1,#o do
- local n=o[n]e=e+1
- l[e]=n
- end
- else
- e=e+1
- l[e]=t
- end
- end
- return l
- end
- local function de(n,r,l)local t={}local e=0
- for o=1,#n do
- local n=r(l,n[o],o-1,n)if y(n)then
- for o=1,#n do
- e=e+1
- t[e]=n[o]end
- else
- e=e+1
- t[e]=n
- end
- end
- return t
- end
- local function he(n,e)if e<0 or e~=e or e==math.huge or math.floor(e)~=e then
- error("invalid array length: "..tostring(e),0)end
- for e=e+1,#n do
- n[e]=nil
- end
- return e
- end
- local function c(t,e)if type(e)~="table"then
- error("Right-hand side of 'instanceof' is not an object",0)end
- if e[n.hasInstance]~=nil then
- return not not e[n.hasInstance](e,t)end
- if type(t)=="table"then
- local n=t.constructor
- while n~=nil do
- if n==e then
- return true
- end
- n=n.____super
- end
- end
- return false
- end
- local function l(e,...)local e=setmetatable({},e.prototype)e:____constructor(...)return e
- end
- local function d(e)local e={prototype={}}e.prototype.__index=e.prototype
- e.prototype.constructor=e
- return e
- end
- local h=table.unpack or unpack
- local function v(t,...)local n={...}return function(e,...)local e={...}I(e,h(n))return t(h(e))end
- end
- local e
- do
- local function a(n)local n
- local t
- local e=l(e,function(l,o,e)n=o
- t=e
- end)return{promise=e,resolve=n,reject=t}end
- local function s(t,n)return c(n,e)end
- e=d()e.name="__TS__Promise"function e.prototype.____constructor(e,t)e.state=0
- e.fulfilledCallbacks={}e.rejectedCallbacks={}e.finallyCallbacks={}do
- local function o(n)e:reject(n)end
- local e,n=pcall(function()t(nil,v(e.resolve,e),v(e.reject,e))end)if not e then
- o(n)end
- end
- end
- function e.resolve(n)local e=l(e,function()end)e.state=1
- e.value=n
- return e
- end
- function e.reject(t)local n=l(e,function()end)n.state=2
- n.rejectionReason=t
- return n
- end
- e.prototype["then"]=function(e,l,r)local t=a(nil)local i=t.promise
- local n=t.resolve
- local t=t.reject
- local o=e.state==1
- local a=e.state==2
- if l then
- local n=e:createPromiseResolvingCallback(l,n,t)local t=e.fulfilledCallbacks
- t[#t+1]=n
- if o then
- n(nil,e.value)end
- else
- local e=e.fulfilledCallbacks
- e[#e+1]=function(t,e)return n(nil,e)end
- end
- if r then
- local t=e:createPromiseResolvingCallback(r,n,t)local n=e.rejectedCallbacks
- n[#n+1]=t
- if a then
- t(nil,e.rejectionReason)end
- else
- local e=e.rejectedCallbacks
- e[#e+1]=function(n,e)return t(nil,e)end
- end
- if o then
- n(nil,e.value)end
- if a then
- t(nil,e.rejectionReason)end
- return i
- end
- function e.prototype.catch(e,n)return e["then"](e,nil,n)end
- function e.prototype.finally(e,n)if n then
- local t=e.finallyCallbacks
- t[#t+1]=n
- if e.state~=0 then
- n(nil)end
- end
- return e
- end
- function e.prototype.resolve(n,t)if c(t,e)then
- t["then"](t,function(t,e)return n:resolve(e)end,function(t,e)return n:reject(e)end)return
- end
- if n.state==0 then
- n.state=1
- n.value=t
- for n,e in ipairs(n.fulfilledCallbacks)do
- e(nil,t)end
- for n,e in ipairs(n.finallyCallbacks)do
- e(nil)end
- end
- end
- function e.prototype.reject(e,n)if e.state==0 then
- e.state=2
- e.rejectionReason=n
- for t,e in ipairs(e.rejectedCallbacks)do
- e(nil,n)end
- for n,e in ipairs(e.finallyCallbacks)do
- e(nil)end
- end
- end
- function e.prototype.createPromiseResolvingCallback(n,r,l,e)return function(t,o)do
- local function t(n)e(nil,n)end
- local n,e=pcall(function()n:handleCallbackData(r(nil,o),l,e)end)if not n then
- t(e)end
- end
- end
- end
- function e.prototype.handleCallbackData(n,e,t,o)if s(nil,e)then
- local n=e
- if n.state==1 then
- t(nil,n.value)elseif n.state==2 then
- o(nil,n.rejectionReason)else
- e["then"](e,t,o)end
- else
- t(nil,e)end
- end
- end
- local function Ze(d)return l(e,function(t,a,n)local r,i,o,l,t
- function r(t,n)return c(n,e)and n or e.resolve(n)end
- function i(l,e)local t,e=coroutine.resume(t,e)if t then
- o(nil,e)else
- n(nil,e)end
- end
- function o(o,e)if l then
- return
- end
- if coroutine.status(t)=="dead"then
- a(nil,e)else
- local e=r(nil,e)e["then"](e,i,n)end
- end
- l=false
- t=coroutine.create(d)local t,e=coroutine.resume(t,function(t,e)l=true
- local e=r(nil,e)e["then"](e,a,n)end)if t then
- o(nil,e)else
- n(nil,e)end
- end)end
- local function Ne(e)return coroutine.yield(e)end
- local function z(n,e)n.____super=e
- local o=setmetatable({__index=e},e)setmetatable(n,o)local t=getmetatable(e)if t then
- if type(t.__index)=="function"then
- o.__index=t.__index
- end
- if type(t.__newindex)=="function"then
- o.__newindex=t.__newindex
- end
- end
- setmetatable(n.prototype,e.prototype)if type(e.prototype.__index)=="function"then
- n.prototype.__index=e.prototype.__index
- end
- if type(e.prototype.__newindex)=="function"then
- n.prototype.__newindex=e.prototype.__newindex
- end
- if type(e.prototype.__tostring)=="function"then
- n.prototype.__tostring=e.prototype.__tostring
- end
- end
- local function F(e)local o
- local l
- local n
- local t
- local r
- local a
- a=e.enumerable
- r=e.configurable
- t=e.get
- n=e.set
- l=e.writable
- o=e.value
- local e={enumerable=a==true,configurable=r==true}local a=t~=nil or n~=nil
- local r=l~=nil or o~=nil
- if a and r then
- error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.",0)end
- if t or n then
- e.get=t
- e.set=n
- else
- e.value=o
- e.writable=l==true
- end
- return e
- end
- local function E(n,...)local e={...}for t=1,#e do
- local e=e[t]for t in pairs(e)do
- n[t]=e[t]end
- end
- return n
- end
- local function D(e,n)local e=getmetatable(e)if not e then
- return
- end
- if not rawget(e,"_descriptors")then
- return
- end
- return rawget(e,"_descriptors")[n]end
- local b
- do
- local function a(n,t)local e=rawget(n,t)if e~=nil then
- return e
- end
- local e=getmetatable(n)while e do
- local o=rawget(e,t)if o~=nil then
- return o
- end
- local o=rawget(e,"_descriptors")if o then
- local e=o[t]if e~=nil then
- if e.get then
- return e.get(n)end
- return e.value
- end
- end
- e=getmetatable(e)end
- end
- local function r(n,l,o)local t=getmetatable(n)while t do
- local e=rawget(t,"_descriptors")if e then
- local e=e[l]if e~=nil then
- if e.set then
- e.set(n,o)else
- if e.writable==false then
- error(((("Cannot assign to read only property '"..l).."' of object '")..tostring(n)).."'",0)end
- e.value=o
- end
- return
- end
- end
- t=getmetatable(t)end
- rawset(n,l,o)end
- function b(n,t,l,e)if e==nil then
- e=false
- end
- local o
- if e then
- o=n
- else
- o=getmetatable(n)end
- local e=o
- if not e then
- e={}setmetatable(n,e)end
- local o=rawget(n,t)if o~=nil then
- rawset(n,t,nil)end
- if not rawget(e,"_descriptors")then
- e._descriptors={}end
- e._descriptors[t]=F(l)e.__index=a
- e.__newindex=r
- end
- end
- local function Ue(o,e,n,r)local t=e
- do
- local l=#o
- while l>=0 do
- local o=o[l+1]if o~=nil then
- local a=t
- if n==nil then
- t=o(nil,t)elseif r==true then
- local t=rawget(e,n)local l=D(e,n)or({configurable=true,writable=true,value=t})local t=o(nil,e,n,l)or l
- local o=t.configurable==true and t.writable==true and not t.get and not t.set
- if o then
- rawset(e,n,t.value)else
- b(e,n,E({},l,t))end
- elseif r==false then
- t=o(nil,e,n,r)else
- t=o(nil,e,n)end
- t=t or a
- end
- l=l-1
- end
- end
- return t
- end
- local function nn(e,n)return function(l,t,o)return n(nil,t,o,e)end
- end
- local function g(n,t,e)if not e then
- e=1
- else
- e=e+1
- end
- local e=string.find(n,t,e,true)return e~=nil
- end
- local w,S,k,T,x,B
- do
- local function a(e,t)local e=1
- while true do
- local n=debug.getinfo(e,"f")e=e+1
- if not n then
- e=1
- break
- elseif n.func==t then
- break
- end
- end
- if g(_VERSION,"Lua 5.0")then
- return debug.traceback(("[Level "..tostring(e)).."]")else
- return debug.traceback(nil,e)end
- end
- local function r(e,n)return function(e)local n=n(e)local t=debug.getinfo(3,"f")local o=g(_VERSION,"Lua 5.0")or _VERSION=="Lua 5.1"if o or t and t.func~=error then
- return n
- else
- return(n.."\n")..tostring(e.stack)end
- end
- end
- local function t(t,e,n)e.name=n
- return setmetatable(e,{__call=function(t,t,n)return l(e,n)end})end
- local o=t
- local n=d()n.name=""function n.prototype.____constructor(e,n)if n==nil then
- n=""end
- e.message=n
- e.name="Error"e.stack=a(nil,e.constructor.new)local e=getmetatable(e)if e and not e.__errorToStringPatched then
- e.__errorToStringPatched=true
- e.__tostring=r(nil,e.__tostring)end
- end
- function n.prototype.__tostring(e)return e.message~=""and(e.name..": ")..e.message or e.name
- end
- w=o(nil,n,"Error")local function n(e,o)local t=t
- local e=d()e.name=e.name
- z(e,w)function e.prototype.____constructor(n,...)e.____super.prototype.____constructor(n,...)n.name=o
- end
- return t(nil,e,o)end
- S=n(nil,"RangeError")k=n(nil,"ReferenceError")T=n(nil,"SyntaxError")x=n(nil,"TypeError")B=n(nil,"URIError")end
- local function C(e)local e=getmetatable(e)if not e then
- return{}end
- return rawget(e,"_descriptors")or({})end
- local function Qe(n,e)local t=C(n)local o=t[e]if o then
- if not o.configurable then
- error(l(x,((("Cannot delete property "..tostring(e)).." of ")..tostring(n)).."."),0)end
- t[e]=nil
- return true
- end
- n[e]=nil
- return true
- end
- local function m(n,e)if e>=0 and e<#n then
- return string.sub(n,e+1,e+1)end
- end
- local function Ye(e)if type(e)=="string"then
- for n=0,#e-1 do
- coroutine.yield(m(e,n))end
- elseif e.____coroutine~=nil then
- local n=e.____coroutine
- while true do
- local t,e=coroutine.resume(n)if not t then
- error(e,0)end
- if coroutine.status(n)=="dead"then
- return e
- else
- coroutine.yield(e)end
- end
- elseif e[n.iterator]then
- local e=e[n.iterator](e)while true do
- local e=e:next()if e.done then
- return e.value
- else
- coroutine.yield(e.value)end
- end
- else
- for n,e in ipairs(e)do
- coroutine.yield(e)end
- end
- end
- local A
- do
- local function t(e)return e
- end
- local function o(e,...)local e=e.____coroutine
- if coroutine.status(e)=="dead"then
- return{done=true}end
- local t,n=coroutine.resume(e,...)if not t then
- error(n,0)end
- return{value=n,done=coroutine.status(e)=="dead"}end
- function A(l)return function(...)local e={...}local r=s(...)return{____coroutine=coroutine.create(function()return l(h(e,1,r))end),[n.iterator]=t,next=o}end
- end
- end
- local function en(e)local e=type(e)return e=="table"or e=="function"end
- local function Je(o,l,e)local n={}local e,t=o(l,e)while e do
- n[#n+1]={e,t}e,t=o(l,e)end
- return h(n)end
- local t
- do
- t=d()t.name="Map"function t.prototype.____constructor(e,t)e[n.toStringTag]="Map"e.items={}e.size=0
- e.nextKey={}e.previousKey={}if t==nil then
- return
- end
- local o=t
- if o[n.iterator]then
- local n=o[n.iterator](o)while true do
- local n=n:next()if n.done then
- break
- end
- local n=n.value
- e:set(n[1],n[2])end
- else
- local n=t
- for t,n in ipairs(n)do
- e:set(n[1],n[2])end
- end
- end
- function t.prototype.clear(e)e.items={}e.nextKey={}e.previousKey={}e.firstKey=nil
- e.lastKey=nil
- e.size=0
- end
- function t.prototype.delete(e,n)local l=e:has(n)if l then
- e.size=e.size-1
- local o=e.nextKey[n]local t=e.previousKey[n]if o~=nil and t~=nil then
- e.nextKey[t]=o
- e.previousKey[o]=t
- elseif o~=nil then
- e.firstKey=o
- e.previousKey[o]=nil
- elseif t~=nil then
- e.lastKey=t
- e.nextKey[t]=nil
- else
- e.firstKey=nil
- e.lastKey=nil
- end
- e.nextKey[n]=nil
- e.previousKey[n]=nil
- end
- e.items[n]=nil
- return l
- end
- function t.prototype.forEach(e,t)for o,n in r(e:keys())do
- t(nil,e.items[n],n,e)end
- end
- function t.prototype.get(e,n)return e.items[n]end
- function t.prototype.has(e,n)return e.nextKey[n]~=nil or e.lastKey==n
- end
- function t.prototype.set(e,n,l)local o=not e:has(n)if o then
- e.size=e.size+1
- end
- e.items[n]=l
- if e.firstKey==nil then
- e.firstKey=n
- e.lastKey=n
- elseif o then
- e.nextKey[e.lastKey]=n
- e.previousKey[n]=e.lastKey
- e.lastKey=n
- end
- return e
- end
- t.prototype[n.iterator]=function(e)return e:entries()end
- function t.prototype.entries(e)local o=e.items
- local t=e.nextKey
- local e=e.firstKey
- return{[n.iterator]=function(e)return e
- end,next=function(n)local n={done=not e,value={e,o[e]}}e=t[e]return n
- end}end
- function t.prototype.keys(e)local t=e.nextKey
- local e=e.firstKey
- return{[n.iterator]=function(e)return e
- end,next=function(n)local n={done=not e,value=e}e=t[e]return n
- end}end
- function t.prototype.values(e)local o=e.items
- local l=e.nextKey
- local e=e.firstKey
- return{[n.iterator]=function(e)return e
- end,next=function(n)local n={done=not e,value=o[e]}e=l[e]return n
- end}end
- t[n.species]=t
- end
- local f=string.match
- local He=math.atan2 or math.atan
- local M=math.modf
- local function Ie(e)if e>0 then
- return 1
- elseif e<0 then
- return-1
- end
- return 0
- end
- local function Me(e)local n=type(e)if n=="number"then
- return e
- elseif n=="string"then
- local n=tonumber(e)if n then
- return n
- end
- if e=="Infinity"then
- return math.huge
- end
- if e=="-Infinity"then
- return-math.huge
- end
- local e=string.gsub(e,"%s","")if e==""then
- return 0
- end
- return 0/0
- elseif n=="boolean"then
- return e and 1 or 0
- else
- return 0/0
- end
- end
- local function Ve(e)return type(e)=="number"and e==e and e~=math.huge and e~=-math.huge
- end
- local function Ee(e)return e~=e
- end
- local P
- do
- local r="0123456789abcdefghijklmnopqrstuvwxyz"function P(t,e)if e==nil or e==10 or t==math.huge or t==-math.huge or t~=t then
- return tostring(t)end
- e=math.floor(e)if e<2 or e>36 then
- error("toString() radix argument must be between 2 and 36",0)end
- local l,o=M(math.abs(t))local n=""if e==8 then
- n=string.format("%o",l)elseif e==16 then
- n=string.format("%x",l)else
- repeat
- do
- n=m(r,l%e)..n
- l=math.floor(l/e)end
- until not(l~=0)end
- if o~=0 then
- n=n.."."local t=1e-16
- repeat
- do
- o=o*e
- t=t*e
- local e=math.floor(o)n=n..m(r,e)o=o-e
- end
- until not(o>=t)end
- if t<0 then
- n="-"..n
- end
- return n
- end
- end
- local function De(e,n)if math.abs(e)>=1e21 or e~=e then
- return tostring(e)end
- local n=math.floor(n or 0)if n<0 or n>99 then
- error("toFixed() digits argument must be between 0 and 99",0)end
- return string.format(("%."..tostring(n)).."f",e)end
- local function Pe(t,n,e)local i=type(n)=="number"and n+1 or n
- local o=rawget(t,i)local l=e.get~=nil or e.set~=nil
- local a
- if l then
- if o~=nil then
- error("Cannot redefine property: "..tostring(n),0)end
- a=e
- else
- local n=o~=nil
- local d=e.set
- local i=e.get
- local r
- if e.configurable~=nil then
- r=e.configurable
- else
- r=n
- end
- local t
- if e.enumerable~=nil then
- t=e.enumerable
- else
- t=n
- end
- local l
- if e.writable~=nil then
- l=e.writable
- else
- l=n
- end
- local n
- if e.value~=nil then
- n=e.value
- else
- n=o
- end
- a={set=d,get=i,configurable=r,enumerable=t,writable=l,value=n}end
- b(t,i,a)return t
- end
- local function Ae(o)local t={}local e=0
- for n in pairs(o)do
- e=e+1
- t[e]={n,o[n]}end
- return t
- end
- local function Ge(o)local e={}local t=o
- if t[n.iterator]then
- local n=t[n.iterator](t)while true do
- local n=n:next()if n.done then
- break
- end
- local n=n.value
- e[n[1]]=n[2]end
- else
- for t,n in ipairs(o)do
- e[n[1]]=n[2]end
- end
- return e
- end
- local function Xe(t)local n={}local e=0
- for t in pairs(t)do
- e=e+1
- n[e]=t
- end
- return n
- end
- local function Re(t,o)local n={}for e in pairs(t)do
- if not o[e]then
- n[e]=t[e]end
- end
- return n
- end
- local function qe(t)local n={}local e=0
- for o in pairs(t)do
- e=e+1
- n[e]=t[o]end
- return n
- end
- local function We(n)local e=f(n,"^%s*(-?Infinity)")if e~=nil then
- return m(e,0)=="-"and-math.huge or math.huge
- end
- local e=tonumber(f(n,"^%s*(-?%d+%.?%d*)"))return e or 0/0
- end
- local function p(t,n,e)if e~=e then
- e=0
- end
- if e~=nil and n>e then
- n,e=e,n
- end
- if n>=0 then
- n=n+1
- else
- n=1
- end
- if e~=nil and e<0 then
- e=0
- end
- return string.sub(t,n,e)end
- local H
- do
- local o="0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ"function H(n,e)if e==nil then
- e=10
- local t=f(n,"^%s*-?0[xX]")if t~=nil then
- e=16
- n=f(t,"-")and"-"..p(n,#t)or p(n,#t)end
- end
- if e<2 or e>36 then
- return 0/0
- end
- local t=e<=10 and p(o,0,e)or p(o,0,10+2*(e-10))local t=("^%s*(-?["..t).."]*)"local e=tonumber(f(n,t),e)if e==nil then
- return 0/0
- end
- if e>=0 then
- return math.floor(e)else
- return math.ceil(e)end
- end
- end
- local function Ke(n)local a={}local i={}local t=0
- local o=0
- for l,n in r(n)do
- if c(n,e)then
- if n.state==1 then
- a[o+1]=n.value
- elseif n.state==2 then
- return e.reject(n.rejectionReason)else
- t=t+1
- i[o]=n
- end
- else
- a[o+1]=n
- end
- o=o+1
- end
- if t==0 then
- return e.resolve(a)end
- return l(e,function(e,l,n)for o,e in pairs(i)do
- e["then"](e,function(n,e)a[o+1]=e
- t=t-1
- if t==0 then
- l(nil,a)end
- end,function(t,e)n(nil,e)end)end
- end)end
- local function Oe(o)local t={}local i={}local n=0
- local a=0
- for l,o in r(o)do
- if c(o,e)then
- if o.state==1 then
- t[a+1]={status="fulfilled",value=o.value}elseif o.state==2 then
- t[a+1]={status="rejected",reason=o.rejectionReason}else
- n=n+1
- i[a]=o
- end
- else
- t[a+1]={status="fulfilled",value=o}end
- a=a+1
- end
- if n==0 then
- return e.resolve(t)end
- return l(e,function(o,e)for o,l in pairs(i)do
- l["then"](l,function(r,l)t[o+1]={status="fulfilled",value=l}n=n-1
- if n==0 then
- e(nil,t)end
- end,function(r,l)t[o+1]={status="rejected",reason=l}n=n-1
- if n==0 then
- e(nil,t)end
- end)end
- end)end
- local function Le(n)local o={}local t={}for l,n in r(n)do
- if c(n,e)then
- if n.state==1 then
- return e.resolve(n.value)elseif n.state==2 then
- o[#o+1]=n.rejectionReason
- else
- t[#t+1]=n
- end
- else
- return e.resolve(n)end
- end
- if#t==0 then
- return e.reject("No promises to resolve with .any()")end
- local n=0
- return l(e,function(e,l,r)for a,e in ipairs(t)do
- e["then"](e,function(n,e)l(nil,e)end,function(l,e)o[#o+1]=e
- n=n+1
- if n==#t then
- r(nil,{name="AggregateError",message="All Promises rejected",errors=o})end
- end)end
- end)end
- local function je(n)local t={}for o,n in r(n)do
- if c(n,e)then
- if n.state==1 then
- return e.resolve(n.value)elseif n.state==2 then
- return e.reject(n.rejectionReason)else
- t[#t+1]=n
- end
- else
- return e.resolve(n)end
- end
- return l(e,function(e,n,o)for t,e in ipairs(t)do
- e["then"](e,function(t,e)return n(nil,e)end,function(n,e)return o(nil,e)end)end
- end)end
- local o
- do
- o=d()o.name="Set"function o.prototype.____constructor(e,t)e[n.toStringTag]="Set"e.size=0
- e.nextKey={}e.previousKey={}if t==nil then
- return
- end
- local o=t
- if o[n.iterator]then
- local n=o[n.iterator](o)while true do
- local n=n:next()if n.done then
- break
- end
- e:add(n.value)end
- else
- local n=t
- for t,n in ipairs(n)do
- e:add(n)end
- end
- end
- function o.prototype.add(e,n)local t=not e:has(n)if t then
- e.size=e.size+1
- end
- if e.firstKey==nil then
- e.firstKey=n
- e.lastKey=n
- elseif t then
- e.nextKey[e.lastKey]=n
- e.previousKey[n]=e.lastKey
- e.lastKey=n
- end
- return e
- end
- function o.prototype.clear(e)e.nextKey={}e.previousKey={}e.firstKey=nil
- e.lastKey=nil
- e.size=0
- end
- function o.prototype.delete(e,o)local l=e:has(o)if l then
- e.size=e.size-1
- local n=e.nextKey[o]local t=e.previousKey[o]if n~=nil and t~=nil then
- e.nextKey[t]=n
- e.previousKey[n]=t
- elseif n~=nil then
- e.firstKey=n
- e.previousKey[n]=nil
- elseif t~=nil then
- e.lastKey=t
- e.nextKey[t]=nil
- else
- e.firstKey=nil
- e.lastKey=nil
- end
- e.nextKey[o]=nil
- e.previousKey[o]=nil
- end
- return l
- end
- function o.prototype.forEach(e,t)for o,n in r(e:keys())do
- t(nil,n,n,e)end
- end
- function o.prototype.has(e,n)return e.nextKey[n]~=nil or e.lastKey==n
- end
- o.prototype[n.iterator]=function(e)return e:values()end
- function o.prototype.entries(e)local t=e.nextKey
- local e=e.firstKey
- return{[n.iterator]=function(e)return e
- end,next=function(n)local n={done=not e,value={e,e}}e=t[e]return n
- end}end
- function o.prototype.keys(e)local t=e.nextKey
- local e=e.firstKey
- return{[n.iterator]=function(e)return e
- end,next=function(n)local n={done=not e,value=e}e=t[e]return n
- end}end
- function o.prototype.values(e)local t=e.nextKey
- local e=e.firstKey
- return{[n.iterator]=function(e)return e
- end,next=function(n)local n={done=not e,value=e}e=t[e]return n
- end}end
- o[n.species]=o
- end
- local function te(...)local e={...}e.sparseLength=s(...)return e
- end
- local function ne(e,...)local l={...}local o=s(...)local n=e.sparseLength
- for t=1,o do
- e[n+t]=l[t]end
- e.sparseLength=n+o
- end
- local function W(e)local n=unpack or table.unpack
- return n(e,1,e.sparseLength)end
- local a
- do
- a=d()a.name="WeakMap"function a.prototype.____constructor(e,t)e[n.toStringTag]="WeakMap"e.items={}setmetatable(e.items,{__mode="k"})if t==nil then
- return
- end
- local o=t
- if o[n.iterator]then
- local n=o[n.iterator](o)while true do
- local n=n:next()if n.done then
- break
- end
- local n=n.value
- e.items[n[1]]=n[2]end
- else
- for t,n in ipairs(t)do
- e.items[n[1]]=n[2]end
- end
- end
- function a.prototype.delete(e,n)local t=e:has(n)e.items[n]=nil
- return t
- end
- function a.prototype.get(e,n)return e.items[n]end
- function a.prototype.has(n,e)return n.items[e]~=nil
- end
- function a.prototype.set(e,t,n)e.items[t]=n
- return e
- end
- a[n.species]=a
- end
- local i
- do
- i=d()i.name="WeakSet"function i.prototype.____constructor(e,o)e[n.toStringTag]="WeakSet"e.items={}setmetatable(e.items,{__mode="k"})if o==nil then
- return
- end
- local t=o
- if t[n.iterator]then
- local n=t[n.iterator](t)while true do
- local n=n:next()if n.done then
- break
- end
- e.items[n.value]=true
- end
- else
- for t,n in ipairs(o)do
- e.items[n]=true
- end
- end
- end
- function i.prototype.add(e,n)e.items[n]=true
- return e
- end
- function i.prototype.delete(n,e)local t=n:has(e)n.items[e]=nil
- return t
- end
- function i.prototype.has(e,n)return e.items[n]==true
- end
- i[n.species]=i
- end
- local function re(n,e)_G.__TS__sourcemap=_G.__TS__sourcemap or({})_G.__TS__sourcemap[n]=e
- if _G.__TS__originalTraceback==nil then
- local n=debug.traceback
- _G.__TS__originalTraceback=n
- debug.traceback=function(l,o,t)local e
- if l==nil and o==nil and t==nil then
- e=n()elseif g(_VERSION,"Lua 5.0")then
- e=n((("[Level "..tostring(t)).."] ")..tostring(o))else
- e=n(l,o,t)end
- if type(e)~="string"then
- return e
- end
- local function l(e,t,o,n)local e=_G.__TS__sourcemap[t]if e~=nil and e[n]~=nil then
- local e=e[n]if type(e)=="number"then
- return(o..":")..tostring(e)end
- return(e.file..":")..tostring(e.line)end
- return(t..":")..n
- end
- local n=string.gsub(e,"(%S+)%.lua:(%d+)",function(e,n)return l(nil,e..".lua",e..".ts",n)end)local function l(e,t,o)local e=_G.__TS__sourcemap[t]if e~=nil and e[o]~=nil then
- local n=f(t,"%[string \"([^\"]+)\"%]")local n=string.gsub(n,".lua$",".ts")local e=e[o]if type(e)=="number"then
- return(n..":")..tostring(e)end
- return(e.file..":")..tostring(e.line)end
- return(t..":")..o
- end
- n=string.gsub(n,"(%[string \"[^\"]+\"%]):(%d+)",function(e,n)return l(nil,e,n)end)return n
- end
- end
- end
- local function K(e)local n={}if type(e)=="string"then
- for t=0,#e-1 do
- n[t+1]=m(e,t)end
- else
- local t=0
- for o,e in r(e)do
- t=t+1
- n[t]=e
- end
- end
- return h(n)end
- local function J(n,e)if e~=e then
- e=0
- end
- if e<0 then
- return""end
- return string.sub(n,e+1,e+1)end
- local function Y(n,e)if e~=e then
- e=0
- end
- if e<0 then
- return 0/0
- end
- return string.byte(n,e+1)or 0/0
- end
- local function N(n,t,e)if e==nil or e>#n then
- e=#n
- end
- return string.sub(n,e-#t+1,e)==t
- end
- local function U(t,e,n)if n==nil then
- n=" "end
- if e~=e then
- e=0
- end
- if e==-math.huge or e==math.huge then
- error("Invalid string length",0)end
- if#t>=e or#n==0 then
- return t
- end
- e=e-#t
- if e>#n then
- n=n..string.rep(n,math.floor(e/#n))end
- return t..string.sub(n,1,math.floor(e))end
- local function le(t,e,n)if n==nil then
- n=" "end
- if e~=e then
- e=0
- end
- if e==-math.huge or e==math.huge then
- error("Invalid string length",0)end
- if#t>=e or#n==0 then
- return t
- end
- e=e-#t
- if e>#n then
- n=n..string.rep(n,math.floor(e/#n))end
- return string.sub(n,1,math.floor(e))..t
- end
- local G
- do
- local o=string.sub
- function G(e,l,t)local n,a=string.find(e,l,nil,true)if not n then
- return e
- end
- local r=o(e,1,n-1)local n=type(t)=="string"and t or t(nil,l,n-1,e)local e=o(e,a+1)return(r..n)..e
- end
- end
- local _
- do
- local a=string.sub
- local i=string.find
- function _(t,r,n)if n==nil then
- n=4294967295
- end
- if n==0 then
- return{}end
- local o={}local e=1
- if r==nil or r==""then
- for n=1,#t do
- o[e]=a(t,n,n)e=e+1
- end
- else
- local l=1
- while e<=n do
- local n,r=i(t,r,l,true)if not n then
- break
- end
- o[e]=a(t,l,n-1)e=e+1
- l=r+1
- end
- if e<=n then
- o[e]=a(t,l)end
- end
- return o
- end
- end
- local V
- do
- local a=string.sub
- local i=string.find
- function V(n,l,o)if type(o)=="string"then
- local e=table.concat(_(n,l),o)if#l==0 then
- return(o..e)..o
- end
- return e
- end
- local t={}local e=1
- if#l==0 then
- t[1]=o(nil,"",0,n)e=2
- for l=1,#n do
- t[e]=a(n,l,l)t[e+1]=o(nil,"",l,n)e=e+2
- end
- else
- local r=1
- while true do
- local i,d=i(n,l,r,true)if not i then
- break
- end
- t[e]=a(n,r,i-1)t[e+1]=o(nil,l,i-1,n)e=e+2
- r=d+1
- end
- t[e]=a(n,r)end
- return table.concat(t)end
- end
- local function q(t,n,e)if n==nil or n~=n then
- n=0
- end
- if e~=e then
- e=0
- end
- if n>=0 then
- n=n+1
- end
- if e~=nil and e<0 then
- e=e-1
- end
- return string.sub(t,n,e)end
- local function oe(t,n,e)if e==nil or e<0 then
- e=0
- end
- return string.sub(t,e+1,#n+e)==n
- end
- local function ee(t,e,n)if e~=e then
- e=0
- end
- if n~=nil then
- if n~=n or n<=0 then
- return""end
- n=n+e
- end
- if e>=0 then
- e=e+1
- end
- return string.sub(t,e,n)end
- local function ae(e)local e=string.gsub(e,"^[%s ]*(.-)[%s ]*$","%1")return e
- end
- local function Z(e)local e=string.gsub(e,"[%s ]*$","")return e
- end
- local function Q(e)local e=string.gsub(e,"^[%s ]*","")return e
- end
- local L,O
- do
- local e={}function L(n)if not e[n]then
- e[n]=u(n)end
- return e[n]end
- function O(t)for n in pairs(e)do
- if e[n]==t then
- return n
- end
- end
- return nil
- end
- end
- local function R(e)local e=type(e)if e=="table"then
- return"object"elseif e=="nil"then
- return"undefined"else
- return e
- end
- end
- return{__TS__ArrayConcat=be,__TS__ArrayEntries=ye,__TS__ArrayEvery=me,__TS__ArrayFilter=ge,__TS__ArrayForEach=pe,__TS__ArrayFind=_e,__TS__ArrayFindIndex=Be,__TS__ArrayFrom=j,__TS__ArrayIncludes=Fe,__TS__ArrayIndexOf=ze,__TS__ArrayIsArray=y,__TS__ArrayJoin=xe,__TS__ArrayMap=we,__TS__ArrayPush=ve,__TS__ArrayPushArray=Te,__TS__ArrayReduce=Se,__TS__ArrayReduceRight=ke,__TS__ArrayReverse=Ce,__TS__ArrayUnshift=I,__TS__ArraySort=se,__TS__ArraySlice=ue,__TS__ArraySome=fe,__TS__ArraySplice=ie,__TS__ArrayToObject=ce,__TS__ArrayFlat=X,__TS__ArrayFlatMap=de,__TS__ArraySetLength=he,__TS__AsyncAwaiter=Ze,__TS__Await=Ne,__TS__Class=d,__TS__ClassExtends=z,__TS__CloneDescriptor=F,__TS__CountVarargs=s,__TS__Decorate=Ue,__TS__DecorateParam=nn,__TS__Delete=Qe,__TS__DelegatedYield=Ye,Error=w,RangeError=S,ReferenceError=k,SyntaxError=T,TypeError=x,URIError=B,__TS__FunctionBind=v,__TS__Generator=A,__TS__InstanceOf=c,__TS__InstanceOfObject=en,__TS__Iterator=r,__TS__LuaIteratorSpread=Je,Map=t,__TS__Match=f,__TS__MathAtan2=He,__TS__MathModf=M,__TS__MathSign=Ie,__TS__New=l,__TS__Number=Me,__TS__NumberIsFinite=Ve,__TS__NumberIsNaN=Ee,__TS__NumberToString=P,__TS__NumberToFixed=De,__TS__ObjectAssign=E,__TS__ObjectDefineProperty=Pe,__TS__ObjectEntries=Ae,__TS__ObjectFromEntries=Ge,__TS__ObjectGetOwnPropertyDescriptor=D,__TS__ObjectGetOwnPropertyDescriptors=C,__TS__ObjectKeys=Xe,__TS__ObjectRest=Re,__TS__ObjectValues=qe,__TS__ParseFloat=We,__TS__ParseInt=H,__TS__Promise=e,__TS__PromiseAll=Ke,__TS__PromiseAllSettled=Oe,__TS__PromiseAny=Le,__TS__PromiseRace=je,Set=o,__TS__SetDescriptor=b,__TS__SparseArrayNew=te,__TS__SparseArrayPush=ne,__TS__SparseArraySpread=W,WeakMap=a,WeakSet=i,__TS__SourceMapTraceBack=re,__TS__Spread=K,__TS__StringAccess=m,__TS__StringCharAt=J,__TS__StringCharCodeAt=Y,__TS__StringEndsWith=N,__TS__StringIncludes=g,__TS__StringPadEnd=U,__TS__StringPadStart=le,__TS__StringReplace=G,__TS__StringReplaceAll=V,__TS__StringSlice=q,__TS__StringSplit=_,__TS__StringStartsWith=oe,__TS__StringSubstr=ee,__TS__StringSubstring=p,__TS__StringTrim=ae,__TS__StringTrimEnd=Z,__TS__StringTrimStart=Q,__TS__Symbol=u,Symbol=n,__TS__SymbolRegistryFor=L,__TS__SymbolRegistryKeyFor=O,__TS__TypeOf=R,__TS__Unpack=h}end,["utils"]=function(...)local e={}function e.read_file(e)local e,n=io.open(e,"rb")if not e then
- error("could not open file: "..n)end
- local n=e:read("*a")if not n then
- error"could not read file"end
- e:close()return n
- end
- function e.write_file(e,t)local n,o=io.open(e,"wb")if not n then
- error((("could not open file "..e)..": ")..o)end
- local o,t=n:write(t)if not o then
- error((("could not write to file "..e)..": ")..t)end
- n:close()end
- function e.log(e,o)local n,t=io.open(e,"a")if not n then
- error((("could not open file "..e)..": ")..t)end
- local t,o=n:write(o)if not t then
- error((("could not write to file "..e)..": ")..o)end
- n:close()end
- function e.download(n)local e,t=http.get(n,nil,true)if not e or e==true then
- error((("could not download "..n)..": ")..t)end
- local n=e.readAll()e.close()return n or""end
- return e
- end,["game"]=function(...)local e=a("lualib_bundle")local o=e.__TS__Class
- local n=e.__TS__Unpack
- local s=e.__TS__ArrayMap
- local r=e.__TS__ArrayIndexOf
- local p=e.__TS__StringAccess
- local i=e.__TS__StringSubstring
- local f=e.__TS__ArrayConcat
- local c=e.__TS__New
- local v=e.__TS__ArrayForEach
- local b=e.__TS__StringEndsWith
- local k=e.__TS__ObjectValues
- local l=e.__TS__ArrayUnshift
- local S={}local g,d,T,t
- local u=a("pine3d.Pine3D")local h=a("basalt.basalt")local y=a("kernel")local m=a("utils")local F=a("nbs")function g()local t=500
- local n={}for e=1,300 do
- local o,e=math.random()<.2,math.random()<.6
- local l=o and(e and colours.lightBlue or colours.red)or(e and colours.white or colours.yellow)local o=2*math.pi*math.pow(2*math.random()-1,2)local e=2*math.pi*math.pow(2*math.random()-1,2)local e,t,o=t*math.sin(o)*math.cos(e),t*math.sin(e),t*math.cos(o)*math.cos(e)n[#n+1]={l,e,t,o}end
- return n
- end
- function d(e,n)if n==nil then
- n=1
- end
- local n=math.sqrt(e[1]*e[1]+e[2]*e[2]+e[3]*e[3])*1/n
- if n>1e-5 then
- return{e[1]/n,e[2]/n,e[3]/n}else
- return{0,0,0}end
- end
- function T(r,o,n,l,a,e)local o=r-o
- local r=string.format("%.2f",n)local i=string.format("%.2f",n/o*100)local l=string.format("%.2f",l)local n=string.format("%.2f",a)t(((((((("fps "..l).." ui ")..r).." max ")..n).." (")..i).."%)")for n=0,#e-1 do
- local o=string.format("%.2f",e[n+1][1]/o*100)local l=string.format("%.2f",e[n+1][1])local e=string.format("%.2f",e[n+1][2])t(((((((("-> thread "..tostring(n)).." time ")..l).." max ")..e).." (")..o).."%)")end
- end
- function t(...)local n={...}local e=debug.getinfo(2)local o=e and e.name or"?"local a=e and e.namewhat or""local r=e and e.short_src or"?"local t=e and e.currentline or"?"local e=string.format("%.3f",os.clock())l(n,((((((((("["..e).." ")..a).." ")..o).." at ")..r)..":")..tostring(t)).."]")m.log("/pg-log.txt",table.concat(s(n,function(n,e)return tostring(e)end),"\t").."\n")end
- local C={arid={"dry",("Dry, rocky world with a nitrogen-oxygen atmosphere. ".."The dust-covered terrain consists largely of mesas and canyons. ").."Forests can be found in the more temperate polar regions, but vegetation is otherwise scarce."},desert={"dry",(("Dry, rocky world with a nitrogen-oxygen atmosphere. ".."Precipitation and major bodies of surface water are relatively rare. Significant ").."temperature variations between day and night cycles. Vegetation is scarce, but even ").."moderate precipitation can make the desert bloom."},savanna={"dry",("Rocky world dominated by dry, arid plains covered by a nitrogen-oxygen ".."atmosphere. The small hydrosphere allows for brief wet seasons, but aside from a few ").."ubiquitous grasses vegetation is largely concentrated around shallow oases."},alpine={"frozen",(("Mountainous world with a nitrogen-oxygen atmosphere. Snow covers the ".."mountaintops and frozen-over lakes dot the valleys. While the planet experiences the minimal ").."seasonal variations, the still-liquid water beneath the frozen surface of the lakes is enough ").."to sustain some hardy vegetation."},arctic={"frozen",("Frigid, rocky world with a nitrogen-oxygen atmosphere. The poles are big, ".."and significant water deposits can be found permanently frozen as glacial ice. However, the planet ").."experiences seasonal variations and the equatorial band is covered by vegetation."},tundra={"frozen",("Cold and rocky world with a nitrogen-oxygen atmosphere. Permafrost covers most ".."of the surface except for the more temperate equatorial regions. A stable biosphere exists but ").."vegetation is mostly limited to mosses and lichens."},continental={"wet",("Rocky world with a nitrogen-oxygen atmosphere. Active and stable hydrosphere. ".."Great landmasses are separated by oceans, with large climate variations depending on latitude and ").."precipitation."},ocean={"wet","Rocky world with a nitrogen-oxygen atmosphere and a significant hydrosphere. ".."Oceans cover more than 90% of the surface, with scattered islands making up the remaining percentage."},tropical={"wet",("Humid, rocky world with a thick nitrogen-oxygen atmosphere. Seasons with ".."significant precipitation are interchanged with drier periods. Most landmasses are covered ").."in dense vegetation."},asteroid={false,("A rocky or metallic object that orbits a star. It is too small to be ".."considered a planet and can vary greatly in size. Some asteroids may be rich in valuable minerals, ").."while others may be little more than space rocks."},["gas giant"]={false,("A massive planet composed mainly of hydrogen and helium gases. ".."These planets have thick atmospheres and strong winds, but no solid surface. Gas giants ").."often have a system of rings and numerous moons."},["frozen world"]={false,("A frigid planet with a surface temperature well below freezing. ".."These worlds are often covered in ice and snow, and may have frozen oceans or lakes. Life is ").."scarce on frozen worlds, but some extremophile organisms may exist."},["barren world"]={false,("A rocky planet with a thin or nonexistent atmosphere. Barren worlds may ".."have little or no water, and are often subject to extreme temperatures and radiation. ").."These worlds are generally inhospitable to life."}}local e=StarType or({})e.ClassB="Class B"e.ClassA="Class A"e.ClassF="Class F"e.ClassG="Class G"e.ClassK="Class K"e.ClassM="Class M"e.ClassMRedGiant="Class M Red Giant"e.ClassTBrownDwarf="Class T Brown Dwarf"local z={["Class B"]="The large class B main-sequence stars are very bright and blue. ".."Although somewhat rare, the luminosity of these stars make them among the most visible to the naked eye.",["Class A"]=("These relatively young white or bluish-white main-sequence stars are ".."typically among the most visible to the naked eye. They are large and rotate very ").."quickly, but will eventually evolve into slower and cooler red giants.",["Class F"]=("F-type stars are fairly large and often referred to as yellow-white dwarves. ".."Although they often emit significant amounts of UV radiation, their wide habitable zones ").."have a good chance of supporting life-bearing worlds.",["Class G"]=(("Often referred to as yellow dwarves, G-type stars actually range in color from white ".."to slightly yellow. Main-sequence stars fuse hydrogen for roughly 10 billion years before they ").."expand and become red giants. Although their lifespans are shorter than K-type stars, worlds ").."inside the habitable zone of a G star often enjoy optimal conditions for the development of life.",["Class K"]=("These main-sequence stars, sometimes referred to as orange dwarves, are a fairly ".."common sight. They are stable on the main-sequence for up to 30 billion years, meaning that ").."worlds orbiting a K-type star have a longer than average window to evolve life.",["Class M"]=(("The most common stars in the universe, often referred to as red dwarves. ".."Their low luminosity means they are difficult to observe with the naked eye from afar. ").."Although they typically have an extremely long lifespan, red dwarves emit almost no UV ").."light resulting in unfavorable conditions for most forms of life.",["Class M Red Giant"]=("With a large radius and comparatively low surface temperature, red giants ".."are stars of moderate mass in a late stage of stellar evolution. Their expanded stellar ").."atmosphere and high luminosity make for distant habitable zone orbits.",["Class T Brown Dwarf"]=(("Brown dwarfs are substellar objects that lack the mass to sustain ".."hydrogen fusion. Roughly the size of large gas giants, they have a much greater density. ").."Their low luminosity and comparatively small heat generation means that planets orbiting ").."them are unlikely to support life."}local B={[e.ClassB]={15,45},[e.ClassA]={15,45},[e.ClassF]={10,60},[e.ClassG]={15,45},[e.ClassK]={15,45},[e.ClassM]={10,30},[e.ClassMRedGiant]={40,80},[e.ClassTBrownDwarf]={5,20}}local a=o()a.name="Music"function a.prototype.____constructor(e,o,n,t,l)e.artist=o
- e.name=n
- e.url=t
- e.data=l
- end
- local x=o()x.name="StarSystem"function x.prototype.____constructor(e,t,n)e.star=t
- e.planets=n
- end
- local w=o()w.name="Galaxy"function w.prototype.____constructor(n,e)n.systems=e
- end
- local _=o()_.name="UIState"function _.prototype.____constructor(e,n,t,o,r,l,a)e.sidebar_list=n
- e.side_tabs=t
- e.info_label=o
- e.speaker_button=r
- e.animations=l
- e.main_frame=a
- end
- local o=o()o.name="GameState"function o.prototype.____constructor(e,n,f,m,h,p,_,w,g,b,y,d,i,a,l,o,t,r,c,s,u)e.mode=n
- e.last_mouse_click=f
- e.clouds=m
- e.objects=h
- e.object_names=p
- e.frame=_
- e.camera=w
- e.camera_target=g
- e.camera_angle_x=b
- e.camera_angle_y=y
- e.camera_angle_y_limits=d
- e.dist_to_target=i
- e.pressed_keys=a
- e.tracks=l
- e.playing=o
- e.speaker_available=t
- e.galaxy=r
- e.current_system=c
- e.trace_overlay=s
- e.ui_state=u
- end
- function o.prototype.change_mode(e,n)if n=="system"then
- e.mode="system"e:set_up_system_scene()elseif n=="galaxy"then
- e.mode="galaxy"e:set_up_galaxy_scene()end
- end
- function o.prototype.process_click(e,r,o,l)if r-e.last_mouse_click<.3 then
- local o=e.frame:getObjectIndexTrace(e.objects,{{x=o,y=l}})local l=o[1].objectIndex
- t(((((("trace returned "..tostring(l)).." / ")..tostring(#e.objects)).." (")..tostring(#e.object_names))..")")if l and l<=#e.objects then
- local o=e.object_names[l]if e.mode=="galaxy"then
- e.current_system=o
- e:change_mode("system")else
- t((((((("double click in system mode, "..tostring(e.current_system))..", ")..tostring(l))..", ")..tostring(o))..", \nall names are: ")..table.concat(e.object_names,","))local t=e.galaxy.systems[e.current_system+1][2]local t,n,l=n(o==-1 and({0,0,0})or t.planets[o+1][1])e.camera_target={t,n,l}e:change_info_tab(e:describe(o))end
- end
- end
- end
- function o.prototype.draw_starfield(e,t)local l=e.frame.buffer.setPixel
- local o=e.frame.map3dTo2d
- local r=e.frame.buffer
- for a=0,#t-1 do
- local a,n,t,i=n(t[a+1])local o,t,n=o(e.frame,n,t,i)if n then
- l(r,o,t,e.mode=="system"and a or colours.lightGrey)end
- end
- end
- function o.prototype.change_info_tab(e,o)local e=e.ui_state
- local n=r(s(e.side_tabs,function(n,e)return e[1]end),"info")local t=e.sidebar_list:getAll()e.sidebar_list:editItem(n+1,t[n+1].text,t[n+1].bgCol,colours.lime)e.info_label:setText(o)end
- function o.prototype.describe(e,t)if t==-1 then
- local e=e.galaxy.systems[e.current_system+1][2].star
- return((string.upper(p(e.name,0))..i(e.name,1))..(" ("..e.type).." star)\n\n")..z[e.type]end
- local n,e=n(e.galaxy.systems[e.current_system+1][2].planets[t+1])local n=C[e.params.type]local e=(e.name.."\ntype: ")..e.params.type
- if n[1]then
- e=e.."\nclimate: "..n[1]end
- e=e.."\n\n"..n[2]return e
- end
- function o.prototype.update(t,l,e)t:update_camera(e)local o={}local e=t.ui_state
- for a=1,e and#e.animations or 0 do
- local e,r=n(t.ui_state.animations[a])if l>e.birth+e.dur then
- r(e.to)o[#o+1]=a
- else
- local n=(l-e.birth)/e.dur
- local t
- if e.easing=="outCubic"then
- t=1-(1-n)^3
- elseif e.easing=="inOutCubic"then
- t=n<.5 and 4*n*n*n or 1-(-2*n+2)^3/2
- else
- error("unhandled easing "..tostring(e.easing))end
- r(t*(e.to-e.from)+e.from)end
- end
- for e=#o,1,-1 do
- table.remove(t.ui_state.animations,o[e])end
- end
- function o.prototype.update_camera(e,r)local n=e.camera
- local t=e.camera_target
- n.rotY=180-e.camera_angle_x*180/math.pi
- n.rotZ=180-e.camera_angle_y*180/math.pi
- local l,o=-e.camera_angle_x,-e.camera_angle_y
- n.x=e.dist_to_target*-math.cos(o)*math.cos(l)n.y=e.dist_to_target*math.sin(o)n.z=e.dist_to_target*-math.cos(o)*math.sin(l)local l,o=e:pressed(keys.s)-e:pressed(keys.w),e:pressed(keys.d)-e:pressed(keys.a)local o={math.cos(math.rad(n.rotY))*l-math.sin(math.rad(n.rotY))*o,math.sin(math.rad(n.rotY))*l+math.cos(math.rad(n.rotY))*o}t={t[1]+e.dist_to_target/2*r*o[1],t[2],t[3]+e.dist_to_target/2*r*o[2]}n.x=n.x+t[1]n.y=n.y+t[2]n.z=n.z+t[3]e.camera_target=t
- end
- function o.prototype.process_drag(e,a,t)local o=os.clock()local l,r=term.getSize()local l,t=e.camera_angle_x+10*a/l/math.pi,e.camera_angle_y+10*t/r/math.pi
- local n,r=n(e.camera_angle_y_limits)t=math.max(n,math.min(r,t))local l={birth=o-.05,dur=.2,from=e.camera_angle_x,to=l,easing="outCubic"}local t={birth=o-.05,dur=.2,from=e.camera_angle_y,to=t,easing="outCubic"}local n=e.ui_state.animations
- n[#n+1]={l,function(n)local n=n
- e.camera_angle_x=n
- return n
- end}local n=e.ui_state.animations
- n[#n+1]={t,function(n)local n=n
- e.camera_angle_y=n
- return n
- end}end
- function o.prototype.pressed(n,e)return n.pressed_keys[e]~=nil and 1 or 0
- end
- function o.prototype.set_up_galaxy_scene(e)local t={}local o={}e.clouds={}e.camera_angle_x=0
- e.camera_angle_y=.25*math.pi
- e.camera_angle_y_limits={-math.pi/4,.8*math.pi/2}e.dist_to_target=1000
- e.camera_target=e.galaxy.systems[e.current_system+1][1]e:update_camera(0)for l=0,#e.galaxy.systems-1 do
- local n=e.galaxy.systems[l+1]local i=n[1][1]local a=n[1][2]local r=n[1][3]local n=n[2]t[#t+1]=e.frame:newObject(n.star.model,i,a,r)o[#o+1]=l
- end
- e.objects=t
- e.object_names=o
- end
- function o.prototype.set_up_system_scene(e)local t,a=n(e.galaxy.systems[e.current_system+1])local o=a.planets
- local r={}local t={}local l={}local i={}t[#t+1]=e.frame:newObject(a.star.model,0,0,0)l[#l+1]=-1
- for a=0,#o-1 do
- local o=o[a+1]local s=o[1][1]local d=o[1][2]local c=o[1][3]local u=o[2].model
- local o=o[2].atmo
- t[#t+1]=e.frame:newObject(u,s,d,c)l[#l+1]=a
- if o then
- for t=1,#o do
- local n,t=n(o[t])r[#r+1]={n,e.frame:newObject(t,s,d,c)}i[#i+1]=a
- end
- end
- end
- for n=0,#r-1 do
- t[#t+1]=r[n+1][2]end
- e.objects=t
- e.object_names=f(l,i)e.clouds=r
- e.camera_target={0,0,0}e.dist_to_target=a.star.radius*2
- e.camera_angle_y_limits={.95*-math.pi/2,.95*math.pi/2}end
- function o.prototype.load_music(l)t"loading music"local n,e=pcall(m.download,"https://cc.viluon.me/pg-music/index.lua")if not n then
- print("could not download soundtrack information! "..(e or""))return
- end
- local n=load(e,"index.lua","bt",getfenv(1))local e={}for t,n in ipairs(n())do
- local t=n.name
- local o=n.url
- local t,n=string.match(t,"^(.-)%s%-%s(.*)$")if t and n then
- e[#e+1]=c(a,t,n,o)end
- end
- l.tracks=e
- end
- function o.prototype.build_soundtrack_ui(e,o)t()local r=string.char(16).." "local l=string.char(4).." "local t={}local function c(e,t,n)local t=t and l or r
- local n=(t..i(e.." ",n+1))..i(e,0,n)local e=o:getSize()-3
- return i(n,0,e)end
- local function d(a,e,r)local t=t[e+1]local l,i,o,n=n(t)local n=r or n
- local e=a.playing==e
- l:setText(c(o,e,n)):setForeground(e and colours.white or colours.lightGrey)t[4]=n
- end
- local s=o:addButton():setText(""):setHorizontalAlign("center"):setSize("parent.w",1):setForeground(colours.pink)local c=2
- for n=0,#e.tracks-1 do
- local l=e.tracks[n+1]local l=((l.name.." (")..l.artist)..")"local a=o:addButton():setSize("parent.w - 2",1):setText(r..i(l,0,o:getSize()-5)):setHorizontalAlign("left")local i=a.setPosition
- local r=c
- c=r+1
- local r=i(a,2,r)local o=o:addAnimation():setObject(r)t[#t+1]={r,o,l,0}for t=0,#l do
- o:add(function()return d(e,n,t)end):wait(.15)end
- o:wait(5):add(function()return o:play()end):play()r:onClick(function()if e.playing then
- os.queueEvent("music:stop",e.playing)end
- if e.playing~=n then
- os.queueEvent("music:play",n)end
- v(t,function(t,t,n)return d(e,n)end)return true
- end)end
- return s
- end
- function o.prototype.draw_labels(e)term.setBackgroundColour(colours.black)term.setTextColour(colours.lightGrey)for n=0,#e.objects-1 do
- local n=e.object_names[n+1]e:draw_label_for(n)end
- end
- function o.prototype.draw_label_for(e,a)local c,s,i=e.camera.x,e.camera.y,e.camera.z
- local r
- local o
- local t
- local l
- if a==-1 then
- local e=e.galaxy.systems[e.current_system+1][2].star
- r=e.name
- o,t,l=0,e.radius*.8,0
- elseif e.mode=="system"then
- local a,e=n(e.galaxy.systems[e.current_system+1][2].planets[a+1])r=e.name
- o,t,l=n(a)t=t+e.params.size*.8
- else
- local a,e=n(e.galaxy.systems[a+1])r=e.star.name
- o,t,l=n(a)t=t+(e.star.radius*.8+math.sqrt((o-c)^2+(t-s)^2+(l-i)^2)/40)end
- local a,n,i=n(d({c-o,s-t,i-l},10))o,t,l=o+a,t+n,l+i
- local n,a,i=e.frame:map3dTo2d(o,t,l)if i then
- n,a=math.floor(.5+n/2),math.floor(.5+a/3)local d=e.frame:getObjectIndexTrace(e.objects,{{x=n,y=a}})local c=d[1].objectIndex
- local d=d[1].depth
- if c then
- local r,e,n=e.camera.x,e.camera.y,e.camera.z
- local e=(o-r)^2+(t-e)^2+(l-n)^2
- i=e<d
- end
- if i then
- term.setCursorPos(math.floor(n-#r/2),a)term.write(r)end
- end
- end
- local a={"harp","basedrum","bass","snare","hat","guitar","flute","bell","chime","xylophone","iron_xylophone","cow_bell","didgeridoo","bit","banjo","pling"}local function l(e,n)n=n/2
- local function t(e,o,t)local l=math.sqrt(e*e+o*o+t*t)local n=n/l
- return n*e,n*o,n*t
- end
- local n={t(e.x1,e.y1,e.z1)}e.x1=n[1]e.y1=n[2]e.z1=n[3]local n={t(e.x2,e.y2,e.z2)}e.x2=n[1]e.y2=n[2]e.z2=n[3]local n={t(e.x3,e.y3,e.z3)}e.x3=n[1]e.y3=n[2]e.z3=n[3]end
- local function f(...)local e={...}return e[math.random(1,#e)]end
- local function p()t()local e={peripheral.find("speaker")}local e=n(e)if e then
- return e
- end
- local t,e=pcall(function()return{{_G.periphemu.create("left","speaker")}}end,nil)if not t then
- error("no speaker found, peripheral emulation not available: "..e)end
- local e,t=n(e[1])if not e then
- error("could not attach speaker: "..t)end
- local e={peripheral.find("speaker")}local e=n(e)return assert(e)end
- local function r(e)local t=p()local e,n=F.load(e)if not e then
- error("could not load soundtrack: "..n)end
- local n=e.delay
- local o=e.layers
- local t=t.playNote
- for l=0,#e-1 do
- local e=e[l+1]for e,n in pairs(e)do
- local e=a[e+1]for n,l in pairs(n)do
- t(e,o[n+1].volume/100,l)end
- end
- sleep(n)end
- end
- local function a(e)local n=p()y.play_dfpwm(n,e)end
- local function i(e)if b(e,".dfpwm")then
- return a(e)end
- if b(e,".nbs")then
- return r(e)end
- error("unknown extension in "..e)end
- local function i(e)local o=u.models:icosphere({res=e.resolution,colors={-1,e.cloud_colour,e.cloud_colour,e.cloud_colour,e.cloud_colour,e.cloud_colour,-1}})local t=o
- local r=e.planet_size*1.1
- local n={}for o=0,#t-1 do
- local t=t[o+1]if t.c~=-1 and math.random()<e.cloud_cover then
- l(t,r)else
- n[#n+1]=o+1
- end
- end
- for e=#n-1,0,-1 do
- table.remove(t,n[e+1])end
- local e=math.random()<.3 and-1 or 1
- return{{e/math.random(4,32),o}}end
- local r={[e.ClassB]={size=5,rot=1,primary=colours.white,alt=colours.lightBlue},[e.ClassA]={size=5,rot=12,primary=colours.white,alt=colours.lightGrey,ratio=4},[e.ClassF]={size=5,rot=1,primary=colours.yellow,alt=colours.white},[e.ClassG]={size=5,rot=1,primary=colours.yellow,alt=colours.white},[e.ClassK]={size=5,rot=1,primary=colours.yellow,alt=colours.orange},[e.ClassM]={size=5,rot=1,primary=colours.red,alt=colours.black,ratio=4},[e.ClassMRedGiant]={size=15,rot=1,primary=colours.red,alt=colours.black,ratio=4},[e.ClassTBrownDwarf]={size=5,rot=1,primary=colours.red,alt=colours.black,ratio=4}}local function D(e)local e=r[e]local o=e.primary
- local a=e.alt
- local t=e.size
- local n=e.rot
- local e=e.ratio
- n=n*(math.random(.8,1.2)*(math.random()<.2 and 1 or-1))if not e then
- e=2
- end
- local r=u.models:icosphere({res=3,colors={o}})local t=t+math.random(2,5)local o=r
- for r=0,#o-1 do
- local n=o[r+1]if r%e==0 then
- n.c=a
- end
- l(n,t)end
- return t,r,n
- end
- local function b(n)local e=u.models:icosphere({res=n.resolution,colors={0}})local r=e
- local a=n.planet_size*1.1
- local o={}local t={}for n in pairs(e)do
- o[n]=e[n]t[n]=e[n]end
- for e=0,#r-1 do
- local e=r[e+1]if e.c~=-1 and math.random()<.3 then
- if math.floor(e.y1)%2==0 then
- e.c=n.cloud_colour
- l(e,a*.9)o[#o+1]=e
- else
- e.c=n.alt_cloud_colour
- l(e,a*1.05)t[#t+1]=e
- end
- end
- end
- return{{1/math.random(4,32),o},{-1/math.random(4,32),t}}end
- local function C(e)local n=e.ice_cap_north and({-1})or({})for t=1,e.water_level do
- local t=t==math.floor(.5+e.water_level/2)local e=e.type=="arctic"and t and e.landmass_colour or e.water_colour
- n[#n+1]=e
- end
- if e.ice_cap_south then
- n[#n+1]=-1
- end
- local o=u.models:icosphere({res=e.resolution,colors=n})local t=false
- local n=o
- for o=0,#n-1 do
- local n=n[o+1]l(n,e.size)if n.c~=-1 and math.random()<e.landmass*(t and .5 or .1)then
- if e.landmass_alt_colour then
- n.c=math.random()<.8 and e.landmass_colour or e.landmass_alt_colour
- else
- n.c=e.landmass_colour
- end
- t=true
- else
- if n.c==-1 then
- n.c=colours.white
- end
- t=false
- end
- end
- local n={resolution=e.resolution+1,planet_size=e.size,cloud_colour=e.atmosphere_colour or colours.white,alt_cloud_colour=e.type=="gas giant"and e.landmass_colour or nil,cloud_cover=e.atmosphere_density or .1}local e=e.type=="gas giant"and b(n)or i(n)return{planet_model=o,atmo=e,atmo_params=n}end
- local l={arid={.8,3.5},desert={.8,3.5},savanna={.8,3.5},alpine={.8,3.5},arctic={.8,3.5},tundra={.8,3.5},continental={.8,3.5},ocean={.8,3.5},tropical={.8,3.5},asteroid={.1,.6},["barren world"]={.8,5},["frozen world"]={.8,5},["gas giant"]={4,9}}local a={arid={water_level={3,6},water_colour=colours.yellow,landmass={1,2},landmass_colour=colours.brown,landmass_alt_colour=colours.green,ice_cap_north=.3,ice_cap_south=.2,atmosphere_density={.07,.1},atmosphere_colour=colours.white},desert={water_level={3,6},water_colour=colours.yellow,landmass={1,2},landmass_colour=colours.brown,landmass_alt_colour=colours.orange,ice_cap_north=.05,ice_cap_south=.03,atmosphere_density={.02,.06},atmosphere_colour=colours.white},savanna={water_level={3,6},water_colour=colours.yellow,landmass={1,2},landmass_colour=colours.green,landmass_alt_colour=colours.blue,ice_cap_north=.5,ice_cap_south=.3,atmosphere_density={.08,.12},atmosphere_colour=colours.white},alpine={water_level={3,6},water_colour=colours.lightBlue,landmass={3,4},landmass_colour=colours.green,landmass_alt_colour=colours.white,ice_cap_north=1,ice_cap_south=1,atmosphere_density={.08,.12},atmosphere_colour=colours.white},arctic={water_level={5,8},water_colour=colours.white,landmass={2,3},landmass_colour=colours.brown,landmass_alt_colour=colours.green,ice_cap_north=1,ice_cap_south=1,atmosphere_density={.08,.12},atmosphere_colour=colours.white},tundra={water_level={3,5},water_colour=colours.grey,landmass={2,3},landmass_colour=colours.green,landmass_alt_colour=colours.lightBlue,ice_cap_north=1,ice_cap_south=1,atmosphere_density={.08,.12},atmosphere_colour=colours.white},continental={water_level={5,8},water_colour=colours.blue,landmass={1.4,2},landmass_colour=colours.green,landmass_alt_colour=colours.yellow,ice_cap_north=1,ice_cap_south=1,atmosphere_density={.08,.12},atmosphere_colour=colours.white},ocean={water_level={5,8},water_colour=colours.blue,landmass={.4,1},landmass_colour=colours.green,landmass_alt_colour=colours.cyan,ice_cap_north=.2,ice_cap_south=.1,atmosphere_density={.08,.12},atmosphere_colour=colours.white},tropical={water_level={5,8},water_colour=colours.cyan,landmass={2,3},landmass_colour=colours.green,landmass_alt_colour=colours.blue,ice_cap_north=.1,ice_cap_south=.05,atmosphere_density={.08,.12},atmosphere_colour=colours.white},asteroid={water_level={2,4},water_colour=colours.grey,landmass={1,5},landmass_colour=colours.brown,landmass_alt_colour=colours.lightGrey,ice_cap_north=0,ice_cap_south=0,atmosphere_density={0,0},atmosphere_colour=colours.white},["barren world"]={water_level={5,8},water_colour=colours.brown,landmass={.3,3},landmass_colour=colours.grey,landmass_alt_colour=colours.red,ice_cap_north=0,ice_cap_south=0,atmosphere_density={0,0},atmosphere_colour=colours.white},["frozen world"]={water_level={5,8},water_colour=colours.lightGrey,landmass={2,5},landmass_colour=colours.lightBlue,landmass_alt_colour=colours.white,ice_cap_north=1,ice_cap_south=1,atmosphere_density={.01,.05},atmosphere_colour=colours.white},["gas giant"]={water_level={5,8},water_colour=colours.green,landmass={2,5},landmass_colour=colours.grey,landmass_alt_colour=colours.lightGrey,ice_cap_north=0,ice_cap_south=0,atmosphere_density={.2,.4},atmosphere_colour=colours.green}}local function z(t)local r=t~="asteroid"and t~="barren world"and t~="frozen world"local o=math.random(n(l[t]))local e=a[t]local e={type=t,size=o,resolution=math.max(2,math.ceil(math.log(o*2))),water_level=math.random(n(e.water_level)),water_colour=e.water_colour,landmass=math.random(n(e.landmass)),landmass_colour=e.landmass_colour,landmass_alt_colour=e.landmass_alt_colour,ice_cap_north=math.random()<e.ice_cap_north,ice_cap_south=math.random()<e.ice_cap_south,atmosphere_density=math.random(n(e.atmosphere_density)),atmosphere_colour=e.atmosphere_colour}return r,e
- end
- local function l()local e={{"The Moon",false,{type="barren world",size=.4,resolution=2,water_level=1,water_colour=colours.lightGrey,landmass=1,landmass_colour=colours.grey}},{"Earth",true,{type="continental",size=1.3,resolution=3,water_level=7,water_colour=colours.blue,landmass=1.4,landmass_colour=colours.green,landmass_alt_colour=colours.yellow,ice_cap_north=true,ice_cap_south=true}},{"Mars",true,{type="frozen world",size=.9,resolution=3,water_level=5,water_colour=colours.red,landmass=1,landmass_colour=colours.grey,ice_cap_north=true,ice_cap_south=true,atmosphere_density=.03,atmosphere_colour=colours.lightGrey}}}return s(e,function(n,e)local n
- local t
- local o
- o=e[1]t=e[2]n=e[3]local e=C(n)local r=e.planet_model
- local l=e.atmo
- local e=e.atmo_params
- return{name=o,params=n,atmo_params=e,model=r:toLoD({qualityHalvingDistance=20}),clouds=t and s(l,function(e,n)local e
- local t
- t=n[1]e=n[2]return{t,e:toLoD({qualityHalvingDistance=30})}end)or nil}end)end
- local function b(e)e.frame:setCamera(e.camera)e.frame:setFoV(60)e.frame:highResMode(true)e.frame:setBackgroundColor(colours.black)local f=g()local u=os.clock()local s=-1
- local n=false
- local c,a,i,d=0,0,0,0
- while true do
- if not n then
- os.queueEvent("end_of_queue")n=true
- end
- local o=os.pullEvent()if o=="end_of_queue"then
- n=false
- end
- local o=os.clock()local l=e
- local h=l.clouds
- local r=l.objects
- local n=l.frame
- local l=l.camera
- n:setCamera(0,0,0,l.rotX,l.rotY,l.rotZ)e:draw_starfield(f)n:setCamera(l)if e.trace_overlay then
- n:drawBuffer()local t,e=term.getSize()term.setBackgroundColour(colours.black)term.setTextColour(colours.white)for e=1,e do
- for t=1,t do
- local n=n:getObjectIndexTrace(r,{{x=t,y=e}})[1]local n=n.objectIndex
- if n then
- term.setCursorPos(t,e)term.write(tostring(n))end
- end
- end
- else
- local l=os.clock()v(h,function(n,e)return e[2]:setRot(nil,e[1]*o)end)for n=1,#r do
- local t=e.object_names[n]if t==-1 then
- r[n]:setRot(nil,e.galaxy.systems[e.current_system+1][2].star.rotation_speed/100*o)break
- end
- end
- local o=os.clock()n:drawObjects(r)local t=os.clock()n:drawBuffer()local n=os.clock()e:draw_labels()local e=os.clock()c=c+(o-l)a=a+(t-o)i=i+(n-t)d=d+(e-n)end
- if o-s>5 then
- t("render stats: "..string.format("r %.2f d %.2f b %.2f l %.2f",c,a,i,d))s=o
- end
- u=o
- end
- end
- local function l(n,e)return{n[2]*e[3]-n[3]*e[2],n[3]*e[1]-n[1]*e[3],n[1]*e[2]-n[2]*e[1]}end
- local function r(n,e)return{n[1]-e[1],n[2]-e[2],n[3]-e[3]}end
- local function a(n,e,t)local e=d(r(n,e))local t=d(l(t,e))local o=d(l(e,t))return{t[1],t[2],t[3],0,o[1],o[2],o[3],0,e[1],e[2],e[3],0,n[1],n[2],n[3],1}end
- local function r(e)local o,n=pcall(p)local l=o and n or nil
- t("speaker setup",o,n)if l then
- e.speaker_available=true
- else
- local e=e.ui_state
- if e~=nil then
- e.speaker_button:setText("no speaker")end
- end
- while true do
- local o,n=coroutine.yield()if not l then
- e.playing=nil
- else
- if o=="music:play"then
- e.playing=n
- local o=e.tracks[n+1]t("playing",n,(o or({})).name)if not o.data then
- o.data=m.download(o.url)end
- y.play_dfpwm(l,o.data)e.playing=nil
- if n<#e.tracks-1 then
- os.queueEvent("music:play",n+1)end
- end
- end
- end
- end
- local function F(o)o:change_mode("system")local p=0
- local m=0
- local a={{0,0,coroutine.create(function()return r(o)end)},{0,0,coroutine.create(function()return b(o)end)}}local e=#a
- local c=nil
- local w=os.clock()local h=w
- local l=""local b=h
- local s=0
- local g=0
- while#a>=e do
- local e=os.clock()local _,r,f,u,C,k=os.pullEvent()local y
- local v
- local x
- local i
- local d
- local l=os.clock()local e=l-e
- p=p+e
- m=math.max(m,e)local S=l-h
- repeat
- local t=_
- local e=t=="mouse_click"if e then
- y,i,d=r,f,u
- c={i,d}o:process_click(l,i,d)o.last_mouse_click=l
- break
- end
- e=e or t=="mouse_drag"if e then
- y,i,d=n({r,f,u})v,x=n(assert(c))c={i,d}i,d=i-v,d-x
- o:process_drag(i,d)break
- end
- e=e or t=="mouse_up"if e then
- y,i,d=r,f,u
- c=nil
- break
- end
- e=e or t=="mouse_scroll"if e then
- o.dist_to_target=o.dist_to_target*(1+r/10)break
- end
- e=e or t=="key"if e then
- o.pressed_keys[r]=true
- break
- end
- e=e or t=="key_up"if e then
- o.pressed_keys[r]=nil
- break
- end
- e=e or t=="char"if e then
- if r=="q"then
- return
- end
- if r=="t"then
- o.trace_overlay=not o.trace_overlay
- end
- if r=="e"or r=="E"then
- o:change_mode(o.mode=="galaxy"and"system"or"galaxy")end
- break
- end
- do
- break
- end
- until true
- o:update(l,S)local n={}local i=l
- for e=0,#a-1 do
- local l=a[e+1][3]local s,r,o,o=coroutine.resume(l,_,r,f,u,C,k)local o=os.clock()local c,d=a[e+1],1
- c[d]=c[d]+(o-i)a[e+1][2]=math.max(a[e+1][2],o-i)i=o
- if not s then
- t("thread",e,"crashed",r)error(r)end
- if coroutine.status(l)=="dead"then
- n[#n+1]=e
- end
- end
- for e=#n-1,0,-1 do
- table.remove(a,n[e+1]+1)end
- if l-b>1 then
- g=s/(l-b)b=l
- s=0
- T(l,w,p,g,m,a)end
- s=s+1
- term.setCursorPos(1,1)term.write(string.format("%.2f fps, in %s, curr sys: %d",g,o.galaxy.systems[o.current_system+1][2].star.name,o.current_system))h=l
- end
- end
- local function p(l,r)local n={}local o={}local t
- local e
- e=l:addFrame():setSize("0.33 * parent.w","parent.h"):setPosition("parent.w",1):onGetFocus(function()local n=l:getSize()-e:getSize()+1
- o[#o+1]={{birth=os.clock(),dur=.5,from=e:getPosition(),to=n,easing="inOutCubic"},function(n)return e:setPosition(math.floor(n),select(2,e:getPosition()))end}return true
- end):onLoseFocus(function()o[#o+1]={{birth=os.clock(),dur=.5,from=e:getPosition(),to=l:getSize(),easing="inOutCubic"},function(n)return e:setPosition(math.floor(n),select(2,e:getPosition()))end}local e=t:getAll()for n=1,#e do
- local e=e[n]local o=e.fgCol==colours.white and colours.lightGrey or e.fgCol
- t:editItem(n,e.text,e.bgCol,o)end
- return true
- end)t=e:addList():setSize(1,"parent.h"):setPosition(1,1):setBackground(colours.black):setForeground(colours.lightGrey):setSelectedItem(colours.black,colours.lightGrey):onChange(function()v(n,function(n,e)local n
- local t=e[1]n=e[2]return n:hide()end)local o=t:getItemIndex()if o then
- n[o][2]:show()end
- local n=t:getAll()for e=1,#n do
- t:editItem(e,n[e].text,n[e].bgCol,e==o and colours.white or colours.lightGrey)end
- return true
- end):addItem(string.char(15)):addItem("i"):addItem(string.char(215))local a=e:addFrame():setPosition(2,1):setSize("parent.w","parent.h")local d=r:build_soundtrack_ui(a)n[#n+1]={"music",a}local a=e:addFrame():setPosition(2,1):setScrollable(true):setSize("parent.w","parent.h"):hide()local i=a:addLabel():setText(((((((((((((((((((((((("Space. The final fun tier. (That's a quote from Wall-E.) ".."").."Eventually, all things must go to space. The Brave Toaster, The ").."").."Leprechaun, Air Buddies. Space represents infinite, boundless ").."").."possibilities, but for ComputerCraft, it actually meant more ").."").."limitations. You no longer have interaction with the Minecraft ").."").."world. Custom shells and scripts are gone. The entire game is ").."").."laser-focused on an immersive emulator experience. You won't run ").."").."this thing on a turtle. But the beauty of Planet Garden lies in ").."").."its acceptance of the boundaries it's been given. Instead of ").."").."pretending ComputerCraft is something it's not, it relies on its ").."").."constraints to define an art style that fits on a 51 by 19 ").."").."terminal. The result is a glitchy, low-poly look coloured with ").."").."CC's vanilla palette."):setPosition(2,2)n[#n+1]={"info",a}local e=e:addFrame():setPosition(2,1):setSize("parent.w","parent.h"):hide()e:addButton():setSize("parent.w - 1",1):setPosition(1,2):setText("save")e:addButton():setSize("parent.w - 1",1):setPosition(1,4):setText("load")e:addButton():setSize("parent.w - 1",1):setPosition(1,6):setText("quit"):onClick(function()h.stop()return true
- end)n[#n+1]={"save",e}r.ui_state=c(_,t,n,i,d,o,l)end
- local function g(a,o,r)local n,e=n(B[r])local n=o>=n and o<=e
- local e
- if not n or math.random()<.2 then
- if o>35 then
- e=f("asteroid","barren world","frozen world","gas giant")else
- e=f("asteroid","barren world")end
- else
- e=f("arid","desert","savanna","alpine","arctic","tundra","continental","ocean","tropical")end
- local u,l=z(e)local n=C(l)local c=n.planet_model
- local d=n.atmo
- local i=n.atmo_params
- local n=math.log(1+l.size)*20
- local d=u and s(d,function(t,e)local t
- local o
- o=e[1]t=e[2]return{o,t:toLoD({qualityHalvingDistance=n})}end)or nil
- t(((((((("generated planet "..a).." (")..e)..", ")..string.format("%.1f",o)).." far from a ")..r)..")")return{name=a,params=l,atmo_params=i,model=c:toLoD({qualityHalvingDistance=n}),atmo=d}end
- local function m(e)if e==nil then
- e={"C","V","C","V"," ","GLN"}end
- local d={"a","e","i","o","u"}local a={"ai","au","aw","ay","ea","ee","ei","eu","ew","ey","ie","oi","oo","ou","ow","oy"}local i={"b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z"}local r={"bl","br","ch","ck","cl","cr","dr","fl","fr","gh","gl","gr","ng","ph","pl","pr","qu","sc","sh","sk","sl","sm","sn","sp","st","sw","th","tr","tw","wh","wr"}local o={"nth","sch","scr","shr","spl","spr","squ","str","thr"}local l={"Alpha","Beta","Gamma","Delta","Epsilon","Zeta","Eta","Theta","Iota","Kappa","Lambda","Mu","Nu","Xi","Omicron","Pi","Rho","Sigma","Tau","Upsilon","Phi","Chi","Psi","Omega"}local c={"Major","Minor"}local s={"er","ury","ion","opa","asi","esi","isi","osi","usi","as","es","is","os","us","on","ov","uv","ald","eld","ild","old","uld","alt","elt","ilt","olt","ult","alv","elv","ilv","olv","ulv","agh","egh","igh","ogh","ugh","ayt","eyt","iyt","oyt","uyt","and","end","ind","ond","und"}local f={"@","#","-"}local n=""for e,u in ipairs(e)do
- repeat
- local t=u
- local e=t=="V"if e then
- n=n..d[math.random(0,#d-1)+1]break
- end
- e=e or t=="VD"if e then
- n=n..a[math.random(0,#a-1)+1]break
- end
- e=e or t=="C"if e then
- n=n..i[math.random(0,#i-1)+1]break
- end
- e=e or t=="CD"if e then
- n=n..r[math.random(0,#r-1)+1]break
- end
- e=e or t=="CT"if e then
- n=n..o[math.random(0,#o-1)+1]break
- end
- e=e or t=="GLN"if e then
- n=n..l[math.random(0,#l-1)+1]break
- end
- e=e or t=="MN"if e then
- n=n..c[math.random(0,#c-1)+1]break
- end
- e=e or t=="FA"if e then
- n=n..s[math.random(0,#s-1)+1]break
- end
- e=e or t=="S"if e then
- n=n..f[math.random(0,#f-1)+1]break
- end
- do
- n=n..u
- break
- end
- until true
- end
- return n
- end
- local function d(n)local t={{1000,"M"},{900,"CM"},{500,"D"},{400,"CD"},{100,"C"},{90,"XC"},{50,"L"},{40,"XL"},{10,"X"},{9,"IX"},{5,"V"},{4,"IV"},{1,"I"}}local e=""for o,t in ipairs(t)do
- local o=t[1]local t=t[2]while n>=o do
- n=n-o
- e=e..t
- end
- end
- return e
- end
- local function r()local function e(n,o,t)local e
- if math.random()<n then
- e=o
- else
- e=t
- end
- return e
- end
- local function l(t)local n={}local o=0
- for e=1,#t do
- local e=string.sub(t,e,e)local t=(n[e]or 0)+1
- if({string.find(e,"[aeiou]")})==nil then
- o=math.max(o,t)end
- n[e]=t
- end
- local function e(e)return n[e]or 0
- end
- local function n(e)return({string.find(t,e)})~=nil and 1 or 0
- end
- return-o-e("w")*e("x")-e("x")*e("z")+n("ri")+n("arr")-2*n("^s")end
- local n={}for t=1,5 do
- local e=e(.5,{e(.5,"CD","C"),e(.5,"VD","V"),"C",e(.5,"FA","")},{"CT","V","C",e(.5,"V","VD")})n[#n+1]=string.lower(m(e))end
- table.sort(n,function(e,n)return l(e)>l(n)end)return n[1]end
- local function i()local e=f(n(k(e)))local n,o,t=D(e)local l={type=e,name=r(),rotation_speed=t,model=o:toLoD({qualityHalvingDistance=130,variantCount=6}),radius=n}local t={}for r=1,math.random(0,5)do
- local n=n+6*math.random(0,7)local o=2*math.pi*math.random()local o,a=n*math.sin(o),n*math.cos(o)local l=(l.name.." ")..d(r)t[#t+1]={{o,math.random(-.5,.5),a},g(l,n,e)}end
- return c(x,l,t)end
- local function l()t"generating galaxy"local e={}local o=20
- local l,r=term.getCursorPos()for a=1,o do
- local t=100*math.random(2,10)local n=2*math.pi*math.random()local n,t=t*math.sin(n),t*math.cos(n)e[#e+1]={{n,math.random(-4,4),t},i()}sleep(nil)term.setCursorPos(l,r)term.clearLine()term.write(string.format("generating galaxy %.2f%%",100*a/o))end
- print()t"done"return c(w,e)end
- local function e()local t=u.newFrame()local n={x=0,y=0,z=0,rotX=0,rotY=0,rotZ=0}local e=l()return c(o,"galaxy",-1,{},{},{},t,n,{0,0,0},0,0,{0,0},2,{},{},nil,false,e,0,false)end
- local function r(...)t("starting Planet Garden on",tostring(_HOST),pcall(nil,os.date))local l=h.createFrame():setTheme({FrameBG=colours.black,FrameText=colours.white,ButtonBG=colours.black,ButtonText=colours.white,LabelBG=false,LabelText=colours.white})local e=e()local n
- n=l:addProgram():setSize("parent.w - 1","parent.h"):execute(function()return F(e)end):onDone(function()t"program is done, stopping"h.stop()end):onError(function(n,e)error(e)end):onResize(function()local o,n=n:getSize()t((("resized game window to "..tostring(o)).." by ")..tostring(n))e.frame:setSize(1,1,o,n)return true
- end)e:load_music()p(l,e)n:setFocus(true)os.queueEvent("begin")t"starting basalt loop"h.autoUpdate()end
- local n,e=pcall(r,...)if not n then
- t("game crashed with "..tostring(e))print(e)read()end
- return S
- end,["nbs"]=function(...)local r={}local function i()os.queueEvent("yield")os.pullEvent("yield")end
- local function o(e)return e.read()+e.read()*256
- end
- _G.readShort=o
- local function l(e)return e.read()+e.read()*256+e.read()*65536+e.read()*16777216
- end
- local function t(t)local e,n=""local o=l(t)for o=1,o do
- n=t.read()if not n then
- break
- end
- e=e..string.char(n)end
- return e
- end
- local function n(n,t)local e=""for t=0,t-1 do
- e=e..string.char(bit32.band(bit32.rshift(n,t*8),255))end
- return e
- end
- local function e(t,e)t.write(n(e,2))end
- local function a(e,t)e.write(n(t,4))end
- local function e(n,e)a(n,#e)n.write(e)end
- local function s(n)local e={}e.lenght=o(n)if e.lenght>0 then
- e.nbs_version=0
- e.height=o(n)e.name=t(n)if e.name==""then
- e.name="Untitled"end
- e.author=t(n)if e.author==""then
- e.author="Unknown"end
- e.original_author=t(n)if e.original_author==""then
- e.original_author="Unknown"end
- e.description=t(n)e.tempo=o(n)/100
- e.autosave=n.read()e.autosave_duration=n.read()e.time_signature=n.read()e.minutes_spent=l(n)e.left_clicks=l(n)e.right_clicks=l(n)e.blocks_added=l(n)e.blocks_removed=l(n)e.filename=t(n)else
- e.nbs_version=n.read()e.vanilla_instruments=n.read()e.lenght=o(n)e.height=o(n)e.name=t(n)if e.name==""then
- e.name="Untitled"end
- e.author=t(n)if e.author==""then
- e.author="Unknown"end
- e.original_author=t(n)if e.original_author==""then
- e.original_author="Unknown"end
- e.description=t(n)e.tempo=o(n)/100
- e.autosave=n.read()e.autosave_duration=n.read()e.time_signature=n.read()e.minutes_spent=l(n)e.left_clicks=l(n)e.right_clicks=l(n)e.blocks_added=l(n)e.blocks_removed=l(n)e.filename=t(n)e.looping=n.read()e.max_looping=n.read()e.loop_start=o(n)end
- return e
- end
- local function d(n,e)local n=o(n)for n=1,n-1 do
- e[#e+1]={}end
- return n>0
- end
- local function c(e)local l={}local a=0
- local r=o(e)while r>0 do
- a=a+r
- local t=e.read()+1
- if t>16 then
- return nil,"(v5) Can't convert custom instruments"end
- local n=e.read()-33
- local i=e.read()local i=e.read()local i=o(e)if n<0 or n>24 then
- return nil,"(v5) Notes must be in Minecraft's 2 octaves ("..n..")"end
- if not l[t]then
- l[t]={}end
- l[t][a]=n
- r=o(e)end
- return l
- end
- function r.saveSong(t,n)local e=fs.open(n,"w")if e then
- e.write(textutils.serialize(t))e.close()return true
- end
- return false,"Error opening file "..n
- end
- function r.saveSongNBS(e,e)end
- function r.load(r,l)local e=fs.open(r,"rb")if e then
- if l then
- print"Reading header..."end
- local n={}local o=s(e)n.header=o
- n.name=o.name
- n.author=o.author
- n.original_author=o.original_author
- n.lenght=o.lenght/o.tempo
- n.delay=1/o.tempo
- if l then
- print"Reading ticks..."end
- if o.nbs_version==0 then
- while d(e,n)do
- local t,o=c(e,n)if t then
- table.insert(n,t)else
- e.close()return nil,o
- end
- i()end
- pcall(function()local l={}for o=1,o.height do
- table.insert(l,{name=t(e),volume=e.read()+0})end
- n.layers=l
- local o={}for l=1,e.read()+0 do
- o[#o+1]={name=t(e),file=t(e),pitch=e.read()+0,key=(e.read()+0)~=0}end
- n.instruments=o
- end)else
- while d(e,n)do
- local t,o=c(e,n)if t then
- table.insert(n,t)else
- e.close()return nil,o
- end
- i()end
- pcall(function()local l={}for o=1,o.height do
- table.insert(l,{name=t(e),lock=e.read(),volume=e.read(),pan=e.read()})end
- n.layers=l
- local o={}for l=1,e.read()+0 do
- o[#o+1]={name=t(e),file=t(e),pitch=e.read()+0,key=(e.read()+0)~=0}end
- n.instruments=o
- end)end
- e.close()return n
- end
- return nil,"Error opening file "..r
- end
- return r
- end,["kernel"]=function(...)local a={}local u,s,h=string.byte,bit32.band,bit32.arshift
- local e=10
- local i=2^e
- local o=2^(e-1)local d=2^(e-8+1)local function f()local n,r,l=0,0,false
- return function(t)local e=t and 127 or-128
- local o=(r*(e-n)+o)/i
- local o=n+(o-o%1)if o==n and o~=e then
- o=o+(t and 1 or-1)end
- local a=t==l and i-1 or 0
- local e=r
- if e~=a then e=e+(t==l and 1 or-1)end
- if e<d then e=d end
- n,r,l=o,e,t
- return n
- end
- end
- local function c()local r=f()local e=0
- local i,d=0,false
- return function(n)local a,o={},0
- for t=1,#n do
- local l=u(n,t)for n=1,8 do
- local t=s(l,1)~=0
- local n=r(t)local r=n
- if t~=d then
- local e=(n+i+1)/2
- r=e-e%1
- end
- i,d=n,t
- local n=((r-e)*140+128)/256
- e=e+(n-n%1)o=o+1
- a[o]=e
- l=h(l,1)end
- end
- return a
- end
- end
- function a.play_dfpwm(e,n)local o=c()local l=string.sub
- for t=1,#n,16*1024 do
- local n=l(n,t,t+16*1024-1)local n=o(n)while not e.playAudio(n)do
- local n=coroutine.yield()if n=="music:stop"then
- e.stop()return
- end
- end
- end
- end
- return a
- end,["basalt.basalt"]=function(...)local r={}local t=true local o=a
- local l=function(e)for t,n in pairs(r)do
- if(type(n)=="table")then for t,n in pairs(n)do if(t==e)then
- return n()end end else if(t==e)then return n()end end end return o(e)end
- local n=function(e)if(e~=nil)then return r[e]end return r end
- r["module"]=function(...)return
- function(e)local e,n=pcall(l,e)return e and n or nil end end
- r["loadObjects"]=function(...)local e={}if(t)then
- for n,t in pairs(n("objects"))do e[n]=t()end return e end local t=table.pack(...)local n=fs.getDir(t[2]or"Basalt")if(n==nil)then
- error("Unable to find directory "..t[2].." please report this bug to our discord.")end for t,n in
- pairs(fs.list(fs.combine(n,"objects")))do
- if(n~="example.lua")then local n=n:gsub(".lua","")e[n]=l(n)end end return e end
- r["main"]=function(...)local z=l("basaltEvent")()local F=l("Frame")local h=l("theme")local e=l("utils")local D=l("basaltLogs")local A=e.uuid
- local x=e.createText local H=e.tableCount local y=300 local m=50 local o=term.current()local P="1.6.5"local w=fs.getDir(table.pack(...)[2]or"")local p,s,d,i,f,t={},{},{},{},{},{}local n,l,a,c local e={}if
- not term.isColor or not term.isColor()then
- error('Basalt requires an advanced (golden) computer to run.',0)end local u={}for n,e in
- pairs(colors)do if(type(e)=="number")then
- u[n]={o.getPaletteColor(e)}end end
- local function b()c=false o.clear()o.setCursorPos(1,1)for n,e in pairs(colors)do if(type(e)=="number")then
- o.setPaletteColor(e,colors.packRGB(table.unpack(u[n])))end end end
- local function u(n)o.clear()o.setBackgroundColor(colors.black)o.setTextColor(colors.red)local t,l=o.getSize()if(e.logging)then D(n,"Error")end local n=x("Basalt error: "..n,t)local e=1 for t,n in pairs(n)do
- o.setCursorPos(1,e)o.write(n)e=e+1 end o.setCursorPos(1,e+1)c=false end
- local function k(e)assert(e~="function","Schedule needs a function in order to work!")return function(...)local e=coroutine.create(e)local o,n=coroutine.resume(e,...)if(o)then table.insert(t,{e,n})else u(n)end end end local T=function(n,e)f[n]=e end
- local C=function(e)return f[e]end local E=function(e)h=e end
- local v=function(e)return h[e]end
- local M={getDynamicValueEventSetting=function()return e.dynamicValueEvents end,getMainFrame=function()return n end,setVariable=T,getVariable=C,getTheme=v,setMainFrame=function(e)n=e end,getActiveFrame=function()return l end,setActiveFrame=function(e)l=e end,getFocusedObject=function()return a end,setFocusedObject=function(e)a=e end,getMonitorFrame=function(e)return
- d[e]or i[e][1]end,setMonitorFrame=function(t,e,o)if(n==e)then
- n=nil end
- if(o)then i[t]={e,sides}else d[t]=e end if(e==nil)then i[t]=nil end end,getBaseTerm=function()return
- o end,schedule=k,stop=b,newFrame=F,getDirectory=function()return w end}local function h(n,...)if(#t>0)then local o={}for e=1,#t do
- if(t[e]~=nil)then
- if(coroutine.status(t[e][1])=="suspended")then
- if(t[e][2]~=nil)then
- if(t[e][2]==n)then
- local o,n=coroutine.resume(t[e][1],n,...)t[e][2]=n if not(o)then u(n)end end else local o,n=coroutine.resume(t[e][1],n,...)t[e][2]=n if not(o)then u(n)end end else table.insert(o,e)end end end
- for e=1,#o do table.remove(t,o[e]-(e-1))end end end
- local function a()if(c==false)then return end if(n~=nil)then n:draw()n:updateTerm()end
- for n,e in pairs(d)do e:draw()e:updateTerm()end
- for n,e in pairs(i)do e[1]:draw()e[1]:updateTerm()end end local _,f,t=nil,nil,nil local g=nil
- local function j(l,o,e,n)_,f,t=o,e,n if(g==nil)then
- g=os.startTimer(y/1000)end end
- local function I()g=nil n:hoverHandler(f,t,_)l=n end local S,B,t=nil,nil,nil local f=nil local function _()f=nil n:dragHandler(S,B,t)l=n end local function V(l,o,e,n)S,B,t=o,e,n
- if(m<50)then _()else if(f==nil)then f=os.startTimer(m/1000)end end end
- local function S(t,...)local o={...}if(z:sendEvent("basaltEventCycle",t,...)==false)then return end if(t=="terminate")then e.stop()end
- if(n~=nil)then
- local e={mouse_click=n.mouseHandler,mouse_up=n.mouseUpHandler,mouse_scroll=n.scrollHandler,mouse_drag=V,mouse_move=j}local e=e[t]if(e~=nil)then e(n,...)h(t,...)a()return end end
- if(t=="monitor_touch")then if(d[o[1]]~=nil)then
- d[o[1]]:mouseHandler(1,o[2],o[3],true)l=d[o[1]]end
- if(H(i)>0)then for n,e in pairs(i)do
- e[1]:mouseHandler(1,o[2],o[3],true,o[1])end end h(t,...)a()return end
- if(l~=nil)then
- local e={char=l.charHandler,key=l.keyHandler,key_up=l.keyUpHandler}local e=e[t]if(e~=nil)then if(t=="key")then p[o[1]]=true elseif(t=="key_up")then
- p[o[1]]=false end e(l,...)h(t,...)a()return end end
- if(t=="timer")and(o[1]==g)then I()elseif(t=="timer")and(o[1]==f)then _()else
- for n,e in pairs(s)do e:eventHandler(t,...)end end h(t,...)a()end
- e={logging=false,dynamicValueEvents=false,setTheme=E,getTheme=v,drawFrames=a,getVersion=function()return P end,setVariable=T,getVariable=C,setBaseTerm=function(e)o=e end,log=function(...)D(...)end,setMouseMoveThrottle=function(e)if(_HOST:find("CraftOS%-PC"))then if(config.get("mouse_move_throttle")~=10)then
- config.set("mouse_move_throttle",10)end
- if(e<100)then y=100 else y=e end return true end return false end,setMouseDragThrottle=function(e)if(e<=0)then m=0 else f=nil m=e end end,autoUpdate=function(e)c=e if(e==nil)then c=true end local function e()a()while c do
- S(os.pullEventRaw())end end
- local e,n=xpcall(e,debug.traceback)if not(e)then u(n)return end end,update=function(e,...)if(e~=nil)then local e,n=xpcall(S,debug.traceback,e,...)if not(e)then
- u(n)return end end end,stop=b,stopUpdate=b,isKeyDown=function(e)if(p[e]==nil)then return false end return p[e]end,getFrame=function(n)for t,e in
- pairs(s)do if(e.name==n)then return e end end end,getActiveFrame=function()return
- l end,setActiveFrame=function(e)if(e:getType()=="Frame")then l=e return true end return false end,onEvent=function(...)for n,e in
- pairs(table.pack(...))do if(type(e)=="function")then
- z:registerEvent("basaltEventCycle",e)end end end,schedule=k,createFrame=function(e)e=e or A()for t,n in pairs(s)do if(n.name==e)then return nil end end local e=F(e,nil,nil,M)e:init()table.insert(s,e)if(n==nil)and(e:getName()~="basaltDebuggingFrame")then e:show()end return e end,removeFrame=function(e)s[e]=nil end,setProjectDir=function(e)w=e end,debug=function(...)local t={...}if(n==nil)then print(...)return end
- if(n.name~="basaltDebuggingFrame")then if(n~=e.debugFrame)then
- e.debugLabel:setParent(n)end end local n=""for o,e in pairs(t)do n=n..tostring(e)..(#t~=o and", "or"")end e.debugLabel:setText("[Debug] "..n)for t,n in
- pairs(x(n,e.debugList:getWidth()))do e.debugList:addItem(n)end if(e.debugList:getItemCount()>50)then
- e.debugList:removeItem(1)end
- e.debugList:setValue(e.debugList:getItem(e.debugList:getItemCount()))if(e.debugList.getItemCount()>e.debugList:getHeight())then
- e.debugList:setOffset(e.debugList:getItemCount()-e.debugList:getHeight())end
- e.debugLabel:show()end}e.debugFrame=e.createFrame("basaltDebuggingFrame"):showBar():setBackground(colors.lightGray):setBar("Debug",colors.black,colors.gray)e.debugFrame:addButton("back"):setAnchor("topRight"):setSize(1,1):setText("\22"):onClick(function()if(e.oldFrame~=nil)then e.oldFrame:show()end end):setBackground(colors.red):show()e.debugList=e.debugFrame:addList("debugList"):setSize("parent.w - 2","parent.h - 3"):setPosition(2,3):setScrollable(true):show()e.debugLabel=e.debugFrame:addLabel("debugLabel"):onClick(function()e.oldFrame=n e.debugFrame:show()end):setBackground(colors.black):setForeground(colors.white):setAnchor("bottomLeft"):ignoreOffset():setZIndex(20):show()return e end
- r["theme"]=function(...)return{BasaltBG=colors.lightGray,BasaltText=colors.black,FrameBG=colors.gray,FrameText=colors.black,ButtonBG=colors.gray,ButtonText=colors.black,CheckboxBG=colors.gray,CheckboxText=colors.black,InputBG=colors.gray,InputText=colors.black,TextfieldBG=colors.gray,TextfieldText=colors.black,ListBG=colors.gray,ListText=colors.black,MenubarBG=colors.gray,MenubarText=colors.black,DropdownBG=colors.gray,DropdownText=colors.black,RadioBG=colors.gray,RadioText=colors.black,SelectionBG=colors.black,SelectionText=colors.lightGray,GraphicBG=colors.black,ImageBG=colors.black,PaneBG=colors.black,ProgramBG=colors.black,ProgressbarBG=colors.gray,ProgressbarText=colors.black,ProgressbarActiveBG=colors.black,ScrollbarBG=colors.lightGray,ScrollbarText=colors.gray,ScrollbarSymbolColor=colors.black,SliderBG=false,SliderText=colors.gray,SliderSymbolColor=colors.black,SwitchBG=colors.lightGray,SwitchText=colors.gray,SwitchBGSymbol=colors.black,SwitchInactive=colors.red,SwitchActive=colors.green,LabelBG=false,LabelText=colors.black,GraphBG=colors.gray,GraphText=colors.black}end
- r["Frame"]=function(...)local e=l("module")local a=l("Object")local Q=l("loadObjects")local A=l("basaltDraw")local C=l("utils")local J=e("layout")local fe=e("basaltMon")local R=C.uuid local g=C.rpairs local o=C.getValueFromXML local b=C.tableCount
- local c,ue,e=string.sub,math.min,math.max
- return
- function(n,D,t,l)local r=a(n)local ce="Frame"local d={}local m={}local _={}local n={}local a={}local i={}local O={}local u={}local k=0 local t=t or term.current()local f=""local p=false
- local x=false local w=false local N=0 local q=0 local W=false local z=0 local j=false local se=false local F=""local E=false
- local P=false local i local s local S=true local I=true local Y=false local y={}local B={}r:setZIndex(10)local i=A(t)local L=false local U=1 local Z=1 local H=colors.white local T,h=0,0 local X={}local function v(n,e)if(e~=nil)then e:setValuesByXMLData(n)end end
- local function G(e,n,t)if(e~=nil)then if(e.properties~=nil)then e={e}end for o,e in pairs(e)do local n=n(t,e["@id"]or R())table.insert(X,n)v(e,n)end end end
- local function v(e)if(type(e)~="string")then e=e.name end for t,n in pairs(d)do
- for t,n in
- pairs(n)do if(n:getName()==e)then return n end end end end
- local function ae(n)local e=v(n)if(e~=nil)then return e end
- for t,e in pairs(d)do
- for t,e in pairs(e)do if(e:getType()=="Frame")then local e=e:getDeepObject(n)if(e~=nil)then return e end end end end end
- local function V(n)local e=n:getZIndex()if(v(n.name)~=nil)then return nil end
- if(d[e]==nil)then
- for n=1,#m+1 do if(m[n]~=nil)then if(e==m[n])then break end if(e>m[n])then table.insert(m,n,e)break end else
- table.insert(m,e)end end if(#m<=0)then table.insert(m,e)end d[e]={}end n.parent=_ if(n.init~=nil)then n:init()end
- table.insert(d[e],n)return n end
- local function M(e,a)for t,o in pairs(n)do
- for l,o in pairs(o)do
- for r,o in pairs(o)do
- if(o==a)then
- table.remove(n[t][l],r)if(e.parent~=nil)then if(b(n[t])<=0)then
- e.parent:removeEvent(t,e)end end end end end end end
- local function ie(o,n)for l,e in pairs(d)do
- for t,e in pairs(e)do
- if(type(n)=="string")then
- if(e:getName()==n)then
- table.remove(d[l],t)M(_,e)o:updateDraw()return true end else if(e==n)then table.remove(d[l],t)M(_,e)o:updateDraw()return true end end end end return false end local function K(o,e,t)for n,e in pairs(n[e])do for n,e in pairs(e)do
- if(e:getName()==t)then return e end end end end
- local function te(l,e,o)local t=o:getZIndex()if(n[e]==nil)then n[e]={}end if(a[e]==nil)then
- a[e]={}end
- if(K(l,e,o.name)~=nil)then return nil end
- if(l.parent~=nil)then l.parent:addEvent(e,l)end y[e]=true
- if(n[e][t]==nil)then
- for n=1,#a[e]+1 do
- if(a[e][n]~=nil)then if(t==a[e][n])then break end if(t>a[e][n])then
- table.insert(a[e],n,t)break end else
- table.insert(a[e],t)end end
- if(#a[e]<=0)then table.insert(a[e],t)end n[e][t]={}end table.insert(n[e][t],o)return o end
- local function ee(t,e,r)if(n[e]~=nil)then
- for o,l in pairs(n[e])do
- for l,a in pairs(l)do
- if(a==r)then
- table.remove(n[e][o],l)if(#n[e][o]<=0)then n[e][o]=nil
- if(t.parent~=nil)then if(b(n[e])<=0)then y[e]=false
- t.parent:removeEvent(e,t)end end end return
- true end end end end return false end local b=math
- local function ne(e)local n,t=pcall(load("return "..e,"",nil,{math=b}))if not(n)then
- error(e.." is not a valid dynamic code")end return t end
- local function oe(e,t,n)for o,e in pairs(u)do
- if(e[2]==n)and(e[4]==t)then return e end end k=k+1
- u[k]={0,n,{},t,k}return u[k]end
- local function le(o,t)local e={}local n={}for n in t:gmatch("%a+%.x")do local n=n:gsub("%.x","")if(n~="self")and(n~="parent")then table.insert(e,n)end end
- for n in
- t:gmatch("%w+%.y")do local n=n:gsub("%.y","")if(n~="self")and(n~="parent")then
- table.insert(e,n)end end for n in t:gmatch("%a+%.w")do local n=n:gsub("%.w","")if(n~="self")and(n~="parent")then table.insert(e,n)end end
- for n in
- t:gmatch("%a+%.h")do local n=n:gsub("%.h","")if(n~="self")and(n~="parent")then
- table.insert(e,n)end end
- for t,e in pairs(e)do n[e]=v(e)if(n[e]==nil)then
- error("Dynamic Values - unable to find object "..e)end end n["self"]=o n["parent"]=o:getParent()return n end
- local function re(n,t)local e=n for n in n:gmatch("%w+%.x")do
- e=e:gsub(n,t[n:gsub("%.x","")]:getX())end for n in n:gmatch("%w+%.y")do
- e=e:gsub(n,t[n:gsub("%.y","")]:getY())end for n in n:gmatch("%w+%.w")do
- e=e:gsub(n,t[n:gsub("%.w","")]:getWidth())end for n in n:gmatch("%w+%.h")do
- e=e:gsub(n,t[n:gsub("%.h","")]:getHeight())end return e end
- local function de(t)if(#u>0)then
- for e=1,k do
- if(u[e]~=nil)then local n if(#u[e][3]<=0)then
- u[e][3]=le(u[e][4],u[e][2])end
- n=re(u[e][2],u[e][3])u[e][1]=ne(n)if(u[e][4]:getType()=="Frame")then
- u[e][4]:recalculateDynamicValues()end end end
- for n,e in pairs(m)do
- if(d[e]~=nil)then
- for n,e in pairs(d[e])do
- if(l.getDynamicValueEventSetting())then if(e.eventHandler~=nil)then
- e:eventHandler("basalt_dynamicvalue",t)end end if(e.customEventHandler~=nil)then
- e:customEventHandler("basalt_resize",t)end end end end end end local function ne(e)return u[e][1]end
- local function u(o)local t=0
- for l,n in pairs(d)do
- for l,n in pairs(n)do
- if(n.getHeight~=nil)and(n.getY~=nil)then
- if(n:getType()=="Dropdown")then local l,r=n:getHeight(),n:getY()local a,n=n:getDropdownSize()l=l+n-1
- if(l+r-o:getHeight()>=t)then t=e(l+r-o:getHeight(),0)end else local n,l=n:getHeight(),n:getY()if(n+l-o:getHeight()>=t)then
- t=e(n+l-o:getHeight(),0)end end end end end return t end
- local function le(o)local t=0
- for l,n in pairs(d)do
- for l,n in pairs(n)do
- if(n.getWidth~=nil)and(n.getX~=nil)then local l,n=n:getWidth(),n:getX()if(l+n-o:getWidth()>=t)then
- t=e(l+n-o:getWidth(),0)end end end end return t end local function k(e)if(I)then z=u(e)end end
- _={barActive=false,barBackground=colors.gray,barTextcolor=colors.black,barText="New Frame",barTextAlign="left",addEvent=te,removeEvent=ee,removeEvents=M,getEvent=K,newDynamicValue=oe,recalculateDynamicValues=de,getDynamicValue=ne,getType=function(e)return
- ce end,setZIndex=function(e,n)r.setZIndex(e,n)for n,t in pairs(y)do if(t)then
- e.parent:addEvent(n,e)end end return e end,setFocusedObject=function(n,e)if(s~=e)then if(s~=nil)then
- if(v(s)~=nil)then s:loseFocusHandler()end end if(e~=nil)then if(v(e)~=nil)then
- e:getFocusHandler()end end s=e end return n end,getVariable=function(n,e)return
- l.getVariable(e)end,setSize=function(e,o,n,l)r.setSize(e,o,n,l)if(e.parent==nil)then i=A(t)end
- for t,n in pairs(m)do if(d[n]~=nil)then
- for t,n in
- pairs(d[n])do if(n.customEventHandler~=nil)then
- n:customEventHandler("basalt_resize",e)end end end end e:recalculateDynamicValues()S=false return e end,setTheme=function(n,e,t)if(type(e)=="table")then O=e elseif(type(e)=="string")then O[e]=t end n:updateDraw()return n end,getTheme=function(n,e)return
- O[e]or(n.parent~=nil and n.parent:getTheme(e)or
- l.getTheme(e))end,getThemeColor=function(n,e)return
- e~=nil and B[e]or B end,setThemeColor=function(o,e,...)if(o.parent==nil)then
- if(o==l.getActiveFrame())then
- if(type(e)=="string")then B[e]=...t.setPaletteColor(type(e)=="number"and e or colors[e],...)elseif(type(e)=="table")then
- for e,n in pairs(e)do B[e]=n
- if(type(n)=="number")then
- t.setPaletteColor(type(e)=="number"and e or colors[e],n)else local o,l,n=table.unpack(n)t.setPaletteColor(type(e)=="number"and e or colors[e],o,l,n)end end end end end return o end,setPosition=function(e,o,t,n)r.setPosition(e,o,t,n)e:recalculateDynamicValues()return e end,getBasaltInstance=function(e)return
- l end,setOffset=function(t,e,n)T=e~=nil and
- b.floor(e<0 and b.abs(e)or-e)or T
- h=n~=nil and
- b.floor(n<0 and b.abs(n)or-n)or h t:updateDraw()return t end,getOffsetInternal=function(e)return
- T,h end,getOffset=function(e)return T<0 and b.abs(T)or-T,h<0 and
- b.abs(h)or-h end,removeFocusedObject=function(e)if(s~=nil)then
- if(v(s)~=nil)then s:loseFocusHandler()end end s=nil return e end,getFocusedObject=function(e)return
- s end,setCursor=function(e,l,o,n,r)if(e.parent~=nil)then
- local a,t=e:getAnchorPosition()e.parent:setCursor(l or false,(o or 0)+a-1,(n or 0)+t-1,r or H)else
- local a,e=e:getAbsolutePosition(e:getAnchorPosition(e:getX(),e:getY(),true))L=l or false if(o~=nil)then U=a+o-1 end if(n~=nil)then Z=e+n-1 end H=r or H if(L)then
- t.setTextColor(H)t.setCursorPos(U,Z)t.setCursorBlink(L)else
- t.setCursorBlink(false)end end return e end,setMovable=function(e,n)if(e.parent~=nil)then E=n or not E
- e.parent:addEvent("mouse_click",e)y["mouse_click"]=true
- e.parent:addEvent("mouse_up",e)y["mouse_up"]=true
- e.parent:addEvent("mouse_drag",e)y["mouse_drag"]=true end return e end,setScrollable=function(e,n)W=(n or n==nil)and true or false
- if(e.parent~=nil)then e.parent:addEvent("mouse_scroll",e)end y["mouse_scroll"]=true return e end,setScrollAmount=function(n,e)z=e or z I=false return n end,getScrollAmount=function(e)return I and k(e)or
- z end,getCalculatedVerticalScroll=u,getCalculatedHorizontalScroll=le,show=function(e)r.show(e)if(e.parent==nil)then l.setActiveFrame(e)for n,e in pairs(colors)do if(type(e)=="number")then
- t.setPaletteColor(e,colors.packRGB(term.nativePaletteColor((e))))end end
- for e,n in pairs(B)do
- if(type(n)=="number")then
- t.setPaletteColor(type(e)=="number"and e or colors[e],n)else local o,n,l=table.unpack(n)t.setPaletteColor(type(e)=="number"and e or colors[e],o,n,l)end end
- if(p)and not(x)then l.setMonitorFrame(f,e)elseif(x)then
- l.setMonitorFrame(e:getName(),e,f)else l.setMainFrame(e)end end return e end,hide=function(e)r.hide(e)if(e.parent==nil)then if(activeFrame==e)then activeFrame=nil end
- if(p)and
- not(x)then if(l.getMonitorFrame(f)==e)then
- l.setActiveFrame(nil)end elseif(x)then
- if(l.getMonitorFrame(e:getName())==e)then l.setActiveFrame(nil)end else
- if(l.getMainFrame()==e)then l.setMainFrame(nil)end end end return e end,addLayout=function(n,e)if(e~=nil)then
- if(fs.exists(e))then local e=fs.open(e,"r")local t=J:ParseXmlText(e.readAll())e.close()X={}n:setValuesByXMLData(t)end end return n end,getLastLayout=function(e)return
- X end,addLayoutFromString=function(n,e)if(e~=nil)then local e=J:ParseXmlText(e)n:setValuesByXMLData(e)end return n end,setValuesByXMLData=function(n,e)r.setValuesByXMLData(n,e)if(o("movable",e)~=nil)then if(o("movable",e))then
- n:setMovable(true)end end if(o("scrollable",e)~=nil)then
- if(o("scrollable",e))then n:setScrollable(true)end end if(o("monitor",e)~=nil)then
- n:setMonitor(o("monitor",e)):show()end if(o("mirror",e)~=nil)then
- n:setMirror(o("mirror",e))end
- if(o("bar",e)~=nil)then if(o("bar",e))then
- n:showBar(true)else n:showBar(false)end end
- if(o("barText",e)~=nil)then n.barText=o("barText",e)end if(o("barBG",e)~=nil)then
- n.barBackground=colors[o("barBG",e)]end if(o("barFG",e)~=nil)then
- n.barTextcolor=colors[o("barFG",e)]end if(o("barAlign",e)~=nil)then
- n.barTextAlign=o("barAlign",e)end if(o("layout",e)~=nil)then
- n:addLayout(o("layout",e))end if(o("xOffset",e)~=nil)then
- n:setOffset(o("xOffset",e),h)end if(o("yOffset",e)~=nil)then
- n:setOffset(h,o("yOffset",e))end if(o("scrollAmount",e)~=nil)then
- n:setScrollAmount(o("scrollAmount",e))end local t=e:children()for t,e in
- pairs(t)do if(e.___name~="animation")then
- local t=e.___name:gsub("^%l",string.upper)if(Q[t]~=nil)then G(e,n["add"..t],n)end end end G(e["frame"],n.addFrame,n)G(e["animation"],n.addAnimation,n)return n end,showBar=function(e,n)e.barActive=n or not e.barActive e:updateDraw()return e end,setBar=function(e,n,o,t)e.barText=n or""e.barBackground=o or e.barBackground
- e.barTextcolor=t or e.barTextcolor e:updateDraw()return e end,setBarTextAlign=function(e,n)e.barTextAlign=n or"left"e:updateDraw()return e end,setMirror=function(e,n)if(e.parent~=nil)then
- error"Frame has to be a base frame in order to attach a mirror."end F=n if(mirror~=nil)then
- i.setMirror(mirror)end j=true return e end,removeMirror=function(e)mirror=nil j=false i.setMirror(nil)return e end,setMonitorScale=function(e,n)if(p)then t.setTextScale(n)end return e end,setMonitor=function(e,n,o)if(n~=nil)and(n~=false)then
- if(type(n)=="string")then
- if(peripheral.getType(n)=="monitor")then t=peripheral.wrap(n)w=true end
- if(e.parent~=nil)then e.parent:removeObject(e)end p=true l.setMonitorFrame(n,e)elseif(type(n)=="table")then
- t=fe(n)w=true p=true x=true
- l.setMonitorFrame(e:getName(),e,true)end else t=parentTerminal p=false x=false
- if(type(f)=="string")then
- if(l.getMonitorFrame(f)==e)then l.setMonitorFrame(f,nil)end else
- if(l.getMonitorFrame(e:getName())==e)then l.setMonitorFrame(e:getName(),nil)end end end if(o~=nil)then t.setTextScale(o)end i=A(t)e:setSize(t.getSize())S=true f=n or nil e:updateDraw()return e end,loseFocusHandler=function(e)r.loseFocusHandler(e)if(s~=nil)then s:loseFocusHandler()s=nil end end,getFocusHandler=function(e)r.getFocusHandler(e)if(e.parent~=nil)then
- if(E)then e.parent:removeEvents(e)e.parent:removeObject(e)e.parent:addObject(e)for t,n in pairs(y)do if(n)then
- e.parent:addEvent(t,e)end end
- e:updateDraw()end end if(s~=nil)then s:getFocusHandler()end end,eventHandler=function(e,o,...)r.eventHandler(e,o,...)if(n["other_event"]~=nil)then
- for t,e in ipairs(a["other_event"])do if(n["other_event"][e]~=nil)then
- for n,e in g(n["other_event"][e])do if(e.eventHandler~=nil)then e:eventHandler(o,...)end end end end end
- if(S)and not(p)then if(e.parent==nil)then
- if(o=="term_resize")then
- e:sendEvent("basalt_resize",e,o,...)e:setSize(t.getSize())S=true end end end
- if(p)then
- if(S)then
- if(o=="monitor_resize")then
- if(type(f)=="string")then
- e:setSize(t.getSize())elseif(type(f)=="table")then
- for o,n in pairs(f)do for o,n in pairs(n)do if(p1==n)then
- e:setSize(t.getSize())end end end end S=true e:updateDraw()end end
- if(o=="peripheral")and(p1==f)then if(peripheral.getType(f)=="monitor")then w=true t=peripheral.wrap(f)i=A(t)e:updateDraw()end end
- if(o=="peripheral_detach")and(p1==f)then w=false end end
- if(j)then if(peripheral.getType(F)=="monitor")then se=true
- i.setMirror(peripheral.wrap(F))end if(o=="peripheral_detach")and(p1==F)then w=false end
- if(o=="monitor_touch")and(F==p1)then e:mouseHandler(1,p2,p3,true)end end end,mouseHandler=function(o,i,e,l,c,d)if(x)then if(t.calculateClick~=nil)then
- e,l=t.calculateClick(d,e,l)end end
- if(r.mouseHandler(o,i,e,l))then
- if(n["mouse_click"]~=nil)then
- o:setCursor(false)for o,t in ipairs(a["mouse_click"])do
- if(n["mouse_click"][t]~=nil)then for t,n in g(n["mouse_click"][t])do
- if(n.mouseHandler~=nil)then if(n:mouseHandler(i,e,l))then return true end end end end end end
- if(E)then
- local n,t=o:getAbsolutePosition(o:getAnchorPosition())if(e>=n)and(e<=n+o:getWidth()-1)and(l==t)then P=true N=n-e
- q=yOff and 1 or 0 end end o:removeFocusedObject()return true end return false end,mouseUpHandler=function(e,l,o,t)if(P)then P=false end
- if(r.mouseUpHandler(e,l,o,t))then
- if(n["mouse_up"]~=nil)then
- for r,e in ipairs(a["mouse_up"])do
- if(n["mouse_up"][e]~=nil)then
- for n,e in
- g(n["mouse_up"][e])do if(e.mouseUpHandler~=nil)then
- if(e:mouseUpHandler(l,o,t))then return true end end end end end end return true end return false end,scrollHandler=function(o,t,i,l)if(r.scrollHandler(o,t,i,l))then
- if(n["mouse_scroll"]~=nil)then
- for o,e in pairs(a["mouse_scroll"])do
- if(n["mouse_scroll"][e]~=nil)then
- for n,e in g(n["mouse_scroll"][e])do if(e.scrollHandler~=nil)then
- if(e:scrollHandler(t,i,l))then return true end end end end end end local n=h
- if(W)then k(o)if(t>0)or(t<0)then
- h=e(ue(h-t,0),-z)o:updateDraw()end end if(h==n)then return false end o:removeFocusedObject()return true end return false end,hoverHandler=function(l,t,e,o)if(r.hoverHandler(l,t,e,o))then
- if(n["mouse_move"]~=nil)then
- for r,l in pairs(a["mouse_move"])do
- if(n["mouse_move"][l]~=nil)then for l,n in g(n["mouse_move"][l])do
- if(n.hoverHandler~=nil)then if(n:hoverHandler(t,e,o))then return true end end end end end end end return false end,dragHandler=function(e,i,l,o)if(P)then local n,t=e.parent:getOffsetInternal()n=n<0 and
- b.abs(n)or-n t=t<0 and b.abs(t)or-t local r=1 local a=1 if(e.parent~=nil)then
- r,a=e.parent:getAbsolutePosition(e.parent:getAnchorPosition())end
- e:setPosition(l+N-(r-1)+n,o+q-(a-1)+t)e:updateDraw()return true end
- if(e:isVisible())and(e:isEnabled())then
- if(n["mouse_drag"]~=nil)then
- for t,e in ipairs(a["mouse_drag"])do
- if(n["mouse_drag"][e]~=nil)then for n,e in g(n["mouse_drag"][e])do
- if(e.dragHandler~=nil)then if(e:dragHandler(i,l,o))then return true end end end end end end end r.dragHandler(e,i,l,o)return false end,keyHandler=function(e,t,o)if(e:isFocused())or(e.parent==nil)then
- local e=e:getEventSystem():sendEvent("key",e,"key",t)if(e==false)then return false end
- if(n["key"]~=nil)then
- for l,e in pairs(a["key"])do
- if(n["key"][e]~=nil)then
- for n,e in g(n["key"][e])do if(e.keyHandler~=nil)then if(e:keyHandler(t,o))then return true end end end end end end end return false end,keyUpHandler=function(e,t)if(e:isFocused())or(e.parent==nil)then
- local e=e:getEventSystem():sendEvent("key_up",e,"key_up",t)if(e==false)then return false end
- if(n["key_up"]~=nil)then
- for o,e in
- pairs(a["key_up"])do
- if(n["key_up"][e]~=nil)then for n,e in g(n["key_up"][e])do
- if(e.keyUpHandler~=nil)then if(e:keyUpHandler(t))then return true end end end end end end end return false end,charHandler=function(e,t)if(e:isFocused())or(e.parent==nil)then
- local e=e:getEventSystem():sendEvent("char",e,"char",t)if(e==false)then return false end
- if(n["char"]~=nil)then
- for o,e in
- pairs(a["char"])do
- if(n["char"][e]~=nil)then for n,e in g(n["char"][e])do
- if(e.charHandler~=nil)then if(e:charHandler(t))then return true end end end end end end end return false end,setText=function(n,t,o,a)local l,r=n:getAnchorPosition()if(o>=1)and(o<=n:getHeight())then
- if(n.parent~=nil)then
- n.parent:setText(e(t+(l-1),l),r+o-1,c(a,e(1-t+1,1),e(n:getWidth()-t+1,1)))else
- i.setText(e(t+(l-1),l),r+o-1,c(a,e(1-t+1,1),e(n:getWidth()-t+1,1)))end end end,setBG=function(t,n,o,r)local l,a=t:getAnchorPosition()if(o>=1)and(o<=t:getHeight())then
- if(t.parent~=nil)then
- t.parent:setBG(e(n+(l-1),l),a+o-1,c(r,e(1-n+1,1),e(t:getWidth()-n+1,1)))else
- i.setBG(e(n+(l-1),l),a+o-1,c(r,e(1-n+1,1),e(t:getWidth()-n+1,1)))end end end,setFG=function(t,n,o,r)local l,a=t:getAnchorPosition()if(o>=1)and(o<=t:getHeight())then
- if(t.parent~=nil)then
- t.parent:setFG(e(n+(l-1),l),a+o-1,c(r,e(1-n+1,1),e(t:getWidth()-n+1,1)))else
- i.setFG(e(n+(l-1),l),a+o-1,c(r,e(1-n+1,1),e(t:getWidth()-n+1,1)))end end end,writeText=function(t,n,o,d,a,r)local l,s=t:getAnchorPosition()if(o>=1)and(o<=t:getHeight())then
- if(t.parent~=nil)then
- t.parent:writeText(e(n+(l-1),l),s+o-1,c(d,e(1-n+1,1),t:getWidth()-n+1),a,r)else
- i.writeText(e(n+(l-1),l),s+o-1,c(d,e(1-n+1,1),e(t:getWidth()-n+1,1)),a,r)end end end,blit=function(a,n,s,l,t,o)local d,u=a:getAnchorPosition()if(s>=1)and(s<=a:getHeight())then
- local r=a:getWidth()if(a.parent~=nil)then
- l=c(l,e(1-n+1,1),r-n+1)t=c(t,e(1-n+1,1),r-n+1)o=c(o,e(1-n+1,1),r-n+1)a.parent:blit(e(n+(d-1),d),u+s-1,l,t,o)else
- l=c(l,e(1-n+1,1),e(r-n+1,1))t=c(t,e(1-n+1,1),e(r-n+1,1))o=c(o,e(1-n+1,1),e(r-n+1,1))i.blit(e(n+(d-1),d),u+s-1,l,t,o)end end end,drawBackgroundBox=function(n,t,o,r,l,c)local d,a=n:getAnchorPosition()l=(o<1 and(l+o>n:getHeight()and n:getHeight()or l+o-1)or(l+o>n:getHeight()and n:getHeight()-o+1 or l))r=(t<1 and(r+t>n:getWidth()and n:getWidth()or r+t-1)or(r+t>n:getWidth()and n:getWidth()-t+1 or r))if(n.parent~=nil)then
- n.parent:drawBackgroundBox(e(t+(d-1),d),e(o+(a-1),a),r,l,c)else
- i.drawBackgroundBox(e(t+(d-1),d),e(o+(a-1),a),r,l,c)end end,drawTextBox=function(n,l,o,r,t,s)local a,d=n:getAnchorPosition()t=(o<1 and(t+o>n:getHeight()and n:getHeight()or t+o-1)or(t+o>n:getHeight()and n:getHeight()-o+1 or t))r=(l<1 and(r+l>n:getWidth()and n:getWidth()or r+l-1)or(r+l>n:getWidth()and n:getWidth()-l+1 or r))if(n.parent~=nil)then
- n.parent:drawTextBox(e(l+(a-1),a),e(o+(d-1),d),r,t,c(s,1,1))else
- i.drawTextBox(e(l+(a-1),a),e(o+(d-1),d),r,t,c(s,1,1))end end,drawForegroundBox=function(n,o,r,l,t,c)local d,a=n:getAnchorPosition()t=(r<1 and(t+r>n:getHeight()and n:getHeight()or t+r-1)or(t+r>n:getHeight()and n:getHeight()-r+1 or t))l=(o<1 and(l+o>n:getWidth()and n:getWidth()or l+o-1)or(l+o>n:getWidth()and n:getWidth()-o+1 or l))if(n.parent~=nil)then
- n.parent:drawForegroundBox(e(o+(d-1),d),e(r+(a-1),a),l,t,c)else
- i.drawForegroundBox(e(o+(d-1),d),e(r+(a-1),a),l,t,c)end end,draw=function(e,n)if(p)and not(w)then return false end
- if(e.parent==nil)then if(e:getDraw()==false)then return false end end
- if(r.draw(e))then
- local n,n=e:getAbsolutePosition(e:getAnchorPosition())local n,t=e:getAnchorPosition()local o,l=e:getSize()if(e.parent==nil)then
- if(e.bgColor~=false)then
- i.drawBackgroundBox(n,t,o,l,e.bgColor)i.drawTextBox(n,t,o,l," ")end if(e.fgColor~=false)then
- i.drawForegroundBox(n,t,o,l,e.fgColor)end end
- if(e.barActive)then
- if(e.parent~=nil)then
- e.parent:writeText(n,t,C.getTextHorizontalAlign(e.barText,o,e.barTextAlign),e.barBackground,e.barTextcolor)else
- i.writeText(n,t,C.getTextHorizontalAlign(e.barText,o,e.barTextAlign),e.barBackground,e.barTextcolor)end
- if(e:getBorder("left"))then
- if(e.parent~=nil)then
- e.parent:drawBackgroundBox(n-1,t,1,1,e.barBackground)if(e.bgColor~=false)then
- e.parent:drawBackgroundBox(n-1,t+1,1,l-1,e.bgColor)end end end
- if(e:getBorder("top"))then if(e.parent~=nil)then
- e.parent:drawBackgroundBox(n-1,t-1,o+1,1,e.barBackground)end end end for n,e in g(m)do
- if(d[e]~=nil)then for n,e in pairs(d[e])do
- if(e.draw~=nil)then e:draw()end end end end end end,updateTerm=function(e)if(p)and not(w)then return false end i.update()end,addObject=function(n,e)return
- V(e)end,removeObject=ie,getObject=function(n,e)return v(e)end,getDeepObject=function(n,e)return ae(e)end,addFrame=function(e,n)local e=l.newFrame(n or R(),e,nil,l)return V(e)end,init=function(e)if
- not(Y)then
- if(D~=nil)then r.width,r.height=D:getSize()e:setBackground(D:getTheme("FrameBG"))e:setForeground(D:getTheme("FrameText"))else r.width,r.height=t.getSize()e:setBackground(l.getTheme("BasaltBG"))e:setForeground(l.getTheme("BasaltText"))end Y=true end end}for e,t in pairs(Q)do _["add"..e]=function(e,n)return V(t(n or R(),e))end end setmetatable(_,r)return _ end end
- r["Object"]=function(...)local t=l("basaltEvent")local e=l("utils")local n=l("module")local g=n("images")local n=e.splitString local n=e.numberFromString
- local n=e.getValueFromXML local F,p=table.unpack,string.sub
- return
- function(e)local M="Object"local T={}local D=1 local C
- local f="topLeft"local z=false local u=true local P=false local S=false local B=false local _=false
- local r={left=false,right=false,top=false,bottom=false}local y=colors.black local h=true local w=false local x,v,H,A=0,0,0,0 local i local c local s=1 local k
- local m local E=true local b=true local a={}local d=t()T={x=1,y=1,width=1,height=1,bgColor=colors.black,bgSymbol=" ",bgSymbolColor=colors.black,fgColor=colors.white,transparentColor=false,name=e or"Object",parent=nil,show=function(e)u=true e:updateDraw()return e end,hide=function(e)u=false
- e:updateDraw()return e end,enable=function(e)h=true return e end,disable=function(e)h=false
- return e end,isEnabled=function(e)return h end,generateXMLEventFunction=function(e,t,n)local t=function(n)if(n:sub(1,1)=="#")then
- local n=e:getBaseFrame():getDeepObject(n:sub(2,n:len()))if(n~=nil)and(n.internalObjetCall~=nil)then t(e,function()n:internalObjetCall()end)end else
- t(e,e:getBaseFrame():getVariable(n))end end if(type(n)=="string")then t(n)elseif(type(n)=="table")then
- for n,e in pairs(n)do t(e)end end return e end,setValuesByXMLData=function(t,e)local o=t:getBaseFrame()local o,d,i
- if(n("texture",e)~=nil)then o=n("texture",e)end if(n("mode",e)~=nil)then d=n("mode",e)end
- if(n("texturePlay",e)~=nil)then i=n("texturePlay",e)end local l,a if(n("x",e)~=nil)then l=n("x",e)end if(n("y",e)~=nil)then a=n("y",e)end if(l~=nil)or(a~=nil)then t:setPosition(l,a)end local l,a if(n("width",e)~=nil)then l=n("width",e)end if(n("height",e)~=nil)then a=n("height",e)end if(l~=nil)or(a~=nil)then t:setSize(l,a)end if(n("bg",e)~=nil)then
- t:setBackground(colors[n("bg",e)])end if(n("bgSymbol",e)~=nil)then
- t:setBackground(t.bgColor,n("bgSymbol",e))end if(n("bgSymbolColor",e)~=nil)then
- t:setBackground(t.bgColor,t.bgSymbol,colors[n("bgSymbolColor",e)])end
- if(n("fg",e)~=nil)then t:setForeground(colors[n("fg",e)])end if(n("value",e)~=nil)then
- t:setValue(colors[n("value",e)])end
- if(n("visible",e)~=nil)then if(n("visible",e))then t:show()else t:hide()end end
- if(n("enabled",e)~=nil)then if(n("enabled",e))then t:enable()else
- t:disable()end end if(n("zIndex",e)~=nil)then
- t:setZIndex(n("zIndex",e))end if(n("anchor",e)~=nil)then
- t:setAnchor(n("anchor",e))end if(n("shadowColor",e)~=nil)then
- t:setShadow(colors[n("shadowColor",e)])end if(n("border",e)~=nil)then
- t:setBorder(colors[n("border",e)])end if(n("borderLeft",e)~=nil)then
- r["left"]=n("borderLeft",e)end if(n("borderTop",e)~=nil)then
- r["top"]=n("borderTop",e)end if(n("borderRight",e)~=nil)then
- r["right"]=n("borderRight",e)end if(n("borderBottom",e)~=nil)then
- r["bottom"]=n("borderBottom",e)end if(n("borderColor",e)~=nil)then
- t:setBorder(colors[n("borderColor",e)])end if(n("ignoreOffset",e)~=nil)then
- if(n("ignoreOffset",e))then t:ignoreOffset(true)end end if(n("onClick",e)~=nil)then
- t:generateXMLEventFunction(t.onClick,n("onClick",e))end if(n("onClickUp",e)~=nil)then
- t:generateXMLEventFunction(t.onClickUp,n("onClickUp",e))end if(n("onScroll",e)~=nil)then
- t:generateXMLEventFunction(t.onScroll,n("onScroll",e))end if(n("onDrag",e)~=nil)then
- t:generateXMLEventFunction(t.onDrag,n("onDrag",e))end if(n("onHover",e)~=nil)then
- t:generateXMLEventFunction(t.onHover,n("onHover",e))end if(n("onLeave",e)~=nil)then
- t:generateXMLEventFunction(t.onLeave,n("onLeave",e))end if(n("onKey",e)~=nil)then
- t:generateXMLEventFunction(t.onKey,n("onKey",e))end if(n("onKeyUp",e)~=nil)then
- t:generateXMLEventFunction(t.onKeyUp,n("onKeyUp",e))end if(n("onChange",e)~=nil)then
- t:generateXMLEventFunction(t.onChange,n("onChange",e))end if(n("onResize",e)~=nil)then
- t:generateXMLEventFunction(t.onResize,n("onResize",e))end if(n("onReposition",e)~=nil)then
- t:generateXMLEventFunction(t.onReposition,n("onReposition",e))end if(n("onEvent",e)~=nil)then
- t:generateXMLEventFunction(t.onEvent,n("onEvent",e))end if(n("onGetFocus",e)~=nil)then
- t:generateXMLEventFunction(t.onGetFocus,n("onGetFocus",e))end if(n("onLoseFocus",e)~=nil)then
- t:generateXMLEventFunction(t.onLoseFocus,n("onLoseFocus",e))end if(o~=nil)then
- t:setTexture(o,d,i)end t:updateDraw()return t end,isVisible=function(e)return
- u end,setFocus=function(e)if(e.parent~=nil)then
- e.parent:setFocusedObject(e)end return e end,setZIndex=function(e,n)D=n
- if(e.parent~=nil)then e.parent:removeObject(e)e.parent:addObject(e)e:updateEventHandlers()end return e end,updateEventHandlers=function(e)for t,n in
- pairs(a)do if(n)then e.parent:addEvent(t,e)end end end,getZIndex=function(e)return D end,getType=function(e)return M end,getName=function(e)return
- e.name end,remove=function(e)if(e.parent~=nil)then
- e.parent:removeObject(e)end e:updateDraw()return e end,setParent=function(e,n)if(n.getType~=nil and n:getType()=="Frame")then
- e:remove()n:addObject(e)if(e.draw)then e:show()end end return e end,setValue=function(e,n,t)if(C~=n)then C=n e:updateDraw()if(t~=false)then
- e:valueChangedHandler()end end
- return e end,getValue=function(e)return C end,getDraw=function(e)return
- b end,updateDraw=function(e,n)b=n if(n==nil)then b=true end if(b)then if(e.parent~=nil)then
- e.parent:updateDraw()end end return e end,getEventSystem=function(e)return
- d end,getParent=function(e)return e.parent end,setPosition=function(e,n,t,o)if(type(n)=="number")then e.x=o and e:getX()+n or n end if(type(t)=="number")then
- e.y=o and e:getY()+t or t end
- if(e.parent~=nil)then if(type(n)=="string")then
- e.x=e.parent:newDynamicValue(e,n)end if(type(t)=="string")then
- e.y=e.parent:newDynamicValue(e,t)end
- e.parent:recalculateDynamicValues()end e:customEventHandler("basalt_reposition")e:updateDraw()return e end,getX=function(e)return
- type(e.x)=="number"and e.x or math.floor(e.x[1]+.5)end,getY=function(e)return
- type(e.y)=="number"and e.y or math.floor(e.y[1]+.5)end,getPosition=function(e)return
- e:getX(),e:getY()end,getVisibility=function(e)return u end,setVisibility=function(e,n)u=n or not u e:updateDraw()return e end,setSize=function(e,n,t,o)if(type(n)=="number")then
- e.width=o and e:getWidth()+n or n end
- if(type(t)=="number")then e.height=o and
- e:getHeight()+t or t end
- if(e.parent~=nil)then if(type(n)=="string")then
- e.width=e.parent:newDynamicValue(e,n)end if(type(t)=="string")then
- e.height=e.parent:newDynamicValue(e,t)end
- e.parent:recalculateDynamicValues()end if(i~=nil)and(m=="stretch")then
- c=g.resizeBIMG(i,e:getSize())[s]end
- e:customEventHandler("basalt_resize")e:updateDraw()return e end,getHeight=function(e)return
- type(e.height)=="number"and e.height or
- math.floor(e.height[1]+.5)end,getWidth=function(e)return
- type(e.width)=="number"and e.width or math.floor(e.width[1]+.5)end,getSize=function(e)return
- e:getWidth(),e:getHeight()end,calculateDynamicValues=function(e)if(type(e.width)=="table")then e.width:calculate()end
- if(type(e.height)=="table")then e.height:calculate()end
- if(type(e.x)=="table")then e.x:calculate()end
- if(type(e.y)=="table")then e.y:calculate()end e:updateDraw()return e end,setBackground=function(e,o,n,t)e.bgColor=o or false
- e.bgSymbol=n or(e.bgColor~=false and e.bgSymbol or
- false)e.bgSymbolColor=t or e.bgSymbolColor
- e:updateDraw()return e end,setTexture=function(e,n,o,t)if(type(n)=="string")then i=g.loadImageAsBimg(n)elseif(type(n)=="table")then
- i=n end
- if(i.animated)then local n=i[s].duration or
- i.secondsPerFrame or .2
- k=os.startTimer(n)e.parent:addEvent("other_event",e)a["other_event"]=true end E=t==false and false or true s=1
- m=o or"normal"if(m=="stretch")then
- c=g.resizeBIMG(i,e:getSize())[1]else c=i[1]end
- e:updateDraw()return e end,setTransparent=function(e,n)e.transparentColor=n or false if(n~=false)then e.bgSymbol=false
- e.bgSymbolColor=false end e:updateDraw()return e end,getBackground=function(e)return
- e.bgColor end,setForeground=function(e,n)e.fgColor=n or false
- e:updateDraw()return e end,getForeground=function(e)return e.fgColor end,setShadow=function(n,e)if(e==false)then _=false else y=e _=true end
- n:updateDraw()return n end,isShadowActive=function(e)return _ end,setBorder=function(t,...)if(...~=nil)then local e={...}for t,n in pairs(e)do if(n=="left")or(#e==1)then
- r["left"]=e[1]end if(n=="top")or(#e==1)then
- r["top"]=e[1]end if(n=="right")or(#e==1)then
- r["right"]=e[1]end if(n=="bottom")or(#e==1)then
- r["bottom"]=e[1]end end end t:updateDraw()return t end,getBorder=function(n,e)if(e=="left")then return borderLeft end
- if(e=="top")then return borderTop end if(e=="right")then return borderRight end if(e=="bottom")then
- return borderBottom end end,draw=function(e)if(u)then
- if(e.parent~=nil)then local n,t=e:getAnchorPosition()local o,l=e:getSize()local i,a=e.parent:getSize()if(n+o<1)or(n>i)or(t+l<1)or(t>a)then return false end if(e.transparentColor~=false)then
- e.parent:drawForegroundBox(n,t,o,l,e.transparentColor)end if(e.bgColor~=false)then
- e.parent:drawBackgroundBox(n,t,o,l,e.bgColor)end
- if(e.bgSymbol~=false)then
- e.parent:drawTextBox(n,t,o,l,e.bgSymbol)if(e.bgSymbol~=" ")then
- e.parent:drawForegroundBox(n,t,o,l,e.bgSymbolColor)end end
- if(c~=nil)then
- if(m=="center")then local a,r=#c[1][1],#c
- local f=a<o and math.floor((o-a)/2)or 0
- local h=r<l and math.floor((l-r)/2)or 0
- local i=a<o and 1 or math.floor((a-o)/2)local a=a<o and o or
- o-math.floor((o-a)/2+.5)-1
- local o=r<l and 1 or math.floor((r-l)/2)local u=r<l and l or
- l-math.floor((l-r)/2+.5)-1 local s=1
- for d=o,#c do
- if(c[d]~=nil)then local l,r,o=F(c[d])l=p(l,i,a)r=p(r,i,a)o=p(o,i,a)e.parent:blit(n+f,t+s-1+h,l,r,o)end s=s+1 if(d==u)then break end end else
- for d,r in pairs(c)do local a,i,r=F(r)a=p(a,1,o)i=p(i,1,o)r=p(r,1,o)e.parent:blit(n,t+d-1,a,i,r)if(d==l)then break end end end end
- if(_)then
- e.parent:drawBackgroundBox(n+1,t+l,o,1,y)e.parent:drawBackgroundBox(n+o,t+1,1,l,y)e.parent:drawForegroundBox(n+1,t+l,o,1,y)e.parent:drawForegroundBox(n+o,t+1,1,l,y)end local a=e.bgColor
- if(r["left"]~=false)then
- e.parent:drawTextBox(n,t,1,l,"\149")if(a~=false)then
- e.parent:drawBackgroundBox(n,t,1,l,a)end
- e.parent:drawForegroundBox(n,t,1,l,r["left"])end
- if(r["top"]~=false)then
- e.parent:drawTextBox(n,t,o,1,"\131")if(a~=false)then
- e.parent:drawBackgroundBox(n,t,o,1,e.bgColor)end
- e.parent:drawForegroundBox(n,t,o,1,r["top"])end
- if(r["left"]~=false)and(r["top"]~=false)then
- e.parent:drawTextBox(n,t,1,1,"\151")if(a~=false)then
- e.parent:drawBackgroundBox(n,t,1,1,e.bgColor)end
- e.parent:drawForegroundBox(n,t,1,1,r["left"])end
- if(r["right"]~=false)then
- e.parent:drawTextBox(n+o-1,t,1,l,"\149")if(a~=false)then
- e.parent:drawForegroundBox(n+o-1,t,1,l,e.bgColor)end
- e.parent:drawBackgroundBox(n+o-1,t,1,l,r["right"])end
- if(r["bottom"]~=false)then
- e.parent:drawTextBox(n,t+l-1,o,1,"\143")if(a~=false)then
- e.parent:drawForegroundBox(n,t+l-1,o,1,e.bgColor)end
- e.parent:drawBackgroundBox(n,t+l-1,o,1,r["bottom"])end
- if(r["top"]~=false)and(r["right"]~=false)then e.parent:drawTextBox(n+o-1,t,1,1,"\148")if(a~=false)then
- e.parent:drawForegroundBox(n+o-1,t,1,1,e.bgColor)end
- e.parent:drawBackgroundBox(n+o-1,t,1,1,r["right"])end
- if(r["right"]~=false)and(r["bottom"]~=false)then
- e.parent:drawTextBox(n+o-1,t+l-1,1,1,"\133")if(a~=false)then
- e.parent:drawForegroundBox(n+o-1,t+l-1,1,1,e.bgColor)end
- e.parent:drawBackgroundBox(n+o-1,t+l-1,1,1,r["right"])end
- if(r["bottom"]~=false)and(r["left"]~=false)then e.parent:drawTextBox(n,t+l-1,1,1,"\138")if(a~=false)then
- e.parent:drawForegroundBox(n-1,t+l-1,1,1,e.bgColor)end
- e.parent:drawBackgroundBox(n,t+l-1,1,1,r["left"])end end b=false return true end return false end,getAbsolutePosition=function(t,n,e)if(n==nil)or(e==nil)then n,e=t:getAnchorPosition()end
- if(t.parent~=nil)then
- local t,o=t.parent:getAbsolutePosition()n=t+n-1 e=o+e-1 end return n,e end,getAnchorPosition=function(l,n,e,r)if(n==nil)then n=l:getX()end
- if(e==nil)then e=l:getY()end
- if(l.parent~=nil)then local t,o=l.parent:getSize()if(f=="top")then n=math.floor(t/2)+n-1 elseif(f=="topRight")then
- n=t+n-1 elseif(f=="right")then n=t+n-1
- e=math.floor(o/2)+e-1 elseif(f=="bottomRight")then n=t+n-1 e=o+e-1 elseif(f=="bottom")then n=math.floor(t/2)+n-1 e=o+e-1 elseif(f=="bottomLeft")then e=o+e-1 elseif(f=="left")then
- e=math.floor(o/2)+e-1 elseif(f=="center")then n=math.floor(t/2)+n-1 e=math.floor(o/2)+e-1 end local o,t=l.parent:getOffsetInternal()if not(z or r)then return
- n+o,e+t end end return n,e end,ignoreOffset=function(n,e)z=e if(e==nil)then z=true end return n end,getBaseFrame=function(e)if(e.parent~=nil)then return e.parent:getBaseFrame()end return e end,setAnchor=function(e,n)f=n
- e:updateDraw()return e end,getAnchor=function(e)return f end,onChange=function(e,...)for t,n in
- pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("value_changed",n)end end return e end,onClick=function(e,...)for t,n in
- pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("mouse_click",n)end end
- if(e.parent~=nil)then
- e.parent:addEvent("mouse_click",e)a["mouse_click"]=true
- e.parent:addEvent("mouse_up",e)a["mouse_up"]=true end return e end,onClickUp=function(e,...)for t,n in
- pairs(table.pack(...))do
- if(type(n)=="function")then e:registerEvent("mouse_up",n)end end
- if(e.parent~=nil)then
- e.parent:addEvent("mouse_click",e)a["mouse_click"]=true
- e.parent:addEvent("mouse_up",e)a["mouse_up"]=true end return e end,onRelease=function(e,...)for t,n in
- pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("mouse_release",n)end end
- if(e.parent~=nil)then
- e.parent:addEvent("mouse_click",e)a["mouse_click"]=true
- e.parent:addEvent("mouse_up",e)a["mouse_up"]=true end return e end,onScroll=function(e,...)for t,n in
- pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("mouse_scroll",n)end end
- if(e.parent~=nil)then
- e.parent:addEvent("mouse_scroll",e)a["mouse_scroll"]=true end return e end,onHover=function(e,...)for t,n in
- pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("mouse_hover",n)end end if(e.parent~=nil)then
- e.parent:addEvent("mouse_move",e)a["mouse_move"]=true end
- return e end,onLeave=function(e,...)for t,n in
- pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("mouse_leave",n)end end if(e.parent~=nil)then
- e.parent:addEvent("mouse_move",e)a["mouse_move"]=true end
- return e end,onDrag=function(e,...)for t,n in
- pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("mouse_drag",n)end end
- if(e.parent~=nil)then
- e.parent:addEvent("mouse_drag",e)a["mouse_drag"]=true
- e.parent:addEvent("mouse_click",e)a["mouse_click"]=true
- e.parent:addEvent("mouse_up",e)a["mouse_up"]=true end return e end,onEvent=function(e,...)for t,n in
- pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("other_event",n)end end if(e.parent~=nil)then
- e.parent:addEvent("other_event",e)a["other_event"]=true end return
- e end,onKey=function(e,...)if(h)then
- for t,n in pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("key",n)end end if(e.parent~=nil)then e.parent:addEvent("key",e)a["key"]=true end end return e end,onChar=function(e,...)if(h)then
- for t,n in pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("char",n)end end if(e.parent~=nil)then e.parent:addEvent("char",e)a["char"]=true end end return e end,onResize=function(e,...)for t,n in
- pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("basalt_resize",n)end end return e end,onReposition=function(e,...)for t,n in
- pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("basalt_reposition",n)end end return e end,onKeyUp=function(e,...)for t,n in
- pairs(table.pack(...))do
- if(type(n)=="function")then e:registerEvent("key_up",n)end end if(e.parent~=nil)then
- e.parent:addEvent("key_up",e)a["key_up"]=true end return e end,isFocused=function(e)if(e.parent~=nil)then
- return e.parent:getFocusedObject()==e end return false end,onGetFocus=function(e,...)for t,n in
- pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("get_focus",n)end end if(e.parent~=nil)then
- e.parent:addEvent("mouse_click",e)a["mouse_click"]=true end return
- e end,onLoseFocus=function(e,...)for t,n in
- pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("lose_focus",n)end end if(e.parent~=nil)then
- e.parent:addEvent("mouse_click",e)a["mouse_click"]=true end return
- e end,registerEvent=function(t,e,n)return
- d:registerEvent(e,n)end,removeEvent=function(t,e,n)return d:removeEvent(e,n)end,sendEvent=function(e,n,...)return d:sendEvent(n,e,...)end,isCoordsInObject=function(l,n,e)if(u)and(h)then if(n==nil)or(e==nil)then return false end
- local o,t=l:getAbsolutePosition()local r,l=l:getSize()if(o<=n)and(o+r>n)and(t<=e)and(t+l>e)then return true end end return false end,mouseHandler=function(e,a,t,n,r)if(e:isCoordsInObject(t,n))then local o,l=e:getAbsolutePosition()local o=d:sendEvent("mouse_click",e,"mouse_click",a,t-(o-1),n-(l-1),t,n,r)if(o==false)then return false end if(e.parent~=nil)then
- e.parent:setFocusedObject(e)end B=true w=true x,v=t,n return true end return false end,mouseUpHandler=function(t,o,n,e)w=false
- if(B)then local l,r=t:getAbsolutePosition()local e=d:sendEvent("mouse_release",t,"mouse_release",o,n-(l-1),e-(r-1),n,e)B=false end
- if(t:isCoordsInObject(n,e))then local r,l=t:getAbsolutePosition()local e=d:sendEvent("mouse_up",t,"mouse_up",o,n-(r-1),e-(l-1),n,e)if(e==false)then return false end return true end return false end,dragHandler=function(e,r,n,t)if(w)then local l,o=e:getAbsolutePosition()local o=d:sendEvent("mouse_drag",e,"mouse_drag",r,n-(l-1),t-(o-1),x-n,v-t,n,t)x,v=n,t if(o~=nil)then return o end if(e.parent~=nil)then
- e.parent:setFocusedObject(e)end return true end
- if(e:isCoordsInObject(n,t))then
- local e,o=e:getAbsolutePosition(e:getAnchorPosition())x,v=n,t H,A=e-n,o-t end return false end,scrollHandler=function(e,o,t,n)if(e:isCoordsInObject(t,n))then local l,r=e:getAbsolutePosition()local n=d:sendEvent("mouse_scroll",e,"mouse_scroll",o,t-(l-1),n-(r-1))if(n==false)then return false end if(e.parent~=nil)then
- e.parent:setFocusedObject(e)end return true end return false end,hoverHandler=function(e,n,t,o)if(e:isCoordsInObject(n,t))then
- local e=d:sendEvent("mouse_hover",e,"mouse_hover",n,t,o)if(e==false)then return false end S=true return true end
- if(S)then
- local e=d:sendEvent("mouse_leave",e,"mouse_leave",n,t,o)if(e==false)then return false end S=false end return false end,keyHandler=function(e,t,n)if(h)and(u)then
- if(e:isFocused())then
- local e=d:sendEvent("key",e,"key",t,n)if(e==false)then return false end return true end end return
- false end,keyUpHandler=function(e,n)if(h)and(u)then
- if(e:isFocused())then
- local e=d:sendEvent("key_up",e,"key_up",n)if(e==false)then return false end return true end end return
- false end,charHandler=function(e,n)if(h)and(u)then
- if(e:isFocused())then
- local e=d:sendEvent("char",e,"char",n)if(e==false)then return false end return true end end return
- false end,valueChangedHandler=function(e)d:sendEvent("value_changed",e,C)end,eventHandler=function(e,n,...)local t={...}if(n=="timer")and(t[1]==k)then
- if(i[s+1]~=nil)then s=s+1 if(m=="stretch")then
- c=g.resizeBIMG(i,e:getSize())[s]else c=i[s]end local e=i[s].duration or
- i.secondsPerFrame or .2
- k=os.startTimer(e)else
- if(E)then s=1 if(m=="stretch")then
- c=g.resizeBIMG(i,e:getSize())[1]else c=i[1]end local e=i[1].duration or i.secondsPerFrame or .2
- k=os.startTimer(e)end end e:updateDraw()end local e=d:sendEvent("other_event",e,n,...)if(e~=nil)then
- return e end end,customEventHandler=function(e,n,...)if(i~=nil)and(m=="stretch")and(n=="basalt_resize")then
- c=g.resizeBIMG(i,e:getSize())[s]e:updateDraw()end local e=d:sendEvent("custom_event",e,n,...)if(e~=nil)then
- return e end return true end,getFocusHandler=function(e)local e=d:sendEvent("get_focus",e)if(e~=nil)then return e end return true end,loseFocusHandler=function(e)w=false local e=d:sendEvent("lose_focus",e)if(e~=nil)then return e end return true end,init=function(e)if(e.parent~=nil)then for n,t in pairs(a)do
- if(t)then e.parent:addEvent(n,e)end end end if not(P)then P=true return true end return false end}T.__index=T return T end end r["objects"]={}r["objects"]["Input"]=function(...)local e=l("Object")local h=l("utils")local n=l("basaltLogs")local o=h.getValueFromXML
- return
- function(n)local t=e(n)local r="Input"local i="text"local c=0 t:setZIndex(5)t:setValue("")t.width=10 t.height=1
- local e=1 local n=1 local l=""local s local u local d=l local a=false
- local e={getType=function(e)return r end,setInputType=function(n,e)if(e=="password")or(e=="number")or(e=="text")then i=e end n:updateDraw()return n end,setDefaultText=function(e,t,o,n)l=t s=n or s u=o or u
- if(e:isFocused())then d=""else d=l end e:updateDraw()return e end,getInputType=function(e)return
- i end,setValue=function(o,l)t.setValue(o,tostring(l))if not(a)then e=tostring(l):len()+1
- n=math.max(1,e-o:getWidth()+1)if(o:isFocused())then local l,t=o:getAnchorPosition()o.parent:setCursor(true,l+e-n,t+math.floor(o:getHeight()/2),o.fgColor)end end o:updateDraw()return o end,getValue=function(e)local e=t.getValue(e)return i=="number"and tonumber(e)or e end,setInputLimit=function(e,n)c=tonumber(n)or c e:updateDraw()return e end,getInputLimit=function(e)return c end,setValuesByXMLData=function(n,e)t.setValuesByXMLData(n,e)local t,l
- if(o("defaultBG",e)~=nil)then t=o("defaultBG",e)end
- if(o("defaultFG",e)~=nil)then l=o("defaultFG",e)end if(o("default",e)~=nil)then
- n:setDefaultText(o("default",e),l~=nil and colors[l],t~=nil and colors[t])end
- if(o("limit",e)~=nil)then n:setInputLimit(o("limit",e))end if(o("type",e)~=nil)then
- n:setInputType(o("type",e))end return n end,getFocusHandler=function(o)t.getFocusHandler(o)if(o.parent~=nil)then local r,t=o:getAnchorPosition()d=""if(l~="")then
- o:updateDraw()end
- o.parent:setCursor(true,r+e-n,t+math.max(math.ceil(o:getHeight()/2-1,1)),o.fgColor)end end,loseFocusHandler=function(e)t.loseFocusHandler(e)if(e.parent~=nil)then d=l if(l~="")then e:updateDraw()end
- e.parent:setCursor(false)end end,keyHandler=function(o,r)if(t.keyHandler(o,r))then local l,i=o:getSize()a=true
- if(r==keys.backspace)then
- local t=tostring(t.getValue())if(e>1)then
- o:setValue(t:sub(1,e-2)..t:sub(e,t:len()))if(e>1)then e=e-1 end
- if(n>1)then if(e<n)then n=n-1 end end end end if(r==keys.enter)then if(o.parent~=nil)then end end
- if(r==keys.right)then
- local t=tostring(t.getValue()):len()e=e+1 if(e>t)then e=t+1 end if(e<1)then e=1 end if(e<n)or(e>=l+n)then n=e-l+1 end if(n<1)then n=1 end end
- if(r==keys.left)then e=e-1 if(e>=1)then
- if(e<n)or(e>=l+n)then n=e end end if(e<1)then e=1 end if(n<1)then n=1 end end local r,d=o:getAnchorPosition()local t=tostring(t.getValue())local e=(e<=t:len()and e-1 or t:len())-(n-1)local n=o:getX()if(e>n+l-1)then e=n+l-1 end if(o.parent~=nil)then
- o.parent:setCursor(true,r+e,d+math.max(math.ceil(i/2-1,1)),o.fgColor)end
- o:updateDraw()a=false return true end return false end,charHandler=function(o,r)if(t.charHandler(o,r))then a=true local d,s=o:getSize()local l=t.getValue()if(l:len()<c or c<=0)then
- if(i=="number")then local n=l
- if(e==1 and r=="-")or(r==".")or(tonumber(r)~=nil)then
- o:setValue(l:sub(1,e-1)..r..l:sub(e,l:len()))e=e+1 if(r==".")or(r=="-")and(#l>0)then
- if(tonumber(t.getValue())==nil)then o:setValue(n)e=e-1 end end end else
- o:setValue(l:sub(1,e-1)..r..l:sub(e,l:len()))e=e+1 end if(e>=d+n)then n=n+1 end end local r,l=o:getAnchorPosition()local t=tostring(t.getValue())local e=(e<=t:len()and e-1 or t:len())-(n-1)local n=o:getX()if(e>n+d-1)then e=n+d-1 end if(o.parent~=nil)then
- o.parent:setCursor(true,r+e,l+math.max(math.ceil(s/2-1,1)),o.fgColor)end a=false
- o:updateDraw()return true end return false end,mouseHandler=function(o,r,l,a)if(t.mouseHandler(o,r,l,a))then local r,a=o:getAnchorPosition()local i,d=o:getAbsolutePosition(r,a)local c,d=o:getSize()e=l-i+n local t=t.getValue()if(e>t:len())then e=t:len()+1 end if(e<n)then n=e-1
- if(n<1)then n=1 end end
- o.parent:setCursor(true,r+e-n,a+math.max(math.ceil(d/2-1,1)),o.fgColor)return true end end,dragHandler=function(e,l,o,n,a,r)if(e:isFocused())then if(e:isCoordsInObject(o,n))then
- if(t.dragHandler(e,l,o,n,a,r))then return true end end
- e.parent:removeFocusedObject()end end,eventHandler=function(o,r,l,...)t.eventHandler(o,r,l,...)if(r=="paste")then
- if(o:isFocused())then local r=t.getValue()local d,c=o:getSize()a=true
- if(i=="number")then local n=r
- if(l==".")or(tonumber(l)~=nil)then
- o:setValue(r:sub(1,e-1)..l..r:sub(e,r:len()))e=e+l:len()end
- if(tonumber(t.getValue())==nil)then o:setValue(n)end else
- o:setValue(r:sub(1,e-1)..l..r:sub(e,r:len()))e=e+l:len()end if(e>=d+n)then n=(e+1)-d end
- local l,r=o:getAnchorPosition()local t=tostring(t.getValue())local e=(e<=t:len()and e-1 or t:len())-(n-1)local n=o:getX()if(e>n+d-1)then e=n+d-1 end if(o.parent~=nil)then
- o.parent:setCursor(true,l+e,r+math.max(math.ceil(c/2-1,1)),o.fgColor)end
- o:updateDraw()a=false end end end,draw=function(o)if(t.draw(o))then
- if(o.parent~=nil)then local f,c=o:getAnchorPosition()local a,l=o:getSize()local r=h.getTextVerticalAlign(l,"center")if(o.bgColor~=false)then
- o.parent:drawBackgroundBox(f,c,a,l,o.bgColor)end
- for h=1,l do
- if(h==r)then
- local t=tostring(t.getValue())local l=o.bgColor local r=o.fgColor local e if(t:len()<=0)then e=d
- l=s or l r=u or r end e=d
- if(t~="")then e=t end e=e:sub(n,a+n-1)local n=a-e:len()if(n<0)then
- n=0 end if(i=="password")and(t~="")then
- e=string.rep("*",e:len())end
- e=e..string.rep(o.bgSymbol,n)o.parent:writeText(f,c+(h-1),e,l,r)end end if(o:isFocused())then
- o.parent:setCursor(true,f+e-n,c+math.floor(o:getHeight()/2),o.fgColor)end end end end,init=function(e)if(e.parent~=nil)then e.parent:addEvent("mouse_click",e)e.parent:addEvent("key",e)e.parent:addEvent("char",e)e.parent:addEvent("other_event",e)e.parent:addEvent("mouse_drag",e)end
- if(t.init(e))then
- e.bgColor=e.parent:getTheme("InputBG")e.fgColor=e.parent:getTheme("InputText")end end}return setmetatable(e,t)end end
- r["objects"]["Button"]=function(...)local n=l("Object")local o=l("utils")local t=o.getValueFromXML local c=l("tHex")return
- function(e)local e=n(e)local a="Button"local l="center"local r="center"e:setZIndex(5)e:setValue("Button")e.width=12 e.height=3
- local n={init=function(n)if(e.init(n))then
- n.bgColor=n.parent:getTheme("ButtonBG")n.fgColor=n.parent:getTheme("ButtonText")end end,getType=function(e)return a end,setHorizontalAlign=function(e,n)l=n e:updateDraw()return e end,setVerticalAlign=function(e,n)r=n
- e:updateDraw()return e end,setText=function(n,t)e:setValue(tostring(t))n:updateDraw()return n end,setValuesByXMLData=function(o,n)e.setValuesByXMLData(o,n)if(t("text",n)~=nil)then o:setText(t("text",n))end if(t("horizontalAlign",n)~=nil)then
- l=t("horizontalAlign",n)end if(t("verticalAlign",n)~=nil)then
- r=t("verticalAlign",n)end return o end,draw=function(n)if(e.draw(n))then
- if(n.parent~=nil)then local d,i=n:getAnchorPosition()local a,e=n:getSize()local r=o.getTextVerticalAlign(e,r)for t=1,e do
- if(t==r)then
- local e=n:getValue()n.parent:setText(d+(a/2-e:len()/2),i+(t-1),o.getTextHorizontalAlign(e,e:len(),l))n.parent:setFG(d+(a/2-e:len()/2),i+(t-1),o.getTextHorizontalAlign(c[n.fgColor]:rep(e:len()),e:len(),l))end end end end end}return setmetatable(n,e)end end
- r["objects"]["Graphic"]=function(...)local e=l("Object")local n=l("tHex")local n=l("utils").getValueFromXML local i=l("bimg")local d=l("images")local n,n,n,n=string.sub,string.len,math.max,math.min
- return
- function(n)local r=e(n)local c="Graphic"local e=i()local n=e.getFrameObject(1)local t
- local a=1 r:setZIndex(5)local l,o=0,0
- local e={getType=function(e)return c end,setOffset=function(e,t,n,r)if(r)then
- l=l+t or 0 o=o+n or 0 else l=t or l o=n or o end e:updateDraw()return e end,getOffset=function(e)return
- l,o end,setValuesByXMLData=function(e,n)r.setValuesByXMLData(e,n)return e end,selectFrame=function(l,o)if(e.getFrameObject(o)==nil)then e.addFrame(o)end
- n=e.getFrameObject(o)t=n.getImage(o)a=o l:updateDraw()end,addFrame=function(t,n)e.addFrame(n)return t end,getFrameMetadata=function(o,t,n)return e.getFrameData(t,n)end,setFrameMetadata=function(o,l,t,n)e.setFrameData(l,t,n)return o end,getMetadata=function(t,n)return e.getMetadata(n)end,setMetadata=function(o,n,t)return
- e.setMetadata(n,t)end,getFrame=function(t,n)return e.getFrame(n)end,getFrameObject=function(t,n)return
- e.getFrameObject(n)end,removeFrame=function(n,t)e.removeFrame(t)return n end,moveFrame=function(t,o,n)e.moveFrame(o,n)return t end,getFrames=function(n)return e.getFrames()end,getFrameCount=function(n)return#e.getFrames()end,getSelectedFrame=function(e)return a end,blit=function(e,r,a,i,o,l)x=o or x y=l or y n.blit(r,a,i,x,y)t=n.getImage()e:updateDraw()return e end,setText=function(e,r,l,o)x=l or x y=o or y n.text(r,x,y)t=n.getImage()e:updateDraw()return e end,setBg=function(e,l,r,o)x=r or x y=o or y n.bg(l,x,y)t=n.getImage()e:updateDraw()return e end,setFg=function(e,o,l,r)x=l or x y=r or
- y n.fg(o,x,y)t=n.getImage()e:updateDraw()return e end,getImageSize=function(n)return e.getSize()end,setImageSize=function(o,l,r)e.setSize(l,r)t=n.getImage()o:updateDraw()return o end,resizeImage=function(o,r,l)local l=d.resizeBIMG(e.createBimg(),r,l)e=i(l)a=1 n=e.getFrameObject(1)t=n.getImage()o:updateDraw()return o end,loadImage=function(o,l)if(fs.exists(l))then local l=d.loadBIMG(l)e=i(l)a=1
- n=e.getFrameObject(1)t=n.getImage()o:updateDraw()end return o end,clear=function(n)e=i()t=nil n:updateDraw()return n end,getImage=function(n)return
- e.createBimg()end,draw=function(e)if(r.draw(e))then
- if(e.parent~=nil)then
- local i,r=e:getAnchorPosition()local n,a=e:getSize()if(t~=nil)then
- for n,t in pairs(t)do if(n<=a-o)and(n+o>=1)then
- e.parent:blit(i+l,r+n-1+o,t[1],t[2],t[3])end end end end end end,init=function(e)if(r.init(e))then e.bgColor=e.parent:getTheme("GraphicBG")end end}return setmetatable(e,r)end end
- r["objects"]["Checkbox"]=function(...)local e=l("Object")local t=l("utils")local o=t.getValueFromXML
- return
- function(n)local n=e(n)local e="Checkbox"n:setZIndex(5)n:setValue(false)n.width=1 n.height=1 local a="\42"local e={getType=function(n)return e end,setSymbol=function(e,n)a=n
- e:updateDraw()return e end,mouseHandler=function(e,t,l,o)if(n.mouseHandler(e,t,l,o))then
- if(t==1)then
- if(e:getValue()~=true)and(e:getValue()~=false)then
- e:setValue(false)else e:setValue(not e:getValue())end e:updateDraw()return true end end return false end,touchHandler=function(e,n,t)return
- e:mouseHandler(1,n,t)end,setValuesByXMLData=function(e,t)n.setValuesByXMLData(e,t)if(o("checked",t)~=nil)then if(o("checked",t))then e:setValue(true)else
- e:setValue(false)end end return e end,draw=function(e)if(n.draw(e))then
- if(e.parent~=nil)then local r,l=e:getAnchorPosition()local o,n=e:getSize()local i=t.getTextVerticalAlign(n,"center")if(e.bgColor~=false)then
- e.parent:drawBackgroundBox(r,l,o,n,e.bgColor)end
- for n=1,n do
- if(n==i)then
- if(e:getValue()==true)then
- e.parent:writeText(r,l+(n-1),t.getTextHorizontalAlign(a,o,"center"),e.bgColor,e.fgColor)else
- e.parent:writeText(r,l+(n-1),t.getTextHorizontalAlign(" ",o,"center"),e.bgColor,e.fgColor)end end end end end end,init=function(e)e.parent:addEvent("mouse_click",e)e.parent:addEvent("mouse_up",e)if(n.init(e))then
- e.bgColor=e.parent:getTheme("CheckboxBG")e.fgColor=e.parent:getTheme("CheckboxText")end end}return setmetatable(e,n)end end
- r["objects"]["Label"]=function(...)local n=l("Object")local d=l("utils")local t=d.getValueFromXML local i=d.createText local e=l("tHex")local f=l("bigfont")return
- function(e)local n=n(e)local e="Label"n:setZIndex(3)local l=true n:setValue("Label")n.width=5
- local c="left"local r="top"local a=0 local u,s=false,false
- local e={getType=function(n)return e end,setText=function(e,t)t=tostring(t)n:setValue(t)if(l)then local o=e.parent:getOffset()if(t:len()+e:getX()>e.parent:getWidth()+o)then local o=e.parent:getWidth()+o-e:getX()n.setSize(e,o,#i(t,o))else
- n.setSize(e,t:len(),1)end end e:updateDraw()return e end,setBackground=function(e,t)n.setBackground(e,t)s=true e:updateDraw()return e end,setForeground=function(e,t)n.setForeground(e,t)u=true e:updateDraw()return e end,setTextAlign=function(e,n,t)c=n or c r=t or r e:updateDraw()return e end,setFontSize=function(n,e)if(e>0)and(e<=4)then a=e-1 or 0 end
- n:updateDraw()return n end,getFontSize=function(e)return a+1 end,setValuesByXMLData=function(o,e)n.setValuesByXMLData(o,e)if(t("text",e)~=nil)then o:setText(t("text",e))end
- if(t("verticalAlign",e)~=nil)then r=t("verticalAlign",e)end if(t("horizontalAlign",e)~=nil)then
- c=t("horizontalAlign",e)end if(t("font",e)~=nil)then
- o:setFontSize(t("font",e))end return o end,setSize=function(e,t,o,r)n.setSize(e,t,o,r)l=false e:updateDraw()return e end,eventHandler=function(e,t)if(t=="basalt_resize")then
- if(l)then local t=e:getValue()if(t:len()+e:getX()>e.parent:getWidth())then local o=e.parent:getWidth()-e:getX()n.setSize(e,o,#i(t,o))else n.setSize(e,t:len(),1)end else end end end,draw=function(e)if(n.draw(e))then
- if(e.parent~=nil)then local n,t=e:getAnchorPosition()local c,o=e:getSize()local r=d.getTextVerticalAlign(o,r)if(a==0)then
- if not(l)then
- local l=i(e:getValue(),e:getWidth())for l,r in pairs(l)do if(l<=o)then
- e.parent:writeText(n,t+l-1,r,e.bgColor,e.fgColor)end end else
- if(#e:getValue()+n>e.parent:getWidth())then local l=i(e:getValue(),e:getWidth())for l,r in
- pairs(l)do if(l<=o)then
- e.parent:writeText(n,t+l-1,r,e.bgColor,e.fgColor)end end else
- e.parent:writeText(n,t,e:getValue(),e.bgColor,e.fgColor)end end else
- local o=f(a,e:getValue(),e.fgColor,e.bgColor or colors.lightGray)if(l)then e:setSize(#o[1][1],#o[1]-1)end local i,a=e.parent:getSize()local r,l=#o[1][1],#o[1]n=n or math.floor((i-r)/2)+1
- t=t or math.floor((a-l)/2)+1
- for l=1,l do
- e.parent:setFG(n,t+l-1,o[2][l])e.parent:setBG(n,t+l-1,o[3][l])e.parent:setText(n,t+l-1,o[1][l])end end end end end,init=function(e)e.parent:addEvent("other_event",e)if(n.init(e))then
- e.bgColor=e.parent:getTheme("LabelBG")e.fgColor=e.parent:getTheme("LabelText")if(e.parent.bgColor==colors.black)and(e.fgColor==colors.black)then e.fgColor=colors.lightGray end end end}return setmetatable(e,n)end end
- r["objects"]["Image"]=function(...)local e=l("Object")local c=l("utils").getValueFromXML local d=l("images")local s,a=table.unpack,string.sub
- return
- function(n)local o=e(n)local u="Image"o:setZIndex(2)local e local l local n=1 local i=false local t local r=false o.width=24
- o.height=8
- local function f(t)if(e~=nil)then local n={}for t,e in pairs(colors)do if(type(e)=="number")then
- n[t]={term.nativePaletteColor(e)}end end if(e.palette~=nil)then
- for t,e in pairs(e.palette)do n[t]=tonumber(e)end end
- if(e[t]~=nil)and(e[t].palette~=nil)then for e,t in pairs(e[t].palette)do
- n[e]=tonumber(t)end end return n end end
- local e={init=function(e)if(o.init(e))then
- e.bgColor=e.parent:getTheme("ImageBG")end end,getType=function(e)return
- u end,loadImage=function(r,o,a)if not(fs.exists(o))then
- error("No valid path: "..o)end e=d.loadImageAsBimg(o,a)n=1 l=e if(t~=nil)then os.cancelTimer(t)end
- r:updateDraw()return r end,setImage=function(o,r)e=r l=e n=1 if(t~=nil)then os.cancelTimer(t)end
- o:updateDraw()return o end,usePalette=function(n,e)r=e~=nil and e or true return n end,play=function(o,l)if(e.animated)then
- local e=e[n].duration or e.secondsPerFrame or .2 o.parent:addEvent("other_event",o)t=os.startTimer(e)i=l or false end return o end,selectFrame=function(l,o)if(e[o]~=nil)then n=o if(t~=nil)then os.cancelTimer(t)end
- l:updateDraw()end end,eventHandler=function(l,r,a,...)o.eventHandler(l,r,a,...)if(r=="timer")then
- if(a==t)then
- if(e[n+1]~=nil)then n=n+1 local e=e[n].duration or e.secondsPerFrame or .2
- t=os.startTimer(e)else
- if(i)then n=1
- local e=e[n].duration or e.secondsPerFrame or .2 t=os.startTimer(e)end end l:updateDraw()end end end,getMetadata=function(t,n)return
- e[n]end,getImageSize=function(n)return e.width,e.height end,resizeImage=function(n,t,o)l=d.resizeBIMG(e,t,o)n:updateDraw()return n end,setValuesByXMLData=function(e,n)o.setValuesByXMLData(e,n)if(c("path",n)~=nil)then e:loadImage(c("path",n))end return e end,draw=function(e)if(o.draw(e))then
- if(l~=nil)then if(r)then
- e:getBaseFrame():setThemeColor(f(n))end local i,c=e:getAnchorPosition()local r,d=e:getSize()for l,n in ipairs(l[n])do local o,t,n=s(n)o=a(o,1,r)t=a(t,1,r)n=a(n,1,r)e.parent:blit(i,c+l-1,o,t,n)if(l==d)then break end end end end end}return setmetatable(e,o)end end
- r["objects"]["Menubar"]=function(...)local e=l("Object")local n=l("utils")local t=n.getValueFromXML local c=l("tHex")return
- function(n)local l=e(n)local a="Menubar"local h={}l.width=30 l.height=1
- l:setZIndex(5)local e={}local s local u local i=true local n="left"local n=0 local o=1 local d=false
- local function f()local n=0 local t=0
- local r=h:getWidth()for l=1,#e do if(t+e[l].text:len()+o*2>r)then
- if(t<r)then
- n=n+(e[l].text:len()+o*2-(r-t))else n=n+e[l].text:len()+o*2 end end t=t+e[l].text:len()+o*2 end return n end
- h={getType=function(e)return a end,addItem=function(n,l,o,t,...)table.insert(e,{text=tostring(l),bgCol=o or n.bgColor,fgCol=t or n.fgColor,args={...}})if(#e==1)then n:setValue(e[1])end
- n:updateDraw()return n end,getAll=function(n)return
- e end,getItemIndex=function(n)local n=n:getValue()for e,t in pairs(e)do
- if(t==n)then return e end end end,clear=function(n)e={}n:setValue({},false)n:updateDraw()return n end,setSpace=function(e,n)o=n or o e:updateDraw()return e end,setOffset=function(t,e)n=e or 0 if(n<0)then n=0 end local e=f()if(n>e)then n=e end
- t:updateDraw()return t end,getOffset=function(e)return n end,setScrollable=function(n,e)d=e if(e==nil)then d=true end return n end,setValuesByXMLData=function(n,e)l.setValuesByXMLData(n,e)if(t("selectionBG",e)~=nil)then
- s=colors[t("selectionBG",e)]end if(t("selectionFG",e)~=nil)then
- u=colors[t("selectionFG",e)]end if(t("scrollable",e)~=nil)then
- if(t("scrollable",e))then n:setScrollable(true)else n:setScrollable(false)end end
- if(t("offset",e)~=nil)then n:setOffset(t("offset",e))end
- if(t("space",e)~=nil)then o=t("space",e)end
- if(e["item"]~=nil)then local e=e["item"]if(e.properties~=nil)then e={e}end for o,e in pairs(e)do
- n:addItem(t("text",e),colors[t("bg",e)],colors[t("fg",e)])end end return n end,removeItem=function(n,t)table.remove(e,t)n:updateDraw()return n end,getItem=function(t,n)return e[n]end,getItemCount=function(n)return#e end,editItem=function(n,t,r,o,l,...)table.remove(e,t)table.insert(e,t,{text=r,bgCol=o or n.bgColor,fgCol=l or n.fgColor,args={...}})n:updateDraw()return n end,selectItem=function(n,t)n:setValue(e[t]or{},false)n:updateDraw()return n end,setSelectedItem=function(e,o,t,n)s=o or e.bgColor u=t or e.fgColor i=n
- e:updateDraw()return e end,mouseHandler=function(t,r,a,i)if(l.mouseHandler(t,r,a,i))then
- local d,c=t:getAbsolutePosition(t:getAnchorPosition())local l,l=t:getSize()local r=0
- for l=1,#e do
- if(e[l]~=nil)then
- if(d+r<=a+n)and(d+r+e[l].text:len()+(o*2)>a+n)and(c==i)then
- t:setValue(e[l])t:getEventSystem():sendEvent(event,t,event,0,a,i,e[l])end r=r+e[l].text:len()+o*2 end end t:updateDraw()return true end return false end,scrollHandler=function(t,e,o,r)if(l.scrollHandler(t,e,o,r))then if(d)then n=n+e if(n<0)then n=0 end local e=f()if(n>e)then n=e end
- t:updateDraw()end return true end return false end,draw=function(t)if(l.draw(t))then
- if(t.parent~=nil)then local d,i=t:getAnchorPosition()local a,l=t:getSize()if(t.bgColor~=false)then
- t.parent:drawBackgroundBox(d,i,a,l,t.bgColor)end local f=""local l=""local r=""for n,e in pairs(e)do
- local n=(" "):rep(o)..e.text..(" "):rep(o)f=f..n
- if(e==t:getValue())then l=l..c[s or e.bgCol or t.bgColor]:rep(n:len())r=r..c[u or e.FgCol or t.fgColor]:rep(n:len())else l=l..c[e.bgCol or t.bgColor]:rep(n:len())r=r..c[e.FgCol or t.fgColor]:rep(n:len())end end
- t.parent:setText(d,i,f:sub(n+1,a+n))t.parent:setBG(d,i,l:sub(n+1,a+n))t.parent:setFG(d,i,r:sub(n+1,a+n))end end end,init=function(e)e.parent:addEvent("mouse_click",e)e.parent:addEvent("mouse_scroll",e)if(l.init(e))then e.bgColor=e.parent:getTheme("MenubarBG")e.fgColor=e.parent:getTheme("MenubarText")s=e.parent:getTheme("SelectionBG")u=e.parent:getTheme("SelectionText")end end}return setmetatable(h,l)end end
- r["objects"]["Dropdown"]=function(...)local n=l("Object")local d=l("utils")local t=l("utils").getValueFromXML
- return
- function(e)local a=n(e)local i="Dropdown"a.width=12 a.height=1 a:setZIndex(6)local e={}local c local s local m=true local u="left"local n=0 local r=16 local l=6 local g="\16"local p="\31"local o=false
- local e={getType=function(e)return
- i end,setValuesByXMLData=function(o,e)a.setValuesByXMLData(o,e)if(t("selectionBG",e)~=nil)then c=colors[t("selectionBG",e)]end if(t("selectionFG",e)~=nil)then
- s=colors[t("selectionFG",e)]end if(t("dropdownWidth",e)~=nil)then
- r=t("dropdownWidth",e)end if(t("dropdownHeight",e)~=nil)then
- l=t("dropdownHeight",e)end if(t("offset",e)~=nil)then
- n=t("offset",e)end
- if(e["item"]~=nil)then local e=e["item"]if(e.properties~=nil)then e={e}end for n,e in pairs(e)do
- o:addItem(t("text",e),colors[t("bg",e)],colors[t("fg",e)])end end end,setOffset=function(e,t)n=t e:updateDraw()return e end,getOffset=function(e)return n end,addItem=function(n,t,o,l,...)table.insert(e,{text=t,bgCol=o or n.bgColor,fgCol=l or n.fgColor,args={...}})n:updateDraw()return n end,getAll=function(n)return
- e end,removeItem=function(n,t)table.remove(e,t)n:updateDraw()return n end,getItem=function(t,n)return e[n]end,getItemIndex=function(n)local t=n:getValue()for n,e in pairs(e)do if(e==t)then return n end end end,clear=function(n)e={}n:setValue({},false)n:updateDraw()return n end,getItemCount=function(n)return#e end,editItem=function(n,t,l,r,o,...)table.remove(e,t)table.insert(e,t,{text=l,bgCol=r or n.bgColor,fgCol=o or n.fgColor,args={...}})n:updateDraw()return n end,selectItem=function(n,t)n:setValue(e[t]or{},false)n:updateDraw()return n end,setSelectedItem=function(e,o,t,n)c=o or e.bgColor s=t or e.fgColor
- m=n~=nil and n e:updateDraw()return e end,setDropdownSize=function(e,n,t)r,l=n,t e:updateDraw()return e end,getDropdownSize=function(e)return r,l end,mouseHandler=function(t,c,i,d)if(o)then
- local a,s=t:getAbsolutePosition(t:getAnchorPosition())if(c==1)then
- if(#e>0)then
- for o=1,l do
- if(e[o+n]~=nil)then
- if(a<=i)and(a+r>i)and(s+o==d)then t:setValue(e[o+n])t:updateDraw()local e=t:getEventSystem():sendEvent("mouse_click",t,"mouse_click",dir,i,d)if(e==false)then return e end return true end end end end end end
- if(a.mouseHandler(t,c,i,d))then o=(not o)t:updateDraw()return true else if(o)then t:updateDraw()o=false end return false end end,mouseUpHandler=function(t,c,a,i)if(o)then
- local d,s=t:getAbsolutePosition(t:getAnchorPosition())if(c==1)then
- if(#e>0)then
- for l=1,l do
- if(e[l+n]~=nil)then
- if(d<=a)and(d+r>a)and(s+l==i)then o=false t:updateDraw()local e=t:getEventSystem():sendEvent("mouse_up",t,"mouse_up",dir,a,i)if(e==false)then return e end return true end end end end end end end,scrollHandler=function(t,r,a,i)if(o)and(t:isFocused())then n=n+r if(n<0)then n=0 end if(r==1)then
- if(#e>l)then if(n>#e-l)then n=#e-l end else n=math.min(#e-1,0)end end
- local e=t:getEventSystem():sendEvent("mouse_scroll",t,"mouse_scroll",r,a,i)if(e==false)then return e end t:updateDraw()return true end end,draw=function(t)if(a.draw(t))then local a,i=t:getAnchorPosition()local f,h=t:getSize()if(t.parent~=nil)then if(t.bgColor~=false)then
- t.parent:drawBackgroundBox(a,i,f,h,t.bgColor)end local h=t:getValue()local f=d.getTextHorizontalAlign((h~=nil and h.text or""),f,u):sub(1,f-1)..(o and p or g)t.parent:writeText(a,i,f,t.bgColor,t.fgColor)if(o)then
- for o=1,l do
- if(e[o+n]~=nil)then
- if(e[o+n]==h)then
- if(m)then
- t.parent:writeText(a,i+o,d.getTextHorizontalAlign(e[o+n].text,r,u),c,s)else
- t.parent:writeText(a,i+o,d.getTextHorizontalAlign(e[o+n].text,r,u),e[o+n].bgCol,e[o+n].fgCol)end else
- t.parent:writeText(a,i+o,d.getTextHorizontalAlign(e[o+n].text,r,u),e[o+n].bgCol,e[o+n].fgCol)end end end end end end end,init=function(e)e.parent:addEvent("mouse_click",e)e.parent:addEvent("mouse_up",e)e.parent:addEvent("mouse_scroll",e)if(a.init(e))then
- e.bgColor=e.parent:getTheme("DropdownBG")e.fgColor=e.parent:getTheme("DropdownText")c=e.parent:getTheme("SelectionBG")s=e.parent:getTheme("SelectionText")end end}return setmetatable(e,a)end end
- r["objects"]["Animation"]=function(...)local t=l("utils").getValueFromXML
- local f=l("basaltEvent")local e,o,s,n,l,i=math.floor,math.sin,math.cos,math.pi,math.sqrt,math.pow
- local c=function(e,n,t)return e+(n-e)*t end local h=function(e)return e end
- local a=function(e)return 1-e end local d=function(e)return e*e*e end local u=function(e)return
- a(d(a(e)))end local z=function(e)return
- c(d(e),u(e),e)end local F=function(e)return
- o((e*n)/2)end local D=function(e)return
- a(s((e*n)/2))end local H=function(e)return-(s(n*x)-1)/2 end
- local E=function(e)local n=1.70158 local t=n+1 return t*e^3-n*e^2 end local V=function(e)return e^3 end
- local M=function(e)local n=(2*n)/3 return
- e==0 and 0 or(e==1 and 1 or(-2^(10*e-10)*o((e*10-10.75)*n)))end
- local function e(e)return e==0 and 0 or 2^(10*e-10)end
- local function P(e)return e==0 and 0 or 2^(10*e-10)end
- local function A(e)local n=1.70158 local n=n*1.525 return
- e<.5 and((2*e)^2*((n+1)*2*e-n))/2 or((2*e-2)^2*((n+1)*(e*2-2)+n)+2)/2 end local function B(e)return
- e<.5 and 4*e^3 or 1-(-2*e+2)^3/2 end
- local function _(e)local n=(2*n)/4.5
- return
- e==0 and 0 or(e==1 and 1 or(e<.5 and-(2^(20*e-10)*o((20*e-11.125)*n))/2 or(2^(-20*e+10)*o((20*e-11.125)*n))/2+1))end
- local function y(e)return
- e==0 and 0 or(e==1 and 1 or(e<.5 and 2^(20*e-10)/2 or(2-2^(-20*e+10))/2))end local function g(e)return
- e<.5 and 2*e^2 or 1-(-2*e+2)^2/2 end local function b(e)return
- e<.5 and 8*e^4 or 1-(-2*e+2)^4/2 end local function p(e)return
- e<.5 and 16*e^5 or 1-(-2*e+2)^5/2 end local function s(e)return e^2 end local function m(e)return e^4 end
- local function w(e)return e^5 end local function v(e)local n=1.70158 local t=n+1 return
- 1+t*(e-1)^3+n*(e-1)^2 end local function S(e)return 1-(1-e)^3 end
- local function k(e)local n=(2*n)/3 return
- e==0 and 0 or(e==1 and 1 or(2^(-10*e)*o((e*10-.75)*n)+1))end
- local function C(e)return e==1 and 1 or 1-2^(-10*e)end local function T(e)return 1-(1-e)*(1-e)end local function I(e)return 1-(1-e)^4 end local function j(e)return 1-(1-e)^5 end
- local function G(e)return 1-l(1-i(e,2))end local function L(e)return l(1-i(e-1,2))end
- local function O(e)return
- e<.5 and(1-l(1-i(2*e,2)))/2 or(l(1-i(-2*e+2,2))+1)/2 end
- local function o(e)local t=7.5625 local n=2.75
- if(e<1/n)then return t*e*e elseif(e<2/n)then local e=e-1.5/n return t*e*e+.75 elseif(e<2.5/n)then local e=e-2.25/n return t*e*e+.9375 else
- local e=e-2.625/n return t*e*e+.984375 end end local function n(e)return 1-o(1-e)end local function l(e)return
- x<.5 and(1-o(1-2*e))/2 or(1+o(2*e-1))/2 end
- local c={linear=h,lerp=c,flip=a,easeIn=d,easeInSine=D,easeInBack=E,easeInCubic=V,easeInElastic=M,easeInExpo=P,easeInQuad=s,easeInQuart=m,easeInQuint=w,easeInCirc=G,easeInBounce=n,easeOut=u,easeOutSine=F,easeOutBack=v,easeOutCubic=S,easeOutElastic=k,easeOutExpo=C,easeOutQuad=T,easeOutQuart=I,easeOutQuint=j,easeOutCirc=L,easeOutBounce=o,easeInOut=z,easeInOutSine=H,easeInOutBack=A,easeInOutCubic=B,easeInOutElastic=_,easeInOutExpo=y,easeInOutQuad=g,easeInOutQuart=b,easeInOutQuint=p,easeInOutCirc=O,easeInOutBounce=l}local a={}return
- function(v)local i={}local x="Animation"local u local n={}local d=0 local _=false local l=1 local p=false
- local m=f()local h=0 local f local b=false local g=false local s="easeOut"local o local function r(e)for t,e in pairs(e)do
- e(i,n[l].t,l)end end
- local function y(e)if(l==1)then
- e:animationStartHandler()end if(n[l]~=nil)then r(n[l].f)d=n[l].t end l=l+1
- if(n[l]==nil)then if(p)then l=1 d=0 else
- e:animationDoneHandler()return end end if(n[l].t>0)then
- u=os.startTimer(n[l].t-d)else y(e)end end
- local function r(e,o)for t=1,#n do
- if(n[t].t==e)then table.insert(n[t].f,o)return end end
- for t=1,#n do
- if(n[t].t>e)then if(n[t-1]~=nil)then if(n[t-1].t<e)then
- table.insert(n,t-1,{t=e,f={o}})return end else
- table.insert(n,t,{t=e,f={o}})return end end end
- if(#n<=0)then table.insert(n,1,{t=e,f={o}})return elseif(n[#n].t<e)then table.insert(n,{t=e,f={o}})end end
- local function w(b,g,l,u,m,p,e,d)local t=o local f,h local n=""if(t.parent~=nil)then
- n=t.parent:getName()end n=n..t:getName()r(u+.05,function()if(e~=nil)then if(a[e]==nil)then a[e]={}end if(a[e][n]~=nil)then
- if(a[e][n]~=d)then a[e][n]:cancel()end end a[e][n]=d end f,h=m(t)end)for o=.05,l+.01,.05 do
- r(u+o,function()local r=math.floor(c.lerp(f,b,c[s](o/l))+.5)local i=math.floor(c.lerp(h,g,c[s](o/l))+.5)p(t,r,i)if(e~=nil)then if(o>=l-.01)then if(a[e][n]==d)then a[e][n]=nil end end end end)end end
- i={name=v,getType=function(e)return x end,getBaseFrame=function(e)if(e.parent~=nil)then
- return e.parent:getBaseFrame()end return e end,setMode=function(n,e)s=e return n end,addMode=function(t,e,n)c[e]=n return t end,generateXMLEventFunction=function(e,t,n)local t=function(n)if(n:sub(1,1)=="#")then
- local n=e:getBaseFrame():getDeepObject(n:sub(2,n:len()))if(n~=nil)and(n.internalObjetCall~=nil)then t(e,function()n:internalObjetCall()end)end else
- t(e,e:getBaseFrame():getVariable(n))end end if(type(n)=="string")then t(n)elseif(type(n)=="table")then
- for n,e in pairs(n)do t(e)end end return e end,setValuesByXMLData=function(n,e)b=t("loop",e)==true and true or false
- if(t("object",e)~=nil)then
- local o=n:getBaseFrame():getDeepObject(t("object",e))if(o==nil)then
- o=n:getBaseFrame():getVariable(t("object",e))end
- if(o~=nil)then n:setObject(o)end end
- if(e["move"]~=nil)then local o=t("x",e["move"])local l=t("y",e["move"])local r=t("duration",e["move"])local e=t("time",e["move"])n:move(o,l,r,e)end
- if(e["size"]~=nil)then local o=t("width",e["size"])local r=t("height",e["size"])local l=t("duration",e["size"])local e=t("time",e["size"])n:size(o,r,l,e)end
- if(e["offset"]~=nil)then local r=t("x",e["offset"])local o=t("y",e["offset"])local l=t("duration",e["offset"])local e=t("time",e["offset"])n:offset(r,o,l,e)end
- if(e["textColor"]~=nil)then
- local o=t("duration",e["textColor"])local l=t("time",e["textColor"])local t={}local e=e["textColor"]["color"]if(e~=nil)then if(e.properties~=nil)then e={e}end for n,e in pairs(e)do
- table.insert(t,colors[e:value()])end end if(o~=nil)and(#t>0)then
- n:changeTextColor(o,l or 0,table.unpack(t))end end
- if(e["background"]~=nil)then
- local o=t("duration",e["background"])local l=t("time",e["background"])local t={}local e=e["background"]["color"]if(e~=nil)then if(e.properties~=nil)then e={e}end for n,e in pairs(e)do
- table.insert(t,colors[e:value()])end end if(o~=nil)and(#t>0)then
- n:changeBackground(o,l or 0,table.unpack(t))end end
- if(e["text"]~=nil)then local o=t("duration",e["text"])local l=t("time",e["text"])local t={}local e=e["text"]["text"]if(e~=nil)then if(e.properties~=nil)then
- e={e}end for n,e in pairs(e)do
- table.insert(t,e:value())end end if(o~=nil)and(#t>0)then
- n:changeText(o,l or 0,table.unpack(t))end end if(t("onDone",e)~=nil)then
- n:generateXMLEventFunction(n.onDone,t("onDone",e))end if(t("onStart",e)~=nil)then
- n:generateXMLEventFunction(n.onDone,t("onStart",e))end
- if(t("autoDestroy",e)~=nil)then if(t("autoDestroy",e))then g=true end end s=t("mode",e)or s
- if(t("play",e)~=nil)then if(t("play",e))then n:play(b)end end return n end,getZIndex=function(e)return
- 1 end,getName=function(e)return e.name end,setObject=function(n,e)o=e return n end,move=function(e,a,r,l,n,t)o=t or o
- w(a,r,l,n or 0,o.getPosition,o.setPosition,"position",e)return e end,offset=function(e,n,t,l,a,r)o=r or o
- w(n,t,l,a or 0,o.getOffset,o.setOffset,"offset",e)return e end,size=function(e,a,l,r,t,n)o=n or
- o
- w(a,l,r,t or 0,o.getSize,o.setSize,"size",e)return e end,changeText=function(l,a,e,...)local n={...}e=e or 0 o=obj or o for t=1,#n do
- r(e+t*(a/#n),function()o.setText(o,n[t])end)end return l end,changeBackground=function(a,l,n,...)local e={...}n=n or 0 o=obj or o for t=1,#e do
- r(n+t*(l/#e),function()o.setBackground(o,e[t])end)end return a end,changeTextColor=function(a,l,n,...)local e={...}n=n or 0 o=obj or o for t=1,#e do
- r(n+t*(l/#e),function()o.setForeground(o,e[t])end)end return a end,add=function(t,e,o)f=e
- r((o or h)+(n[#n]~=nil and n[#n].t or 0),e)return t end,wait=function(e,n)h=n return e end,rep=function(e,t)if(f~=nil)then for e=1,t or 1 do
- r((wait or h)+(n[#n]~=nil and n[#n].t or 0),f)end end return e end,onDone=function(e,n)m:registerEvent("animation_done",n)return e end,onStart=function(e,n)m:registerEvent("animation_start",n)return e end,setAutoDestroy=function(n,e)g=e~=nil and e or true return n end,animationDoneHandler=function(e)m:sendEvent("animation_done",e)e.parent:removeEvent("other_event",e)if(g)then
- e.parent:removeObject(e)e=nil end end,animationStartHandler=function(e)m:sendEvent("animation_start",e)end,clear=function(e)n={}f=nil h=0 l=1 d=0 p=false return e end,play=function(e,t)e:cancel()_=true p=t and true or false l=1 d=0
- if(n[l]~=nil)then
- if(n[l].t>0)then u=os.startTimer(n[l].t)else y(e)end else e:animationDoneHandler()end e.parent:addEvent("other_event",e)return e end,cancel=function(e)if(u~=nil)then os.cancelTimer(u)p=false end
- _=false e.parent:removeEvent("other_event",e)return e end,internalObjetCall=function(e)e:play(b)end,eventHandler=function(e,o,t)if(_)then
- if(o=="timer")and(t==u)then if(n[l]~=nil)then
- y(e)else e:animationDoneHandler()end end end end}i.__index=i return i end end
- r["objects"]["List"]=function(...)local n=l("Object")local i=l("utils")local t=i.getValueFromXML
- return
- function(e)local l=n(e)local o="List"l.width=16 l.height=6 l:setZIndex(5)local e={}local a local r local u=true local s="left"local n=0 local d=true
- local e={getType=function(e)return o end,addItem=function(n,t,l,o,...)table.insert(e,{text=t,bgCol=l or n.bgColor,fgCol=o or n.fgColor,args={...}})if(#e<=1)then n:setValue(e[1],false)end
- n:updateDraw()return n end,setOffset=function(e,t)n=t e:updateDraw()return e end,getOffset=function(e)return n end,removeItem=function(n,t)table.remove(e,t)n:updateDraw()return n end,getItem=function(t,n)return e[n]end,getAll=function(n)return e end,getItemIndex=function(n)local n=n:getValue()for e,t in pairs(e)do if(t==n)then return e end end end,clear=function(n)e={}n:setValue({},false)n:updateDraw()return n end,getItemCount=function(n)return#e end,editItem=function(n,t,l,o,r,...)table.remove(e,t)table.insert(e,t,{text=l,bgCol=o or n.bgColor,fgCol=r or n.fgColor,args={...}})n:updateDraw()return n end,selectItem=function(n,t)n:setValue(e[t]or{},false)n:updateDraw()return n end,setSelectedItem=function(e,t,o,n)a=t or e.bgColor r=o or e.fgColor u=n~=nil and n or
- true e:updateDraw()return e end,setScrollable=function(n,e)d=e if(e==nil)then d=true end n:updateDraw()return n end,setValuesByXMLData=function(o,e)l.setValuesByXMLData(o,e)if(t("selectionBG",e)~=nil)then
- a=colors[t("selectionBG",e)]end if(t("selectionFG",e)~=nil)then
- r=colors[t("selectionFG",e)]end if(t("scrollable",e)~=nil)then
- if(t("scrollable",e))then o:setScrollable(true)else o:setScrollable(false)end end if(t("offset",e)~=nil)then n=t("offset",e)end
- if(e["item"]~=nil)then local e=e["item"]if(e.properties~=nil)then e={e}end for n,e in pairs(e)do
- o:addItem(t("text",e),colors[t("bg",e)],colors[t("fg",e)])end end return o end,scrollHandler=function(o,t,r,a)if(l.scrollHandler(o,t,r,a))then
- if(d)then local r,l=o:getSize()n=n+t if(n<0)then n=0 end
- if(t>=1)then if(#e>l)then if(n>#e-l)then n=#e-l end if(n>=#e)then n=#e-1 end else n=n-1 end end o:updateDraw()end return true end return false end,mouseHandler=function(t,o,r,a)if(l.mouseHandler(t,o,r,a))then
- local l,d=t:getAbsolutePosition(t:getAnchorPosition())local i,o=t:getSize()if(#e>0)then for o=1,o do
- if(e[o+n]~=nil)then if(l<=r)and(l+i>r)and(d+o-1==a)then
- t:setValue(e[o+n])t:updateDraw()end end end end return true end return false end,dragHandler=function(t,o,e,n)return
- t:mouseHandler(o,e,n)end,touchHandler=function(t,n,e)return
- t:mouseHandler(1,n,e)end,draw=function(o)if(l.draw(o))then
- if(o.parent~=nil)then local d,l=o:getAnchorPosition()local c,t=o:getSize()if(o.bgColor~=false)then
- o.parent:drawBackgroundBox(d,l,c,t,o.bgColor)end
- for t=1,t do
- if(e[t+n]~=nil)then
- if(e[t+n]==o:getValue())then
- if(u)then
- o.parent:writeText(d,l+t-1,i.getTextHorizontalAlign(e[t+n].text,c,s),a,r)else
- o.parent:writeText(d,l+t-1,i.getTextHorizontalAlign(e[t+n].text,c,s),e[t+n].bgCol,e[t+n].fgCol)end else
- o.parent:writeText(d,l+t-1,i.getTextHorizontalAlign(e[t+n].text,c,s),e[t+n].bgCol,e[t+n].fgCol)end end end end end end,init=function(e)e.parent:addEvent("mouse_click",e)e.parent:addEvent("mouse_drag",e)e.parent:addEvent("mouse_scroll",e)if(l.init(e))then e.bgColor=e.parent:getTheme("ListBG")e.fgColor=e.parent:getTheme("ListText")a=e.parent:getTheme("SelectionBG")r=e.parent:getTheme("SelectionText")end end}return setmetatable(e,l)end end
- r["objects"]["Pane"]=function(...)local n=l("Object")local e=l("basaltLogs")return
- function(e)local n=n(e)local e="Pane"local e={getType=function(n)return e end,setBackground=function(e,t,l,o)n.setBackground(e,t,l,o)return e end,init=function(e)if(n.init(e))then
- e.bgColor=e.parent:getTheme("PaneBG")e.fgColor=e.parent:getTheme("PaneBG")end end}return setmetatable(e,n)end end
- r["objects"]["Program"]=function(...)local t=l("Object")local a=l("tHex")local E=l("process")local _=l("utils").getValueFromXML local n=string.sub
- return
- function(e,f)local t=t(e)local D="Program"t:setZIndex(5)local p local m local F={}local function P(g,y,e,d,o)local h,o=1,1
- local u,s=colors.black,colors.white local z=false local c=false local i={}local r={}local l={}local _={}local C local b={}for e=0,15 do local e=2^e
- _[e]={f:getBasaltInstance().getBaseTerm().getPaletteColour(e)}end local function m()C=(" "):rep(e)for n=0,15 do local n=2^n local t=a[n]b[n]=t:rep(e)end end
- local function B()m()local a=C
- local c=b[colors.white]local o=b[colors.black]for t=1,d do
- i[t]=n(i[t]==nil and a or i[t]..a:sub(1,e-i[t]:len()),1,e)l[t]=n(l[t]==nil and c or l[t]..c:sub(1,e-l[t]:len()),1,e)r[t]=n(r[t]==nil and o or r[t]..o:sub(1,e-r[t]:len()),1,e)end t.updateDraw(t)end B()local function m()if
- h>=1 and o>=1 and h<=e and o<=d then else end end
- local function S(s,g,f)local t=h local a=t+#s-1
- if o>=1 and o<=d then
- if t<=e and a>=1 then
- if t==1 and a==e then i[o]=s l[o]=g r[o]=f else local d,c,u
- if t<1 then local o=1-t+1 local e=e-t+1 d=n(s,o,e)c=n(g,o,e)u=n(f,o,e)elseif a>e then local e=e-t+1 d=n(s,1,e)c=n(g,1,e)u=n(f,1,e)else d=s c=g u=f end local p=i[o]local m=l[o]local g=r[o]local f,s,h
- if t>1 then local e=t-1 f=n(p,1,e)..d s=n(m,1,e)..c
- h=n(g,1,e)..u else f=d s=c h=u end
- if a<e then local t=a+1 f=f..n(p,t,e)s=s..n(m,t,e)h=h..n(g,t,e)end i[o]=f l[o]=s r[o]=h end p:updateDraw()end h=a+1 if(c)then m()end end end
- local function w(r,l,o)if(o~=nil)then local t=i[l]if(t~=nil)then
- i[l]=n(t:sub(1,r-1)..o..t:sub(r+(o:len()),e),1,e)end end p:updateDraw()end
- local function x(a,l,o)if(o~=nil)then local t=r[l]if(t~=nil)then
- r[l]=n(t:sub(1,a-1)..o..t:sub(a+(o:len()),e),1,e)end end p:updateDraw()end
- local function v(a,r,o)if(o~=nil)then local t=l[r]if(t~=nil)then
- l[r]=n(t:sub(1,a-1)..o..t:sub(a+(o:len()),e),1,e)end end p:updateDraw()end
- local k=function(e)if type(e)~="number"then
- error("bad argument #1 (expected number, got "..type(e)..")",2)elseif a[e]==nil then
- error("Invalid color (got "..e..")",2)end s=e end
- local T=function(e)if type(e)~="number"then
- error("bad argument #1 (expected number, got "..type(e)..")",2)elseif a[e]==nil then
- error("Invalid color (got "..e..")",2)end u=e end
- local p=function(n,t,l,o)if type(n)~="number"then
- error("bad argument #1 (expected number, got "..type(n)..")",2)end
- if a[n]==nil then error("Invalid color (got "..n..")",2)end local e
- if
- type(t)=="number"and l==nil and o==nil then e={colours.rgb8(t)}_[n]=e else if
- type(t)~="number"then
- error("bad argument #2 (expected number, got "..type(t)..")",2)end if type(l)~="number"then
- error("bad argument #3 (expected number, got "..type(l)..")",2)end if type(o)~="number"then
- error("bad argument #4 (expected number, got "..type(o)..")",2)end e=_[n]e[1]=t
- e[2]=l e[3]=o end end
- local t=function(e)if type(e)~="number"then
- error("bad argument #1 (expected number, got "..type(e)..")",2)end
- if a[e]==nil then error("Invalid color (got "..e..")",2)end local e=_[e]return e[1],e[2],e[3]end
- local e={setCursorPos=function(n,e)if type(n)~="number"then
- error("bad argument #1 (expected number, got "..type(n)..")",2)end if type(e)~="number"then
- error("bad argument #2 (expected number, got "..type(e)..")",2)end h=math.floor(n)o=math.floor(e)if(c)then m()end end,getCursorPos=function()return
- h,o end,setCursorBlink=function(e)if type(e)~="boolean"then
- error("bad argument #1 (expected boolean, got "..type(e)..")",2)end z=e end,getCursorBlink=function()return
- z end,getPaletteColor=t,getPaletteColour=t,setBackgroundColor=T,setBackgroundColour=T,setTextColor=k,setTextColour=k,setPaletteColor=p,setPaletteColour=p,getBackgroundColor=function()return u end,getBackgroundColour=function()return u end,getSize=function()return e,d end,getTextColor=function()return s end,getTextColour=function()return s end,basalt_resize=function(t,n)e,d=t,n B()end,basalt_reposition=function(n,e)g,y=n,e end,basalt_setVisible=function(e)c=e end,drawBackgroundBox=function(t,o,l,n,e)for n=1,n do
- x(t,o+(n-1),a[e]:rep(l))end end,drawForegroundBox=function(e,n,t,o,l)for o=1,o do v(e,n+(o-1),a[l]:rep(t))end end,drawTextBox=function(t,l,o,e,n)for e=1,e do
- w(t,l+(e-1),n:rep(o))end end,writeText=function(l,o,n,t,e)t=t or u e=e or s w(g,o,n)x(l,o,a[t]:rep(n:len()))v(l,o,a[e]:rep(n:len()))end,basalt_update=function()if(f~=nil)then for e=1,d do f:setText(g,y+(e-1),i[e])f:setBG(g,y+(e-1),r[e])f:setFG(g,y+(e-1),l[e])end end end,scroll=function(n)if
- type(n)~="number"then
- error("bad argument #1 (expected number, got "..type(n)..")",2)end
- if n~=0 then local t=C
- local o=b[s]local a=b[u]for e=1,d do local n=e+n
- if n>=1 and n<=d then
- i[e]=i[n]r[e]=r[n]l[e]=l[n]else i[e]=t
- l[e]=o r[e]=a end end end if(c)then m()end end,isColor=function()return
- f:getBasaltInstance().getBaseTerm().isColor()end,isColour=function()return
- f:getBasaltInstance().getBaseTerm().isColor()end,write=function(e)e=tostring(e)if(c)then
- S(e,a[s]:rep(e:len()),a[u]:rep(e:len()))end end,clearLine=function()if(c)then w(1,o,(" "):rep(e))x(1,o,a[u]:rep(e))v(1,o,a[s]:rep(e))end if(c)then m()end end,clear=function()for n=1,d
- do w(1,n,(" "):rep(e))x(1,n,a[u]:rep(e))v(1,n,a[s]:rep(e))end if(c)then m()end end,blit=function(e,n,t)if
- type(e)~="string"then
- error("bad argument #1 (expected string, got "..type(e)..")",2)end if type(n)~="string"then
- error("bad argument #2 (expected string, got "..type(n)..")",2)end if type(t)~="string"then
- error("bad argument #3 (expected string, got "..type(t)..")",2)end
- if#n~=#e or#t~=#e then error("Arguments must be the same length",2)end if(c)then S(e,n,t)end end}return e end t.width=30 t.height=12 local e=P(1,1,t.width,t.height)local n
- local o=false local a={}local function d(o)local l,r=e.getCursorPos()local t,n=o:getAnchorPosition()local a,i=o:getSize()if(t+l-1>=1 and
- t+l-1<=t+a-1 and r+n-1>=1 and
- r+n-1<=n+i-1)then
- o.parent:setCursor(o:isFocused()and e.getCursorBlink(),t+l-1,r+n-1,e.getTextColor())end end
- local function l(t,e,...)local o,e=n:resume(e,...)if(o==false)and(e~=nil)and(e~="Terminated")then
- local n=t:sendEvent("program_error",e)if(n~=false)then error("Basalt Program - "..e)end end
- if(n:getStatus()=="dead")then t:sendEvent("program_done")end end
- local function r(e,c,i,a,r)if(n==nil)then return false end
- if not(n:isDead())then if not(o)then
- local t,n=e:getAbsolutePosition(e:getAnchorPosition(nil,nil,true))l(e,c,i,a-t+1,r-n+1)d(e)end end end
- local function i(e,t,a,r)if(n==nil)then return false end
- if not(n:isDead())then if not(o)then if(e.draw)then
- l(e,t,a,r)d(e)end end end end
- p={getType=function(e)return D end,show=function(n)t.show(n)e.setBackgroundColor(n.bgColor)e.setTextColor(n.fgColor)e.basalt_setVisible(true)return n end,hide=function(n)t.hide(n)e.basalt_setVisible(false)return n end,setPosition=function(n,l,o,r)t.setPosition(n,l,o,r)e.basalt_reposition(n:getAnchorPosition())return n end,setValuesByXMLData=function(n,e)t.setValuesByXMLData(n,e)if(_("path",e)~=nil)then m=_("path",e)end
- if(_("execute",e)~=nil)then if(_("execute",e))then
- if(m~=nil)then n:execute(m)end end end end,getBasaltWindow=function()return
- e end,getBasaltProcess=function()return n end,setSize=function(n,o,l,r)t.setSize(n,o,l,r)e.basalt_resize(n:getWidth(),n:getHeight())return n end,getStatus=function(e)if(n~=nil)then return
- n:getStatus()end return"inactive"end,setEnviroment=function(e,n)F=n or{}return e end,execute=function(t,r,...)m=r or m
- n=E:new(m,e,F,...)e.setBackgroundColor(colors.black)e.setTextColor(colors.white)e.clear()e.setCursorPos(1,1)e.setBackgroundColor(t.bgColor)e.setTextColor(t.fgColor)e.basalt_setVisible(true)l(t)o=false
- if(t.parent~=nil)then
- t.parent:addEvent("mouse_click",t)t.parent:addEvent("mouse_up",t)t.parent:addEvent("mouse_drag",t)t.parent:addEvent("mouse_scroll",t)t.parent:addEvent("key",t)t.parent:addEvent("key_up",t)t.parent:addEvent("char",t)t.parent:addEvent("other_event",t)end return t end,stop=function(e)if(n~=nil)then
- if not(n:isDead())then l(e,"terminate")if(n:isDead())then
- if(e.parent~=nil)then e.parent:setCursor(false)end end end end e.parent:removeEvents(e)return e end,pause=function(e,t)o=t or(not o)if(n~=nil)then if not(n:isDead())then if not(o)then
- e:injectEvents(a)a={}end end end return e end,isPaused=function(e)return
- o end,injectEvent=function(e,t,r,i,d,c,s)if(n~=nil)then
- if not(n:isDead())then if(o==false)or(s)then
- l(e,t,r,i,d,c)else
- table.insert(a,{event=t,args={r,i,d,c}})end end end return e end,getQueuedEvents=function(e)return
- a end,updateQueuedEvents=function(n,e)a=e or a return n end,injectEvents=function(e,t)if(n~=nil)then
- if not(n:isDead())then for t,n in pairs(t)do
- l(e,n.event,table.unpack(n.args))end end end return e end,mouseHandler=function(o,l,n,e)if(t.mouseHandler(o,l,n,e))then r(o,"mouse_click",l,n,e)return true end return false end,mouseUpHandler=function(o,n,e,l)if(t.mouseUpHandler(o,n,e,l))then r(o,"mouse_up",n,e,l)return true end return false end,scrollHandler=function(o,l,e,n)if(t.scrollHandler(o,l,e,n))then r(o,"mouse_scroll",l,e,n)return true end return false end,dragHandler=function(l,o,n,e)if(t.dragHandler(l,o,n,e))then r(l,"mouse_drag",o,n,e)return true end return false end,keyHandler=function(e,o,n)if(t.keyHandler(e,o,n))then i(e,"key",o,n)return true end return
- false end,keyUpHandler=function(n,e)if(t.keyUpHandler(n,e))then i(n,"key_up",e)return true end
- return false end,charHandler=function(n,e)if(t.charHandler(n,e))then i(n,"char",e)return true end
- return false end,getFocusHandler=function(l)t.getFocusHandler(l)if(n~=nil)then
- if not(n:isDead())then
- if not(o)then
- if(l.parent~=nil)then
- local o,r=e.getCursorPos()local n,t=l:getAnchorPosition()local a,i=l:getSize()if(n+o-1>=1 and n+o-1<=n+a-1 and
- r+t-1>=1 and r+t-1<=t+i-1)then
- l.parent:setCursor(e.getCursorBlink(),n+o-1,r+t-1,e.getTextColor())end end end end end end,loseFocusHandler=function(e)t.loseFocusHandler(e)if(n~=nil)then if not(n:isDead())then if(e.parent~=nil)then
- e.parent:setCursor(false)end end end end,customEventHandler=function(o,r,...)t.customEventHandler(o,r,...)if(n==nil)then return end
- if(r=="basalt_resize")then local i,a=e.getSize()local t,r=o:getSize()if(i~=t)or(a~=r)then e.basalt_resize(t,r)if not(n:isDead())then l(o,"term_resize")end end
- e.basalt_reposition(o:getAnchorPosition())end end,eventHandler=function(r,i,u,s,c,d)t.eventHandler(r,i,u,s,c,d)if(n==nil)then return end
- if not(n:isDead())then
- if not(o)then if(i~="terminate")then
- l(r,i,u,s,c,d)end
- if(r:isFocused())then
- local n,t=r:getAnchorPosition()local o,a=e.getCursorPos()if(r.parent~=nil)then
- local l,i=r:getSize()if(n+o-1>=1 and n+o-1<=n+l-1 and
- a+t-1>=1 and a+t-1<=t+i-1)then
- r.parent:setCursor(e.getCursorBlink(),n+o-1,a+t-1,e.getTextColor())end end if(i=="terminate")then l(r,i)r.parent:setCursor(false)return true end end else
- table.insert(a,{event=i,args={u,s,c,d}})end end end,draw=function(n)if(t.draw(n))then
- if(n.parent~=nil)then local t,o=n:getAnchorPosition()local r,l=e.getCursorPos()local a,i=n:getSize()e.basalt_reposition(t,o)e.basalt_update()if(t+r-1>=1 and t+r-1<=t+a-1 and
- l+o-1>=1 and l+o-1<=o+i-1)then
- n.parent:setCursor(n:isFocused()and e.getCursorBlink(),t+r-1,l+o-1,e.getTextColor())end end end end,onError=function(e,...)for t,n in
- pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("program_error",n)end end if(e.parent~=nil)then
- e.parent:addEvent("other_event",e)end return e end,onDone=function(e,...)for t,n in
- pairs(table.pack(...))do if(type(n)=="function")then
- e:registerEvent("program_done",n)end end if(e.parent~=nil)then
- e.parent:addEvent("other_event",e)end return e end,init=function(e)if(t.init(e))then e.bgColor=e.parent:getTheme("ProgramBG")end end}return setmetatable(p,t)end end
- r["objects"]["Progressbar"]=function(...)local n=l("Object")local t=l("utils").getValueFromXML
- return
- function(e)local a=n(e)local o="Progressbar"local n=0 a:setZIndex(5)a:setValue(false)a.width=25 a.height=1 local i local d=""local c=colors.white local u=""local s=0
- local e={init=function(e)if(a.init(e))then e.bgColor=e.parent:getTheme("ProgressbarBG")e.fgColor=e.parent:getTheme("ProgressbarText")i=e.parent:getTheme("ProgressbarActiveBG")end end,getType=function(e)return
- o end,setValuesByXMLData=function(n,e)a.setValuesByXMLData(n,e)if(t("direction",e)~=nil)then s=t("direction",e)end
- if(t("progressColor",e)~=nil)then i=colors[t("progressColor",e)]end
- if(t("progressSymbol",e)~=nil)then d=t("progressSymbol",e)end if(t("backgroundSymbol",e)~=nil)then
- u=t("backgroundSymbol",e)end
- if(t("progressSymbolColor",e)~=nil)then c=colors[t("progressSymbolColor",e)]end if(t("onDone",e)~=nil)then
- n:generateXMLEventFunction(n.onProgressDone,t("onDone",e))end return n end,setDirection=function(e,n)s=n e:updateDraw()return e end,setProgressBar=function(e,n,t,o)i=n or i
- d=t or d c=o or c e:updateDraw()return e end,setBackgroundSymbol=function(e,n)u=n:sub(1,1)e:updateDraw()return e end,setProgress=function(e,t)if(t>=0)and(t<=100)and(n~=t)then n=t e:setValue(n)if(n==100)then
- e:progressDoneHandler()end end
- e:updateDraw()return e end,getProgress=function(e)return
- n end,onProgressDone=function(e,n)e:registerEvent("progress_done",n)return e end,progressDoneHandler=function(e)e:sendEvent("progress_done",e)end,draw=function(e)if(a.draw(e))then
- if(e.parent~=nil)then
- local l,r=e:getAnchorPosition()local o,t=e:getSize()if(e.bgColor~=false)then
- e.parent:drawBackgroundBox(l,r,o,t,e.bgColor)end if(u~="")then
- e.parent:drawTextBox(l,r,o,t,u)end if(e.fgColor~=false)then
- e.parent:drawForegroundBox(l,r,o,t,e.fgColor)end
- if(s==1)then e.parent:drawBackgroundBox(l,r,o,t/100*n,i)e.parent:drawForegroundBox(l,r,o,t/100*n,c)e.parent:drawTextBox(l,r,o,t/100*n,d)elseif(s==2)then
- e.parent:drawBackgroundBox(l,r+math.ceil(t-t/100*n),o,t/100*n,i)e.parent:drawForegroundBox(l,r+math.ceil(t-t/100*n),o,t/100*n,c)e.parent:drawTextBox(l,r+math.ceil(t-t/100*n),o,t/100*n,d)elseif(s==3)then
- e.parent:drawBackgroundBox(l+math.ceil(o-o/100*n),r,o/100*n,t,i)e.parent:drawForegroundBox(l+math.ceil(o-o/100*n),r,o/100*n,t,c)e.parent:drawTextBox(l+math.ceil(o-o/100*n),r,o/100*n,t,d)else
- e.parent:drawBackgroundBox(l,r,o/100*n,t,i)e.parent:drawForegroundBox(l,r,o/100*n,t,c)e.parent:drawTextBox(l,r,o/100*n,t,d)end end end end}return setmetatable(e,a)end end
- r["objects"]["Scrollbar"]=function(...)local t=l("Object")local n=l("utils").getValueFromXML
- return
- function(e)local l=t(e)local f="Scrollbar"l.width=1 l.height=8 l:setValue(1)l:setZIndex(2)local o="vertical"local d=" "local a local i="\127"local r=l.height local e=1 local t=1
- local function u(n,l,c,i)local d,s=n:getAbsolutePosition(n:getAnchorPosition())local a,l=n:getSize()if(o=="horizontal")then
- for o=0,a do
- if(d+o==c)and(s<=i)and(s+l>i)then
- e=math.min(o+1,a-(t-1))n:setValue(r/a*(e))n:updateDraw()end end end
- if(o=="vertical")then
- for o=0,l do
- if(s+o==i)and(d<=c)and(d+a>c)then e=math.min(o+1,l-(t-1))n:setValue(r/l*(e))n:updateDraw()end end end end
- local e={getType=function(e)return f end,setSymbol=function(e,n)d=n:sub(1,1)e:updateDraw()return e end,setValuesByXMLData=function(t,e)l.setValuesByXMLData(t,e)if(n("maxValue",e)~=nil)then r=n("maxValue",e)end if(n("backgroundSymbol",e)~=nil)then
- i=n("backgroundSymbol",e):sub(1,1)end if(n("symbol",e)~=nil)then
- d=n("symbol",e):sub(1,1)end if(n("barType",e)~=nil)then
- o=n("barType",e):lower()end if(n("symbolSize",e)~=nil)then
- t:setSymbolSize(n("symbolSize",e))end if(n("symbolColor",e)~=nil)then
- a=colors[n("symbolColor",e)]end if(n("index",e)~=nil)then
- t:setIndex(n("index",e))end end,setIndex=function(n,l)e=l if(e<1)then e=1 end local a,l=n:getSize()e=math.min(e,(o=="vertical"and l or a)-(t-1))n:setValue(r/(o=="vertical"and l or a)*e)n:updateDraw()return n end,getIndex=function(n)return
- e end,setSymbolSize=function(n,l)t=tonumber(l)or 1
- local a,l=n:getSize()if(o=="vertical")then
- n:setValue(e-1*(r/(l-(t-1)))-(r/(l-(t-1))))elseif(o=="horizontal")then
- n:setValue(e-1*(r/(a-(t-1)))-(r/(a-(t-1))))end n:updateDraw()return n end,setMaxValue=function(e,n)r=n e:updateDraw()return e end,setBackgroundSymbol=function(e,n)i=string.sub(n,1,1)e:updateDraw()return e end,setSymbolColor=function(e,n)a=n
- e:updateDraw()return e end,setBarType=function(e,n)o=n:lower()e:updateDraw()return e end,mouseHandler=function(t,n,o,e)if(l.mouseHandler(t,n,o,e))then
- u(t,n,o,e)return true end return false end,dragHandler=function(n,e,t,o)if(l.dragHandler(n,e,t,o))then u(n,e,t,o)return true end
- return false end,scrollHandler=function(n,a,d,i)if(l.scrollHandler(n,a,d,i))then local i,l=n:getSize()e=e+a if(e<1)then e=1 end
- e=math.min(e,(o=="vertical"and l or i)-(t-1))n:setValue(r/(o=="vertical"and l or i)*e)n:updateDraw()end end,draw=function(n)if(l.draw(n))then
- if(n.parent~=nil)then local r,l=n:getAnchorPosition()local s,c=n:getSize()if(o=="horizontal")then
- n.parent:writeText(r,l,i:rep(e-1),n.bgColor,n.fgColor)n.parent:writeText(r+e-1,l,d:rep(t),a,a)n.parent:writeText(r+e+t-1,l,i:rep(s-(e+t-1)),n.bgColor,n.fgColor)end
- if(o=="vertical")then
- for o=0,c-1 do
- if(e==o+1)then
- for e=0,math.min(t-1,c)do n.parent:writeText(r,l+o+e,d,a,a)end else if(o+1<e)or(o+1>e-1+t)then
- n.parent:writeText(r,l+o,i,n.bgColor,n.fgColor)end end end end end end end,init=function(e)e.parent:addEvent("mouse_click",e)e.parent:addEvent("mouse_drag",e)e.parent:addEvent("mouse_scroll",e)if(l.init(e))then
- e.bgColor=e.parent:getTheme("ScrollbarBG")e.fgColor=e.parent:getTheme("ScrollbarText")a=e.parent:getTheme("ScrollbarSymbolColor")end end}return setmetatable(e,l)end end
- r["objects"]["Radio"]=function(...)local t=l("Object")local e=l("utils")local e=e.getValueFromXML
- return
- function(n)local i=t(n)local n="Radio"i.width=8 i:setZIndex(5)local t={}local a local r
- local l local o local s local d local f=true local c="\7"local u="left"local e={getType=function(e)return n end,setValuesByXMLData=function(t,n)i.setValuesByXMLData(t,n)if(e("selectionBG",n)~=nil)then
- a=colors[e("selectionBG",n)]end if(e("selectionFG",n)~=nil)then
- r=colors[e("selectionFG",n)]end if(e("boxBG",n)~=nil)then
- l=colors[e("boxBG",n)]end if(e("inactiveBoxBG",n)~=nil)then
- s=colors[e("inactiveBoxBG",n)]end if(e("inactiveBoxFG",n)~=nil)then
- d=colors[e("inactiveBoxFG",n)]end if(e("boxFG",n)~=nil)then
- o=colors[e("boxFG",n)]end if(e("symbol",n)~=nil)then
- c=e("symbol",n)end
- if(n["item"]~=nil)then local n=n["item"]if(n.properties~=nil)then n={n}end for o,n in pairs(n)do
- t:addItem(e("text",n),e("x",n),e("y",n),colors[e("bg",n)],colors[e("fg",n)])end end return t end,addItem=function(e,a,r,o,l,n,...)table.insert(t,{x=r or 1,y=o or 1,text=a,bgCol=l or e.bgColor,fgCol=n or e.fgColor,args={...}})if(#t==1)then e:setValue(t[1])end
- e:updateDraw()return e end,getAll=function(e)return
- t end,removeItem=function(e,n)table.remove(t,n)e:updateDraw()return e end,getItem=function(n,e)return t[e]end,getItemIndex=function(e)local o=e:getValue()for e,n in pairs(t)do if(n==o)then return e end end end,clear=function(e)t={}e:setValue({},false)e:updateDraw()return e end,getItemCount=function(e)return#t end,editItem=function(e,n,o,a,i,r,l,...)table.remove(t,n)table.insert(t,n,{x=a or 1,y=i or 1,text=o,bgCol=r or e.bgColor,fgCol=l or e.fgColor,args={...}})e:updateDraw()return e end,selectItem=function(e,n)e:setValue(t[n]or{},false)e:updateDraw()return e end,setActiveSymbol=function(e,n)c=n:sub(1,1)e:updateDraw()return e end,setSelectedItem=function(n,c,i,d,t,e)a=c or a r=i or r l=d or l o=t or o
- f=e~=nil and e or true n:updateDraw()return n end,mouseHandler=function(e,a,o,r)if(#t>0)then
- local l,i=e:getAbsolutePosition(e:getAnchorPosition())for t,n in pairs(t)do
- if(l+n.x-1<=o)and(l+n.x-1+n.text:len()+1>=o)and(i+n.y-1==r)then
- e:setValue(n)local n=e:getEventSystem():sendEvent("mouse_click",e,"mouse_click",a,o,r)if(n==false)then return n end if(e.parent~=nil)then
- e.parent:setFocusedObject(e)end e:updateDraw()return true end end end return false end,draw=function(n)if(n.parent~=nil)then local d,i=n:getAnchorPosition()for t,e in pairs(t)do
- if(e==n:getValue())then if(u=="left")then
- n.parent:writeText(e.x+d-1,e.y+i-1,c,l,o)n.parent:writeText(e.x+2+d-1,e.y+i-1,e.text,a,r)end else
- n.parent:drawBackgroundBox(e.x+d-1,e.y+i-1,1,1,s or n.bgColor)n.parent:writeText(e.x+2+d-1,e.y+i-1,e.text,e.bgCol,e.fgCol)end end return true end end,init=function(e)e.parent:addEvent("mouse_click",e)if(i.init(e))then
- e.bgColor=e.parent:getTheme("MenubarBG")e.fgColor=e.parent:getTheme("MenubarFG")a=e.parent:getTheme("SelectionBG")r=e.parent:getTheme("SelectionText")l=e.parent:getTheme("MenubarBG")o=e.parent:getTheme("MenubarText")end end}return setmetatable(e,i)end end
- r["objects"]["Slider"]=function(...)local e=l("Object")local n=l("basaltLogs")local n=l("utils").getValueFromXML
- return
- function(t)local l=e(t)local f="Slider"l.width=8 l.height=1 l:setValue(1)local o="horizontal"local d=" "local a local i="\140"local r=l.width local e=1 local t=1
- local function u(n,l,i,c)local d,s=n:getAbsolutePosition(n:getAnchorPosition())local a,l=n:getSize()if(o=="horizontal")then
- for o=0,a do
- if(d+o==i)and(s<=c)and(s+l>c)then
- e=math.min(o+1,a-(t-1))n:setValue(r/a*(e))n:updateDraw()end end end
- if(o=="vertical")then
- for o=0,l do
- if(s+o==c)and(d<=i)and(d+a>i)then e=math.min(o+1,l-(t-1))n:setValue(r/l*(e))n:updateDraw()end end end end
- local e={getType=function(e)return f end,setSymbol=function(e,n)d=n:sub(1,1)e:updateDraw()return e end,setValuesByXMLData=function(t,e)l.setValuesByXMLData(t,e)if(n("maxValue",e)~=nil)then r=n("maxValue",e)end if(n("backgroundSymbol",e)~=nil)then
- i=n("backgroundSymbol",e):sub(1,1)end if(n("barType",e)~=nil)then
- o=n("barType",e):lower()end if(n("symbol",e)~=nil)then
- d=n("symbol",e):sub(1,1)end if(n("symbolSize",e)~=nil)then
- t:setSymbolSize(n("symbolSize",e))end if(n("symbolColor",e)~=nil)then
- a=colors[n("symbolColor",e)]end if(n("index",e)~=nil)then
- t:setIndex(n("index",e))end end,setIndex=function(n,l)e=l if(e<1)then e=1 end local a,l=n:getSize()e=math.min(e,(o=="vertical"and l or a)-(t-1))n:setValue(r/(o=="vertical"and l or a)*e)n:updateDraw()return n end,getIndex=function(n)return
- e end,setSymbolSize=function(n,l)t=tonumber(l)or 1
- if(o=="vertical")then
- n:setValue(e-1*(r/(h-(t-1)))-(r/(h-(t-1))))elseif(o=="horizontal")then
- n:setValue(e-1*(r/(w-(t-1)))-(r/(w-(t-1))))end n:updateDraw()return n end,setMaxValue=function(n,e)r=e return n end,setBackgroundSymbol=function(e,n)i=string.sub(n,1,1)e:updateDraw()return e end,setSymbolColor=function(e,n)a=n e:updateDraw()return e end,setBarType=function(e,n)o=n:lower()e:updateDraw()return e end,mouseHandler=function(t,o,n,e)if(l.mouseHandler(t,o,n,e))then
- u(t,o,n,e)return true end return false end,dragHandler=function(e,o,n,t)if(l.dragHandler(e,o,n,t))then u(e,o,n,t)return true end
- return false end,scrollHandler=function(n,a,i,d)if(l.scrollHandler(n,a,i,d))then local l,i=n:getSize()e=e+a if(e<1)then e=1 end
- e=math.min(e,(o=="vertical"and i or l)-(t-1))n:setValue(r/(o=="vertical"and i or l)*e)n:updateDraw()return true end return false end,draw=function(n)if(l.draw(n))then
- if(n.parent~=nil)then local l,r=n:getAnchorPosition()local s,c=n:getSize()if(o=="horizontal")then
- n.parent:writeText(l,r,i:rep(e-1),n.bgColor,n.fgColor)n.parent:writeText(l+e-1,r,d:rep(t),a,a)n.parent:writeText(l+e+t-1,r,i:rep(s-(e+t-1)),n.bgColor,n.fgColor)end
- if(o=="vertical")then
- for o=0,c-1 do
- if(e==o+1)then
- for e=0,math.min(t-1,c)do n.parent:writeText(l,r+o+e,d,a,a)end else if(o+1<e)or(o+1>e-1+t)then
- n.parent:writeText(l,r+o,i,n.bgColor,n.fgColor)end end end end end end end,init=function(e)e.parent:addEvent("mouse_click",e)e.parent:addEvent("mouse_drag",e)e.parent:addEvent("mouse_scroll",e)if(l.init(e))then
- e.bgColor=e.parent:getTheme("SliderBG")e.fgColor=e.parent:getTheme("SliderText")a=e.parent:getTheme("SliderSymbolColor")end end}return setmetatable(e,l)end end
- r["objects"]["Textfield"]=function(...)local n=l("Object")local i=l("tHex")local b=l("utils").getValueFromXML local e=l("basaltLogs")local g,B,S,v,e=string.rep,string.find,string.gmatch,string.sub,string.len
- return
- function(e)local d=n(e)local k="Textfield"local l,o,n,e=1,1,1,1 local t={" "}local r={""}local a={""}local p={}local m={}local u,c,f,s local T,C=colors.lightBlue,colors.black d.width=30
- d.height=12 d:setZIndex(5)local function y()if(u~=nil)and(c~=nil)and(f~=nil)and(s~=nil)then return true end return false end
- local function _()local e,t,n,o
- if(y())then if(u>c)then e,t=c,u else e,t=u,c end if(f>s)then
- n,o=s,f else n,o=f,s end end return e,t,n,o end local function h()end
- local function w(p)local i,d,h,m=_(p)for e=m,h,-1 do
- if(e==h)or(e==m)then local o=t[e]local l=r[e]local n=a[e]if(e==h)and(e==m)then o=o:sub(1,i-1)..o:sub(d+1,o:len())l=l:sub(1,i-1)..l:sub(d+1,l:len())n=n:sub(1,i-1)..n:sub(d+1,n:len())elseif(e==i)then
- o=o:sub(1,i)l=l:sub(1,i)n=n:sub(1,i)elseif(e==h)then
- o=o:sub(d,o:len())l=l:sub(d,l:len())n=n:sub(d,n:len())end t[e]=o r[e]=l a[e]=n else table.remove(t,e)table.remove(r,e)table.remove(a,e)end end n,e=u,f u,c,f,s=nil,nil,nil,nil return p end
- local function x(e,n)local o={}if(e:len()>0)then
- for l in S(e,n)do local n,t=B(e,l)if(n~=nil)and(t~=nil)then table.insert(o,n)table.insert(o,t)local n=v(e,1,(n-1))local t=v(e,t+1,e:len())e=n..(":"):rep(l:len())..t end end end return o end
- local function h(d,o)o=o or e
- local n=i[d.fgColor]:rep(a[o]:len())local l=i[d.bgColor]:rep(r[o]:len())for e,r in pairs(m)do local e=x(t[o],r[1])if(#e>0)then
- for t=1,#e/2 do
- local t=t*2-1 if(r[2]~=nil)then
- n=n:sub(1,e[t]-1)..i[r[2]]:rep(e[t+1]-(e[t]-1))..n:sub(e[t+1]+1,n:len())end if(r[3]~=nil)then
- l=l:sub(1,e[t]-1)..i[r[3]]:rep(e[t+1]-(e[t]-1))..l:sub(e[t+1]+1,l:len())end end end end
- for l,e in pairs(p)do
- for r,e in pairs(e)do local e=x(t[o],e)if(#e>0)then for t=1,#e/2 do
- local t=t*2-1
- n=n:sub(1,e[t]-1)..i[l]:rep(e[t+1]-(e[t]-1))..n:sub(e[t+1]+1,n:len())end end end end a[o]=n r[o]=l d:updateDraw()end local function x(e)for n=1,#t do h(e,n)end end
- local e={getType=function(e)return k end,setBackground=function(e,n)d.setBackground(e,n)x(e)return e end,setForeground=function(e,n)d.setForeground(e,n)x(e)return e end,setValuesByXMLData=function(n,e)d.setValuesByXMLData(n,e)if(e["lines"]~=nil)then local e=e["lines"]["line"]if(e.properties~=nil)then e={e}end for t,e in pairs(e)do
- n:addLine(e:value())end end
- if(e["keywords"]~=nil)then
- for o,e in pairs(e["keywords"])do
- if(colors[o]~=nil)then
- local e=e if(e.properties~=nil)then e={e}end local t={}for n,e in pairs(e)do
- local n=e["keyword"]if(e["keyword"].properties~=nil)then
- n={e["keyword"]}end for n,e in pairs(n)do
- table.insert(t,e:value())end end n:addKeywords(colors[o],t)end end end
- if(e["rules"]~=nil)then
- if(e["rules"]["rule"]~=nil)then
- local t=e["rules"]["rule"]if(e["rules"]["rule"].properties~=nil)then
- t={e["rules"]["rule"]}end
- for t,e in pairs(t)do if(b("pattern",e)~=nil)then
- n:addRule(b("pattern",e),colors[b("fg",e)],colors[b("bg",e)])end end end end end,getLines=function(e)return
- t end,getLine=function(n,e)return t[e]end,editLine=function(n,e,o)t[e]=o or t[e]h(n,e)n:updateDraw()return n end,clear=function(i)t={" "}r={""}a={""}u,c,f,s=nil,nil,nil,nil l,o,n,e=1,1,1,1
- i:updateDraw()return i end,addLine=function(e,n,o)if(n~=nil)then
- if(#t==1)and(t[1]=="")then t[1]=n
- r[1]=i[e.bgColor]:rep(n:len())a[1]=i[e.fgColor]:rep(n:len())h(e,1)return e end
- if(o~=nil)then table.insert(t,o,n)table.insert(r,o,i[e.bgColor]:rep(n:len()))table.insert(a,o,i[e.fgColor]:rep(n:len()))else table.insert(t,n)table.insert(r,i[e.bgColor]:rep(n:len()))table.insert(a,i[e.fgColor]:rep(n:len()))end end h(e,o or#t)e:updateDraw()return e end,addKeywords=function(n,e,t)if(p[e]==nil)then p[e]={}end for t,n in pairs(t)do
- table.insert(p[e],n)end n:updateDraw()return n end,addRule=function(e,o,n,t)table.insert(m,{o,n,t})e:updateDraw()return e end,editRule=function(n,l,o,t)for e,n in
- pairs(m)do
- if(n[1]==l)then m[e][2]=o m[e][3]=t end end n:updateDraw()return n end,removeRule=function(e,n)for e,t in
- pairs(m)do if(t[1]==n)then table.remove(m,e)end end e:updateDraw()return e end,setKeywords=function(e,n,t)p[n]=t e:updateDraw()return e end,removeLine=function(n,e)if(#t>1)then table.remove(t,e or#t)table.remove(r,e or#r)table.remove(a,e or#a)else t={" "}r={""}a={""}end n:updateDraw()return n end,getTextCursor=function(t)return
- n,e end,getFocusHandler=function(t)d.getFocusHandler(t)if(t.parent~=nil)then
- local a,r=t:getAnchorPosition()if(t.parent~=nil)then
- t.parent:setCursor(true,a+n-o,r+e-l,t.fgColor)end end end,loseFocusHandler=function(e)d.loseFocusHandler(e)if(e.parent~=nil)then e.parent:setCursor(false)end end,keyHandler=function(i,c)if(d.keyHandler(i,event,c))then local s,u=i:getAnchorPosition()local d,f=i:getSize()if(c==keys.backspace)then
- if(t[e]=="")then
- if(e>1)then table.remove(t,e)table.remove(a,e)table.remove(r,e)n=t[e-1]:len()+1 o=n-d+1 if(o<1)then o=1 end e=e-1 end elseif(n<=1)then
- if(e>1)then n=t[e-1]:len()+1
- o=n-d+1 if(o<1)then o=1 end t[e-1]=t[e-1]..t[e]a[e-1]=a[e-1]..a[e]r[e-1]=r[e-1]..r[e]table.remove(t,e)table.remove(a,e)table.remove(r,e)e=e-1 end else t[e]=t[e]:sub(1,n-2)..t[e]:sub(n,t[e]:len())a[e]=a[e]:sub(1,n-2)..a[e]:sub(n,a[e]:len())r[e]=r[e]:sub(1,n-2)..r[e]:sub(n,r[e]:len())if(n>1)then
- n=n-1 end if(o>1)then if(n<o)then o=o-1 end end end if(e<l)then l=l-1 end h(i)i:setValue("")end
- if(c==keys.delete)then
- if(y())then w(i)else
- if(n>t[e]:len())then
- if(t[e+1]~=nil)then t[e]=t[e]..t[e+1]table.remove(t,e+1)table.remove(r,e+1)table.remove(a,e+1)end else t[e]=t[e]:sub(1,n-1)..t[e]:sub(n+1,t[e]:len())a[e]=a[e]:sub(1,n-1)..a[e]:sub(n+1,a[e]:len())r[e]=r[e]:sub(1,n-1)..r[e]:sub(n+1,r[e]:len())end end h(i)end
- if(c==keys.enter)then
- table.insert(t,e+1,t[e]:sub(n,t[e]:len()))table.insert(a,e+1,a[e]:sub(n,a[e]:len()))table.insert(r,e+1,r[e]:sub(n,r[e]:len()))t[e]=t[e]:sub(1,n-1)a[e]=a[e]:sub(1,n-1)r[e]=r[e]:sub(1,n-1)e=e+1 n=1 o=1 if(e-l>=f)then l=l+1 end i:setValue("")end
- if(c==keys.up)then
- if(e>1)then e=e-1 if(n>t[e]:len()+1)then n=t[e]:len()+1 end
- if(o>1)then if(n<o)then
- o=n-d+1 if(o<1)then o=1 end end end if(l>1)then if(e<l)then l=l-1 end end end end
- if(c==keys.down)then
- if(e<#t)then e=e+1 if(n>t[e]:len()+1)then n=t[e]:len()+1 end
- if(o>1)then if(n<o)then o=n-d+1 if(o<1)then o=1 end end end if(e>=l+f)then l=l+1 end end end
- if(c==keys.right)then n=n+1
- if(e<#t)then if(n>t[e]:len()+1)then n=1 e=e+1 end elseif(n>t[e]:len())then n=t[e]:len()+1 end if(n<1)then n=1 end
- if(n<o)or(n>=d+o)then o=n-d+1 end if(o<1)then o=1 end end
- if(c==keys.left)then n=n-1 if(n>=1)then
- if(n<o)or(n>=d+o)then o=n end end
- if(e>1)then if(n<1)then e=e-1
- n=t[e]:len()+1 o=n-d+1 end end if(n<1)then n=1 end if(o<1)then o=1 end end
- if not((s+n-o>=s and s+n-o<s+d)and(u+e-l>=u and u+e-l<u+f))then o=math.max(1,t[e]:len()-d+1)l=math.max(1,e-f+1)end local n=(n<=t[e]:len()and n-1 or t[e]:len())-(o-1)if(n>i:getX()+d-1)then n=i:getX()+d-1 end
- local e=(e-l<f and e-l or e-l-1)if(n<1)then n=0 end
- i.parent:setCursor(true,s+n,u+e,i.fgColor)i:updateDraw()return true end end,charHandler=function(c,m)if(d.charHandler(c,m))then local s,u=c:getAnchorPosition()local d,f=c:getSize()t[e]=t[e]:sub(1,n-1)..m..t[e]:sub(n,t[e]:len())a[e]=a[e]:sub(1,n-1)..i[c.fgColor]..a[e]:sub(n,a[e]:len())r[e]=r[e]:sub(1,n-1)..i[c.bgColor]..r[e]:sub(n,r[e]:len())n=n+1 if(n>=d+o)then o=o+1 end h(c)c:setValue("")if not((s+n-o>=s and s+n-o<s+d)and(u+e-l>=u and u+e-l<u+f))then o=math.max(1,t[e]:len()-d+1)l=math.max(1,e-f+1)end local n=(n<=t[e]:len()and n-1 or t[e]:len())-(o-1)if(n>c:getX()+d-1)then n=c:getX()+d-1 end
- local e=(e-l<f and e-l or e-l-1)if(n<1)then n=0 end if(y())then w(c)end c.parent:setCursor(true,s+n,u+e,c.fgColor)c:updateDraw()return true end end,dragHandler=function(r,a,i,u)if(d.dragHandler(r,a,i,u))then
- local d,f=r:getAbsolutePosition(r:getAnchorPosition())local a,m=r:getAnchorPosition()local h,p=r:getSize()if(t[u-f+l]~=nil)then
- if(a+h>a+i-(d+1)+o)and(a<a+i-d+o)then
- n=i-d+o e=u-f+l c=n s=e if(n>t[e]:len())then n=t[e]:len()+1 c=n end if(n<o)then o=n-1 if(o<1)then o=1 end end r.parent:setCursor(true,a+n-o,m+e-l,r.fgColor)r:updateDraw()end end return true end end,scrollHandler=function(r,c,a,i)if(d.scrollHandler(r,c,a,i))then
- local i,a=r:getAbsolutePosition(r:getAnchorPosition())local s,a=r:getAnchorPosition()local u,d=r:getSize()l=l+c if(l>#t-(d-1))then l=#t-(d-1)end if(l<1)then l=1 end
- if(i+n-o>=i and i+n-o<i+u)and(a+e-l>=a and a+e-l<a+d)then
- r.parent:setCursor(true,s+n-o,a+e-l,r.fgColor)else r.parent:setCursor(false)end r:updateDraw()return true end end,mouseHandler=function(r,h,i,a)if(d.mouseHandler(r,h,i,a))then
- local m,d=r:getAbsolutePosition(r:getAnchorPosition())local h,p=r:getAnchorPosition()if(t[a-d+l]~=nil)then n=i-m+o e=a-d+l c=nil s=nil u=n f=e
- if(n>t[e]:len())then n=t[e]:len()+1 u=n end if(n<o)then o=n-1 if(o<1)then o=1 end end
- r:updateDraw()end if(r.parent~=nil)then
- r.parent:setCursor(true,h+n-o,p+e-l,r.fgColor)end return true end end,mouseUpHandler=function(e,r,a,n)if(d.mouseUpHandler(e,r,a,n))then
- local i,r=e:getAbsolutePosition(e:getAnchorPosition())local d,d=e:getAnchorPosition()if(t[n-r+l]~=nil)then c=a-i+o s=n-r+l if(c>t[s]:len())then c=t[s]:len()+1 end if(u==c)and(f==s)then u,c,f,s=nil,nil,nil,nil end
- e:updateDraw()end return true end end,eventHandler=function(c,u,s,f,p,m)if(d.eventHandler(c,u,s,f,p,m))then
- if(u=="paste")then
- if(c:isFocused())then local d,u=c:getSize()t[e]=t[e]:sub(1,n-1)..s..t[e]:sub(n,t[e]:len())a[e]=a[e]:sub(1,n-1)..i[c.fgColor]:rep(s:len())..a[e]:sub(n,a[e]:len())r[e]=r[e]:sub(1,n-1)..i[c.bgColor]:rep(s:len())..r[e]:sub(n,r[e]:len())n=n+s:len()if(n>=d+o)then o=(n+1)-d end local t,r=c:getAnchorPosition()c.parent:setCursor(true,t+n-o,r+e-l,c.fgColor)h(c)c:updateDraw()end end end end,draw=function(e)if(d.draw(e))then
- if(e.parent~=nil)then local m,h=e:getAnchorPosition()local p,n=e:getSize()for d=1,n do local n=""local s=""local c=""if(t[d+l-1]~=nil)then n=t[d+l-1]c=a[d+l-1]s=r[d+l-1]end n=n:sub(o,p+o-1)s=s:sub(o,p+o-1)c=c:sub(o,p+o-1)local t=p-n:len()if(t<0)then
- t=0 end n=n..g(e.bgSymbol,t)s=s..g(i[e.bgColor],t)c=c..g(i[e.fgColor],t)e.parent:setText(m,h+d-1,n)e.parent:setBG(m,h+d-1,s)e.parent:setFG(m,h+d-1,c)end
- if(u~=nil)and(c~=nil)and(f~=nil)and(s~=nil)then local l,d,r,a=_(e)for o=r,a do local n=t[o]:len()local t=0
- if(o==r)and(o==a)then t=l-1 n=n-(l-1)-(n-d)elseif(o==a)then
- n=n-(n-d)elseif(o==r)then n=n-(l-1)t=l-1 end
- e.parent:setBG(m+t,h+o-1,g(i[T],n))e.parent:setFG(m+t,h+o-1,g(i[C],n))end end
- if(e:isFocused())then local e,e=e:getAnchorPosition()end end end end,init=function(e)e.parent:addEvent("mouse_click",e)e.parent:addEvent("mouse_up",e)e.parent:addEvent("mouse_scroll",e)e.parent:addEvent("mouse_drag",e)e.parent:addEvent("key",e)e.parent:addEvent("char",e)e.parent:addEvent("other_event",e)if(d.init(e))then
- e.bgColor=e.parent:getTheme("TextfieldBG")e.fgColor=e.parent:getTheme("TextfieldText")end end}return setmetatable(e,d)end end
- r["objects"]["Thread"]=function(...)local l=l("utils").getValueFromXML
- return
- function(c)local o
- local d="Thread"local a local n local r=false local t
- local i=function(n,e)if(e:sub(1,1)=="#")then
- local e=n:getBaseFrame():getDeepObject(e:sub(2,e:len()))if(e~=nil)and(e.internalObjetCall~=nil)then return(function()e:internalObjetCall()end)end else return n:getBaseFrame():getVariable(e)end return n end
- o={name=c,getType=function(e)return d end,getZIndex=function(e)return 1 end,getName=function(e)return e.name end,getBaseFrame=function(e)if(e.parent~=nil)then return e.parent:getBaseFrame()end
- return e end,setValuesByXMLData=function(t,e)local n if(l("thread",e)~=nil)then
- n=i(t,l("thread",e))end
- if(l("start",e)~=nil)then if(l("start",e))and(n~=nil)then t:start(n)end end return t end,start=function(e,o)if(o==nil)then error"Function provided to thread is nil"end a=o n=coroutine.create(a)r=true t=nil
- local o,n=coroutine.resume(n)t=n if not(o)then if(n~="Terminated")then
- error("Thread Error Occurred - "..n)end end
- e.parent:addEvent("mouse_click",e)e.parent:addEvent("mouse_up",e)e.parent:addEvent("mouse_scroll",e)e.parent:addEvent("mouse_drag",e)e.parent:addEvent("key",e)e.parent:addEvent("key_up",e)e.parent:addEvent("char",e)e.parent:addEvent("other_event",e)return e end,getStatus=function(e,e)if(n~=nil)then return coroutine.status(n)end return nil end,stop=function(e,n)r=false e.parent:removeEvent("mouse_click",e)e.parent:removeEvent("mouse_up",e)e.parent:removeEvent("mouse_scroll",e)e.parent:removeEvent("mouse_drag",e)e.parent:removeEvent("key",e)e.parent:removeEvent("key_up",e)e.parent:removeEvent("char",e)e.parent:removeEvent("other_event",e)return e end,mouseHandler=function(e,...)e:eventHandler("mouse_click",...)end,mouseUpHandler=function(e,...)e:eventHandler("mouse_up",...)end,mouseScrollHandler=function(e,...)e:eventHandler("mouse_scroll",...)end,mouseDragHandler=function(e,...)e:eventHandler("mouse_drag",...)end,mouseMoveHandler=function(e,...)e:eventHandler("mouse_move",...)end,keyHandler=function(e,...)e:eventHandler("key",...)end,keyUpHandler=function(e,...)e:eventHandler("key_up",...)end,charHandler=function(e,...)e:eventHandler("char",...)end,eventHandler=function(o,e,...)if(r)then
- if(coroutine.status(n)=="suspended")then if(t~=nil)then if(e~=t)then return end t=nil end
- local n,e=coroutine.resume(n,e,...)t=e if not(n)then if(e~="Terminated")then
- error("Thread Error Occurred - "..e)end end else
- o:stop()end end end}o.__index=o return o end end
- r["objects"]["Timer"]=function(...)local n=l("basaltEvent")local e=l("utils").getValueFromXML
- return
- function(c)local d="Timer"local r=0 local a=0 local o=0 local t local i=n()local l=false
- local s=function(e,o,t)local n=function(n)if(n:sub(1,1)=="#")then
- local n=e:getBaseFrame():getDeepObject(n:sub(2,n:len()))if(n~=nil)and(n.internalObjetCall~=nil)then o(e,function()n:internalObjetCall()end)end else
- o(e,e:getBaseFrame():getVariable(n))end end if(type(t)=="string")then n(t)elseif(type(t)=="table")then
- for t,e in pairs(t)do n(e)end end return e end
- local e={name=c,getType=function(e)return d end,setValuesByXMLData=function(t,n)if(e("time",n)~=nil)then r=e("time",n)end if(e("repeat",n)~=nil)then a=e("repeat",n)end
- if(e("start",n)~=nil)then if(e("start",n))then t:start()end end if(e("onCall",n)~=nil)then
- s(t,t.onCall,e("onCall",n))end return t end,getBaseFrame=function(e)if(e.parent~=nil)then return e.parent:getBaseFrame()end return e end,getZIndex=function(e)return 1 end,getName=function(e)return e.name end,setTime=function(e,n,t)r=n or 0 a=t or 1 return e end,start=function(e)if(l)then
- os.cancelTimer(t)end o=a t=os.startTimer(r)l=true
- e.parent:addEvent("other_event",e)return e end,isActive=function(e)return l end,cancel=function(e)if(t~=nil)then os.cancelTimer(t)end l=false
- e.parent:removeEvent("other_event",e)return e end,onCall=function(e,n)i:registerEvent("timed_event",n)return e end,eventHandler=function(a,n,e)if
- n=="timer"and e==t and l then i:sendEvent("timed_event",a)if(o>=1)then o=o-1 if(o>=1)then
- t=os.startTimer(r)end elseif(o==-1)then t=os.startTimer(r)end end end}e.__index=e return e end end
- r["objects"]["Switch"]=function(...)local e=l("Object")local t=l("utils").getValueFromXML
- return
- function(n)local n=e(n)local e="Switch"n.width=2 n.height=1
- n.bgColor=colors.lightGray n.fgColor=colors.gray n:setValue(false)n:setZIndex(5)local o=colors.black local a=colors.red local r=colors.green
- local e={getType=function(n)return e end,setSymbolColor=function(e,n)o=n
- e:updateDraw()return e end,setActiveBackground=function(e,n)r=n e:updateDraw()return e end,setInactiveBackground=function(e,n)a=n e:updateDraw()return e end,setValuesByXMLData=function(l,e)n.setValuesByXMLData(l,e)if(t("inactiveBG",e)~=nil)then
- a=colors[t("inactiveBG",e)]end if(t("activeBG",e)~=nil)then
- r=colors[t("activeBG",e)]end if(t("symbolColor",e)~=nil)then
- o=colors[t("symbolColor",e)]end end,mouseHandler=function(e,l,o,t)if(n.mouseHandler(e,l,o,t))then
- local n,n=e:getAbsolutePosition(e:getAnchorPosition())e:setValue(not e:getValue())e:updateDraw()return true end end,draw=function(e)if(n.draw(e))then
- if(e.parent~=nil)then local t,n=e:getAnchorPosition()local i,l=e:getSize()e.parent:drawBackgroundBox(t,n,i,l,e.bgColor)if(e:getValue())then
- e.parent:drawBackgroundBox(t,n,1,l,r)e.parent:drawBackgroundBox(t+1,n,1,l,o)else
- e.parent:drawBackgroundBox(t,n,1,l,o)e.parent:drawBackgroundBox(t+1,n,1,l,a)end end end end,init=function(e)e.parent:addEvent("mouse_click",e)if(n.init(e))then e.bgColor=e.parent:getTheme("SwitchBG")e.fgColor=e.parent:getTheme("SwitchText")o=e.parent:getTheme("SwitchBGSymbol")a=e.parent:getTheme("SwitchInactive")r=e.parent:getTheme("SwitchActive")end end}return setmetatable(e,n)end end r["libraries"]={}r["libraries"]["basaltEvent"]=function(...)return
- function()local n={}local t={}local e={registerEvent=function(l,e,o)if(n[e]==nil)then n[e]={}t[e]=1 end
- n[e][t[e]]=o t[e]=t[e]+1 return t[e]-1 end,removeEvent=function(o,e,t)n[e][t[e]]=nil end,sendEvent=function(e,t,...)local e
- if(n[t]~=nil)then for t,n in pairs(n[t])do
- local n=n(...)if(n==false)then e=n end end end return e end}e.__index=e return e end end
- r["libraries"]["basaltLogs"]=function(...)local e=""local n="basaltLog.txt"local l="Debug"fs.delete(e~=""and e.."/"..n or n)local e={__call=function(r,t,o)if(t==nil)then return end
- local e=e~=""and e.."/"..n or n
- local e=fs.open(e,fs.exists(e)and"a"or"w")e.writeLine("[Basalt]["..(o and o or l).."]: "..tostring(t))e.close()end}return setmetatable({},e)end
- r["libraries"]["basaltMon"]=function(...)local b={[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}local e,d,y,e=type,string.len,string.rep,string.sub
- return
- function(n)local e={}for t,n in pairs(n)do
- e[t]={}for l,n in pairs(n)do local o=peripheral.wrap(n)if(o==nil)then
- error("Unable to find monitor "..n)end e[t][l]=o
- e[t][l].name=n end end local n,l,o,t,r,r,m,f=1,1,1,1,0,0,0,0 local i,h=false,1
- local u,s=colors.white,colors.black
- local function c()local t,o=0,0
- for e,l in pairs(e)do local e,n=0,0
- for o,t in pairs(l)do local o,t=t.getSize()e=e+o n=t>n and t or n end t=t>e and t or e o=o+n end m,f=t,o end c()local function a()local r=0 local a,i=0,0
- for s,o in pairs(e)do local e=0 local t=0
- for c,o in pairs(o)do
- local d,i=o.getSize()if(n-e>=1)and(n-e<=d)then a=c end o.setCursorPos(n-e,l-r)e=e+d
- if(t<i)then t=i end end if(l-r>=1)and(l-r<=t)then i=s end
- r=r+t end o,t=a,i end a()local function r(n,...)local t={...}return
- function()for o,e in pairs(e)do for o,e in pairs(e)do
- e[n](table.unpack(t))end end end end
- local function g()r("setCursorBlink",false)()if not(i)then return end if(e[t]==nil)then return end local e=e[t][o]if(e==nil)then return end e.setCursorBlink(i)end
- local function p(l,c,i)if(e[t]==nil)then return end local r=e[t][o]if(r==nil)then return end r.blit(l,c,i)local r,s=r.getSize()if(d(l)+n>r)then local e=e[t][o+1]if(e~=nil)then e.blit(l,c,i)o=o+1 n=n+d(l)end end a()end
- return{clear=r("clear"),setCursorBlink=function(e)i=e g()end,getCursorBlink=function()return i end,getCursorPos=function()return n,l end,setCursorPos=function(e,t)n,l=e,t a()g()end,setTextScale=function(e)r("setTextScale",e)()c()a()h=e end,getTextScale=function()return h end,blit=function(n,e,t)p(n,e,t)end,write=function(e)e=tostring(e)local n=d(e)p(e,y(b[u],n),y(b[s],n))end,getSize=function()return m,f end,setBackgroundColor=function(e)r("setBackgroundColor",e)()s=e end,setTextColor=function(e)r("setTextColor",e)()u=e end,calculateClick=function(d,a,r)local t=0
- for e,o in pairs(e)do local e=0 local n=0
- for o,l in pairs(o)do
- local i,o=l.getSize()if(l.name==d)then return a+e,r+t end
- e=e+i if(o>n)then n=o end end t=t+n end return a,r end}end end
- r["libraries"]["basaltDraw"]=function(...)local h=l("tHex")local n,u=string.sub,string.rep
- return
- function(e)local o=e or term.current()local l local e,s=o.getSize()local r={}local a={}local i={}local t={}local t={}local t={}local c local t={}local function d()c=u(" ",e)for n=0,15 do local n=2^n
- local o=h[n]t[n]=u(o,e)end end d()local function b()d()local o=c local l=t[colors.white]local d=t[colors.black]for t=1,s do
- r[t]=n(r[t]==nil and o or r[t]..o:sub(1,e-r[t]:len()),1,e)i[t]=n(i[t]==nil and l or i[t]..l:sub(1,e-i[t]:len()),1,e)a[t]=n(a[t]==nil and d or a[t]..d:sub(1,e-a[t]:len()),1,e)end end b()local function p(t,a,o)if(a>=1)and(a<=s)then
- if(t+o:len()>0)and(t<=e)then local d=r[a]local l local i=t+#o-1
- if(t<1)then local l=1-t+1
- local e=e-t+1 o=n(o,l,e)elseif(i>e)then local e=e-t+1 o=n(o,1,e)end
- if(t>1)then local e=t-1 l=n(d,1,e)..o else l=o end if i<e then l=l..n(d,i+1,e)end
- r[a]=l end end end
- local function g(t,r,o)if(r>=1)and(r<=s)then
- if(t+o:len()>0)and(t<=e)then
- local d=a[r]local l local i=t+#o-1
- if(t<1)then
- o=n(o,1-t+1,e-t+1)elseif(i>e)then o=n(o,1,e-t+1)end
- if(t>1)then l=n(d,1,t-1)..o else l=o end if i<e then l=l..n(d,i+1,e)end
- a[r]=l end end end
- local function m(t,r,o)if(r>=1)and(r<=s)then
- if(t+o:len()>0)and(t<=e)then
- local d=i[r]local l local a=t+#o-1
- if(t<1)then local l=1-t+1 local e=e-t+1
- o=n(o,l,e)elseif(a>e)then local e=e-t+1 o=n(o,1,e)end
- if(t>1)then local e=t-1 l=n(d,1,e)..o else l=o end if a<e then l=l..n(d,a+1,e)end
- i[r]=l end end end
- local function y(o,l,t,c,d)if(#t==#c)or(#t==#d)then
- if(l>=1)and(l<=s)then
- if(o+t:len()>0)and(o<=e)then local g=r[l]local m=i[l]local p=a[l]local h,s,u local f=o+#t-1
- if(o<1)then local l=1-o+1 local e=e-o+1
- t=n(t,l,e)c=n(c,l,e)d=n(d,l,e)elseif(f>e)then local e=e-o+1
- t=n(t,1,e)c=n(c,1,e)d=n(d,1,e)end
- if(o>1)then local e=o-1 h=n(g,1,e)..t
- s=n(m,1,e)..c u=n(p,1,e)..d else h=t s=c u=d end
- if f<e then h=h..n(g,f+1,e)s=s..n(m,f+1,e)u=u..n(p,f+1,e)end r[l]=h i[l]=s a[l]=u end end end end
- local e={setSize=function(n,t)e,s=n,t b()end,setMirror=function(e)l=e end,setBG=function(n,e,t)g(n,e,t)end,setText=function(t,e,n)p(t,e,n)end,setFG=function(t,e,n)m(t,e,n)end,blit=function(l,o,t,n,e)y(l,o,t,n,e)end,drawBackgroundBox=function(t,n,e,o,l)for o=1,o
- do g(t,n+(o-1),u(h[l],e))end end,drawForegroundBox=function(l,t,o,n,e)for n=1,n do
- m(l,t+(n-1),u(h[e],o))end end,drawTextBox=function(e,t,n,o,l)for o=1,o do p(e,t+(o-1),u(l,n))end end,writeText=function(t,n,e,l,o)if(e~=nil)then p(t,n,e)if(l~=nil)and(l~=false)then
- g(t,n,u(h[l],e:len()))end if(o~=nil)and(o~=false)then
- m(t,n,u(h[o],e:len()))end end end,update=function()local t,d=o.getCursorPos()local n=false
- if(o.getCursorBlink~=nil)then n=o.getCursorBlink()end o.setCursorBlink(false)if(l~=nil)then
- l.setCursorBlink(false)end
- for e=1,s do o.setCursorPos(1,e)o.blit(r[e],i[e],a[e])if(l~=nil)then l.setCursorPos(1,e)l.blit(r[e],i[e],a[e])end end o.setBackgroundColor(colors.black)o.setCursorBlink(n)o.setCursorPos(t,d)if(l~=nil)then
- l.setBackgroundColor(colors.black)l.setCursorBlink(n)l.setCursorPos(t,d)end end,setTerm=function(e)o=e end}return e end end
- r["libraries"]["bigfont"]=function(...)local h=l("tHex")local n={{"\32\32\32\137\156\148\158\159\148\135\135\144\159\139\32\136\157\32\159\139\32\32\143\32\32\143\32\32\32\32\32\32\32\32\147\148\150\131\148\32\32\32\151\140\148\151\140\147","\32\32\32\149\132\149\136\156\149\144\32\133\139\159\129\143\159\133\143\159\133\138\32\133\138\32\133\32\32\32\32\32\32\150\150\129\137\156\129\32\32\32\133\131\129\133\131\132","\32\32\32\130\131\32\130\131\32\32\129\32\32\32\32\130\131\32\130\131\32\32\32\32\143\143\143\32\32\32\32\32\32\130\129\32\130\135\32\32\32\32\131\32\32\131\32\131","\139\144\32\32\143\148\135\130\144\149\32\149\150\151\149\158\140\129\32\32\32\135\130\144\135\130\144\32\149\32\32\139\32\159\148\32\32\32\32\159\32\144\32\148\32\147\131\132","\159\135\129\131\143\149\143\138\144\138\32\133\130\149\149\137\155\149\159\143\144\147\130\132\32\149\32\147\130\132\131\159\129\139\151\129\148\32\32\139\131\135\133\32\144\130\151\32","\32\32\32\32\32\32\130\135\32\130\32\129\32\129\129\131\131\32\130\131\129\140\141\132\32\129\32\32\129\32\32\32\32\32\32\32\131\131\129\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\159\154\133\133\133\144\152\141\132\133\151\129\136\153\32\32\154\32\159\134\129\130\137\144\159\32\144\32\148\32\32\32\32\32\32\32\32\32\32\32\151\129","\32\32\32\32\133\32\32\32\32\145\145\132\141\140\132\151\129\144\150\146\129\32\32\32\138\144\32\32\159\133\136\131\132\131\151\129\32\144\32\131\131\129\32\144\32\151\129\32","\32\32\32\32\129\32\32\32\32\130\130\32\32\129\32\129\32\129\130\129\129\32\32\32\32\130\129\130\129\32\32\32\32\32\32\32\32\133\32\32\32\32\32\129\32\129\32\32","\150\156\148\136\149\32\134\131\148\134\131\148\159\134\149\136\140\129\152\131\32\135\131\149\150\131\148\150\131\148\32\148\32\32\148\32\32\152\129\143\143\144\130\155\32\134\131\148","\157\129\149\32\149\32\152\131\144\144\131\148\141\140\149\144\32\149\151\131\148\32\150\32\150\131\148\130\156\133\32\144\32\32\144\32\130\155\32\143\143\144\32\152\129\32\134\32","\130\131\32\131\131\129\131\131\129\130\131\32\32\32\129\130\131\32\130\131\32\32\129\32\130\131\32\130\129\32\32\129\32\32\133\32\32\32\129\32\32\32\130\32\32\32\129\32","\150\140\150\137\140\148\136\140\132\150\131\132\151\131\148\136\147\129\136\147\129\150\156\145\138\143\149\130\151\32\32\32\149\138\152\129\149\32\32\157\152\149\157\144\149\150\131\148","\149\143\142\149\32\149\149\32\149\149\32\144\149\32\149\149\32\32\149\32\32\149\32\149\149\32\149\32\149\32\144\32\149\149\130\148\149\32\32\149\32\149\149\130\149\149\32\149","\130\131\129\129\32\129\131\131\32\130\131\32\131\131\32\131\131\129\129\32\32\130\131\32\129\32\129\130\131\32\130\131\32\129\32\129\131\131\129\129\32\129\129\32\129\130\131\32","\136\140\132\150\131\148\136\140\132\153\140\129\131\151\129\149\32\149\149\32\149\149\32\149\137\152\129\137\152\129\131\156\133\149\131\32\150\32\32\130\148\32\152\137\144\32\32\32","\149\32\32\149\159\133\149\32\149\144\32\149\32\149\32\149\32\149\150\151\129\138\155\149\150\130\148\32\149\32\152\129\32\149\32\32\32\150\32\32\149\32\32\32\32\32\32\32","\129\32\32\130\129\129\129\32\129\130\131\32\32\129\32\130\131\32\32\129\32\129\32\129\129\32\129\32\129\32\131\131\129\130\131\32\32\32\129\130\131\32\32\32\32\140\140\132","\32\154\32\159\143\32\149\143\32\159\143\32\159\144\149\159\143\32\159\137\145\159\143\144\149\143\32\32\145\32\32\32\145\149\32\144\32\149\32\143\159\32\143\143\32\159\143\32","\32\32\32\152\140\149\151\32\149\149\32\145\149\130\149\157\140\133\32\149\32\154\143\149\151\32\149\32\149\32\144\32\149\149\153\32\32\149\32\149\133\149\149\32\149\149\32\149","\32\32\32\130\131\129\131\131\32\130\131\32\130\131\129\130\131\129\32\129\32\140\140\129\129\32\129\32\129\32\137\140\129\130\32\129\32\130\32\129\32\129\129\32\129\130\131\32","\144\143\32\159\144\144\144\143\32\159\143\144\159\138\32\144\32\144\144\32\144\144\32\144\144\32\144\144\32\144\143\143\144\32\150\129\32\149\32\130\150\32\134\137\134\134\131\148","\136\143\133\154\141\149\151\32\129\137\140\144\32\149\32\149\32\149\154\159\133\149\148\149\157\153\32\154\143\149\159\134\32\130\148\32\32\149\32\32\151\129\32\32\32\32\134\32","\133\32\32\32\32\133\129\32\32\131\131\32\32\130\32\130\131\129\32\129\32\130\131\129\129\32\129\140\140\129\131\131\129\32\130\129\32\129\32\130\129\32\32\32\32\32\129\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32\32\32\32\32\149\32\32\149\32\32\32\32","\32\32\32\32\32\32\32\32\32\32\32\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\32\32\32\32\32\32\32\32\32\32\32","\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32\32\149\32","\32\32\32\32\145\32\159\139\32\151\131\132\155\143\132\134\135\145\32\149\32\158\140\129\130\130\32\152\147\155\157\134\32\32\144\144\32\32\32\32\32\32\152\131\155\131\131\129","\32\32\32\32\149\32\149\32\145\148\131\32\149\32\149\140\157\132\32\148\32\137\155\149\32\32\32\149\154\149\137\142\32\153\153\32\131\131\149\131\131\129\149\135\145\32\32\32","\32\32\32\32\129\32\130\135\32\131\131\129\134\131\132\32\129\32\32\129\32\131\131\32\32\32\32\130\131\129\32\32\32\32\129\129\32\32\32\32\32\32\130\131\129\32\32\32","\150\150\32\32\148\32\134\32\32\132\32\32\134\32\32\144\32\144\150\151\149\32\32\32\32\32\32\145\32\32\152\140\144\144\144\32\133\151\129\133\151\129\132\151\129\32\145\32","\130\129\32\131\151\129\141\32\32\142\32\32\32\32\32\149\32\149\130\149\149\32\143\32\32\32\32\142\132\32\154\143\133\157\153\132\151\150\148\151\158\132\151\150\148\144\130\148","\32\32\32\140\140\132\32\32\32\32\32\32\32\32\32\151\131\32\32\129\129\32\32\32\32\134\32\32\32\32\32\32\32\129\129\32\129\32\129\129\130\129\129\32\129\130\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\150\151\129\150\131\132\140\143\144\143\141\145\137\140\148\141\141\144\157\142\32\159\140\32\151\134\32\157\141\32","\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\157\140\149\151\151\32\154\143\132\157\140\32\157\140\32\157\140\32\157\140\32\32\149\32\32\149\32\32\149\32\32\149\32","\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\32\129\129\131\129\32\134\32\131\131\129\131\131\129\131\131\129\131\131\129\130\131\32\130\131\32\130\131\32\130\131\32","\151\131\148\152\137\145\155\140\144\152\142\145\153\140\132\153\137\32\154\142\144\155\159\132\150\156\148\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\136\32\151\140\132","\151\32\149\151\155\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\152\137\144\157\129\149\149\32\149\149\32\149\149\32\149\149\32\149\130\150\32\32\157\129\149\32\149","\131\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\129\32\130\131\32\133\131\32","\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\159\142\32\159\159\144\152\140\144\156\143\32\159\141\129\153\140\132\157\141\32\130\145\32\32\147\32\136\153\32\130\146\32","\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\152\140\149\149\157\134\154\143\132\157\140\133\157\140\133\157\140\133\157\140\133\32\149\32\32\149\32\32\149\32\32\149\32","\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\131\129\130\130\131\32\134\32\130\131\129\130\131\129\130\131\129\130\131\129\32\129\32\32\129\32\32\129\32\32\129\32","\159\134\144\137\137\32\156\143\32\159\141\129\153\140\132\153\137\32\157\141\32\32\132\32\159\143\32\147\32\144\144\130\145\136\137\32\146\130\144\144\130\145\130\138\32\146\130\144","\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\149\32\149\131\147\129\138\134\149\149\32\149\149\32\149\149\32\149\149\32\149\154\143\149\32\157\129\154\143\149","\130\131\32\129\32\129\130\131\32\130\131\32\130\131\32\130\131\32\130\131\32\32\32\32\130\131\32\130\131\129\130\131\129\130\131\129\130\131\129\140\140\129\130\131\32\140\140\129"},{"000110000110110000110010101000000010000000100101","000000110110000000000010101000000010000000100101","000000000000000000000000000000000000000000000000","100010110100000010000110110000010100000100000110","000000110000000010110110000110000000000000110000","000000000000000000000000000000000000000000000000","000000110110000010000000100000100000000000000010","000000000110110100010000000010000000000000000100","000000000000000000000000000000000000000000000000","010000000000100110000000000000000000000110010000","000000000000000000000000000010000000010110000000","000000000000000000000000000000000000000000000000","011110110000000100100010110000000100000000000000","000000000000000000000000000000000000000000000000","000000000000000000000000000000000000000000000000","110000110110000000000000000000010100100010000000","000010000000000000110110000000000100010010000000","000000000000000000000000000000000000000000000000","010110010110100110110110010000000100000110110110","000000000000000000000110000000000110000000000000","000000000000000000000000000000000000000000000000","010100010110110000000000000000110000000010000000","110110000000000000110000110110100000000010000000","000000000000000000000000000000000000000000000000","000100011111000100011111000100011111000100011111","000000000000100100100100011011011011111111111111","000000000000000000000000000000000000000000000000","000100011111000100011111000100011111000100011111","000000000000100100100100011011011011111111111111","100100100100100100100100100100100100100100100100","000000110100110110000010000011110000000000011000","000000000100000000000010000011000110000000001000","000000000000000000000000000000000000000000000000","010000100100000000000000000100000000010010110000","000000000000000000000000000000110110110110110000","000000000000000000000000000000000000000000000000","110110110110110110000000110110110110110110110110","000000000000000000000110000000000000000000000000","000000000000000000000000000000000000000000000000","000000000000110110000110010000000000000000010010","000010000000000000000000000000000000000000000000","000000000000000000000000000000000000000000000000","110110110110110110110000110110110110000000000000","000000000000000000000110000000000000000000000000","000000000000000000000000000000000000000000000000","110110110110110110110000110000000000000000010000","000000000000000000000000100000000000000110000110","000000000000000000000000000000000000000000000000"}}local t={}local o={}do local a=0 local e=#n[1]local l=#n[1][1]for t=1,e,3 do
- for e=1,l,3 do
- local i=string.char(a)local r={}r[1]=n[1][t]:sub(e,e+2)r[2]=n[1][t+1]:sub(e,e+2)r[3]=n[1][t+2]:sub(e,e+2)local l={}l[1]=n[2][t]:sub(e,e+2)l[2]=n[2][t+1]:sub(e,e+2)l[3]=n[2][t+2]:sub(e,e+2)o[i]={r,l}a=a+1 end end t[1]=o end
- local function g(e,l)local u={["0"]="1",["1"]="0"}if e<=#t then return true end
- for s=#t+1,e do local h={}local n=t[s-1]for m=0,255 do local c=string.char(m)local r={}local t={}local e=n[c][1]local p=n[c][2]for a=1,#e do local c,f,s,l,i,d={},{},{},{},{},{}for n=1,#e[1]do
- local t=o[e[a]:sub(n,n)][1]table.insert(c,t[1])table.insert(f,t[2])table.insert(s,t[3])local e=o[e[a]:sub(n,n)][2]if p[a]:sub(n,n)=="1"then
- table.insert(l,(e[1]:gsub("[01]",u)))table.insert(i,(e[2]:gsub("[01]",u)))table.insert(d,(e[3]:gsub("[01]",u)))else table.insert(l,e[1])table.insert(i,e[2])table.insert(d,e[3])end end table.insert(r,table.concat(c))table.insert(r,table.concat(f))table.insert(r,table.concat(s))table.insert(t,table.concat(l))table.insert(t,table.concat(i))table.insert(t,table.concat(d))end h[c]={r,t}if l then l="Font"..s.."Yeld"..m
- os.queueEvent(l)os.pullEvent(l)end end t[s]=h end return true end
- local function f(n,e,l,o,i)if not type(e)=="string"then error("Not a String",3)end
- local a=type(l)=="string"and l:sub(1,1)or h[l]or
- error("Wrong Front Color",3)local r=type(o)=="string"and o:sub(1,1)or h[o]or
- error("Wrong Back Color",3)if(t[n]==nil)then g(3,false)end local t=t[n]or
- error("Wrong font size selected",3)if e==""then
- return{{""},{""},{""}}end local n={}for e in e:gmatch('.')do table.insert(n,e)end local d={}local c=#t[n[1]][1]for l=1,c do local o={}for e=1,#n do o[e]=t[n[e]]and
- t[n[e]][1][l]or""end d[l]=table.concat(o)end local s={}local u={}local f={["0"]=a,["1"]=r}local h={["0"]=r,["1"]=a}for r=1,c do
- local d={}local a={}for e=1,#n do
- local n=t[n[e]]and t[n[e]][2][r]or""d[e]=n:gsub("[01]",i and{["0"]=l:sub(e,e),["1"]=o:sub(e,e)}or f)a[e]=n:gsub("[01]",i and{["0"]=o:sub(e,e),["1"]=l:sub(e,e)}or h)end s[r]=table.concat(d)u[r]=table.concat(a)end return{d,s,u}end return f end
- r["libraries"]["bimg"]=function(...)local d,a=string.sub,string.rep
- local function h(s,u)local n,i=0,0
- local l,o,t={},{},{}local r,e=1,1 local c={}local function p()for e=1,i do if(l[e]==nil)then l[e]=a(" ",n)else l[e]=l[e]..a(" ",n-#l[e])end if(o[e]==nil)then o[e]=a("0",n)else
- o[e]=o[e]..a("0",n-#o[e])end
- if(t[e]==nil)then t[e]=a("f",n)else t[e]=t[e]..a("f",n-#t[e])end end end
- local m=function(t,o,c)r=o or r e=c or e
- if(l[e]==nil)then l[e]=a(" ",r-1)..t..a(" ",n-(#t+r))else l[e]=d(l[e],1,r-1)..a(" ",r-#l[e])..t..d(l[e],r+#t,n)end if(#l[e]>n)then n=#l[e]end if(e>i)then i=e end
- u.updateSize(n,i)end
- local h=function(o,c,l)r=c or r e=l or e
- if(t[e]==nil)then t[e]=a("f",r-1)..o..a("f",n-(#o+r))else t[e]=d(t[e],1,r-1)..a("f",r-#t[e])..o..d(t[e],r+#o,n)end if(#t[e]>n)then n=#t[e]end if(e>i)then i=e end
- u.updateSize(n,i)end
- local f=function(t,l,c)r=l or r e=c or e
- if(o[e]==nil)then o[e]=a("0",r-1)..t..a("0",n-(#t+r))else o[e]=d(o[e],1,r-1)..a("0",r-#o[e])..t..d(o[e],r+#t,n)end if(#o[e]>n)then n=#o[e]end if(e>i)then i=e end
- u.updateSize(n,i)end
- local function r(e)c={}l,o,t={},{},{}for e,n in pairs(s)do if(type(e)=="string")then c[e]=n else
- l[e],o[e],t[e]=n[1],n[2],n[3]end end u.updateSize(n,i)end if(s~=nil)then n=#s[1][1]i=#s r(s)end
- return{recalculateSize=p,setFrame=r,getFrame=function()local e={}for n,l in
- pairs(l)do table.insert(e,{l,o[n],t[n]})end for n,t in pairs(c)do e[n]=t end return e,n,i end,getImage=function()local e={}for n,l in pairs(l)do
- table.insert(e,{l,o[n],t[n]})end return e end,setFrameData=function(e,n)if(n~=nil)then c[e]=n else if(type(e)=="table")then c=e end end end,setFrameImage=function(n)for e,r in pairs(n.t)do
- l[e]=n.t[e]o[e]=n.fg[e]t[e]=n.bg[e]end end,getFrameImage=function()return{t=l,fg=o,bg=t}end,getFrameData=function(e)return(e~=nil and c[e]or c)end,blit=function(t,o,l,n,e)m(t,n,e)f(o,n,e)h(l,n,e)end,text=m,fg=f,bg=h,getSize=function()return
- n,i end,setSize=function(r,f)local c,u,s={},{},{}for e=1,f do
- if(l[e]~=nil)then c[e]=d(l[e],1,r)..a(" ",r-n)else c[e]=a(" ",r)end if(o[e]~=nil)then
- u[e]=d(o[e],1,r)..a("0",r-n)else u[e]=a("0",r)end if(t[e]~=nil)then s[e]=d(t[e],1,r)..a("f",r-n)else
- s[e]=a("f",r)end end l,o,t=c,u,s n,i=r,f end}end
- return
- function(a)local e={}local n={creator="Bimg Library by NyoriE",date=os.date("!%Y-%m-%dT%TZ")}local o,t=0,0 local r={}local function l(n,l)n=n or#e+1
- table.insert(e,n,h(l,r))if(l==nil)then e[n].setSize(o,t)end end local function i(n)table.remove(e,n or#e)end
- local function d(n,t)local o=e[n]if(o~=nil)then local t=n+t if(t>=1)and(t<=#e)then table.remove(e,n)table.insert(e,t,o)end end end
- r={updateSize=function(l,r,n)local n=n==true and true or false
- if(l>o)then n=true o=l end if(r>t)then n=true t=r end
- if(n)then for n,e in pairs(e)do e.setSize(o,t)e.recalculateSize()end end end,text=function(n,t,o,r)local e=e[n]if(e==nil)then e=l(n)end e.text(t,o,r)end,fg=function(n,r,t,o)local e=e[n]if(e==nil)then e=l(n)end e.fg(r,t,o)end,bg=function(n,t,r,o)local e=e[n]if(e==nil)then e=l(n)end e.bg(t,r,o)end,blit=function(n,i,a,o,t,r)local e=e[n]if(e==nil)then e=l(n)end e.blit(i,a,o,t,r)end,setSize=function(n,l)o=n t=l for t,e in pairs(e)do e.setSize(n,l)end end,getFrame=function(n)if(e[n]~=nil)then return e[n].getFrame()end end,getFrameObjects=function()return
- e end,getFrames=function()local n={}for t,e in pairs(e)do local e=e.getFrame()table.insert(n,e)end return n end,getFrameObject=function(n)return
- e[n]end,addFrame=function(t)local o=h()if(#e<=1)then
- if(n.animated==nil)then n.animated=true end
- if(n.secondsPerFrame==nil)then n.secondsPerFrame=.2 end end l(t)return o end,removeFrame=function(t)i(t)if(#e<=1)then if(n.animated==nil)then n.animated=true end if(n.secondsPerFrame==nil)then n.secondsPerFrame=.2 end end end,moveFrame=d,setFrameData=function(n,t,o)if(e[n]~=nil)then e[n].setFrameData(t,o)end end,getFrameData=function(n,t)return e[n]~=nil and
- e[n].getFrameData(t)end,getSize=function()return
- o,t end,setAnimation=function(e)n.animation=e end,setMetadata=function(e,t)if(t~=nil)then n[e]=t else if(type(e)=="table")then n=e end end end,getMetadata=function(e)return
- e~=nil and n[e]or n end,createBimg=function()local l={}for n,e in pairs(e)do local e=e.getFrame()table.insert(l,e)end for e,n in pairs(n)do l[e]=n end l.width=o l.height=t return l end}if(a~=nil)then for e,t in pairs(a)do
- if(type(e)=="string")then n[e]=t else l(e,t)end end
- if(n.width==nil)or(n.height==nil)then for n,e in pairs(e)do local n,e=e.getSize()if(n>o)then n=o end
- if(e>t)then e=t end end
- r.updateSize(o,t,true)end else l(1)end return r end end
- r["libraries"]["images"]=function(...)local i,c,t=string.sub,math.floor,string.rep
- local function l(e)local o={{}}local n=fs.open(e,"r")if(n~=nil)then for e in n.readLine do
- table.insert(o[1],{t(" ",#e),t(" ",#e),e})end n.close()return o end end
- local function s(e)return paintutils.loadImage(e),"nfp"end
- local function a(e)local e=fs.open(e,"rb")local n=textutils.unserialize(e.readAll())e.close()if(n~=nil)then return n,"bimg"end end local function t(e)end local function o(e)end local function p(e,n)if(n==nil)then if(e:find(".bimg"))then return a(e)elseif(e:find(".bbf"))then return t(e)else return s(e)end end end
- local function h(e,n)if(n==nil)then
- if(e:find(".bimg"))then return a(e)elseif(e:find(".bbf"))then return o(e)else return l(e)end end end
- local function m(e,r,o)local u,f=e.width or#e[1][1][1],e.height or#e[1]local n={}for l,t in pairs(e)do
- if(type(l)=="number")then local s={}for e=1,o do local l,d,a="","",""local n=c(e/o*f+.5)if(t[n]~=nil)then
- for e=1,r do local e=c(e/r*u+.5)l=l..i(t[n][1],e,e)d=d..i(t[n][2],e,e)a=a..i(t[n][3],e,e)end table.insert(s,{l,d,a})end end table.insert(n,l,s)else n[l]=t end end n.width=r n.height=o return n end
- return{loadNFP=s,loadBIMG=a,loadImage=p,resizeBIMG=m,loadImageAsBimg=h}end
- r["libraries"]["layout"]=function(...)local function i(n)local e={}e.___value=nil e.___name=n
- e.___children={}e.___props={}function e:value()return self.___value end function e:setValue(e)self.___value=e end function e:name()return self.___name end function e:setName(e)self.___name=e end function e:children()return self.___children end function e:numChildren()return#self.___children end
- function e:addChild(e)if
- self[e:name()]~=nil then if
- type(self[e:name()].name)=="function"then local n={}table.insert(n,self[e:name()])self[e:name()]=n end
- table.insert(self[e:name()],e)else self[e:name()]=e end table.insert(self.___children,e)end function e:properties()return self.___props end function e:numProperties()return#self.___props end
- function e:addProperty(n,t)local e="@"..n
- if self[e]~=nil then if
- type(self[e])=="string"then local n={}table.insert(n,self[e])self[e]=n end
- table.insert(self[e],t)else self[e]=t end
- table.insert(self.___props,{name=n,value=self[n]})end return e end local o={}function o:ToXmlString(e)e=string.gsub(e,"&","&")e=string.gsub(e,"<","<")e=string.gsub(e,">",">")e=string.gsub(e,"\"",""")e=string.gsub(e,"([^%w%&%;%p%\t% ])",function(e)return string.format("&#x%X;",string.byte(e))end)return e end
- function o:FromXmlString(e)e=string.gsub(e,"&#x([%x]+)%;",function(e)return string.char(tonumber(e,16))end)e=string.gsub(e,"&#([0-9]+)%;",function(e)return string.char(tonumber(e,10))end)e=string.gsub(e,""","\"")e=string.gsub(e,"'","'")e=string.gsub(e,">",">")e=string.gsub(e,"<","<")e=string.gsub(e,"&","&")return e end function o:ParseArgs(e,n)string.gsub(n,"(%w+)=([\"'])(.-)%2",function(t,o,n)e:addProperty(t,self:FromXmlString(n))end)end
- function o:ParseXmlText(a)local e={}local n=i()table.insert(e,n)local r,d,t,l,s local o,c=1,1
- while true do
- r,c,d,t,l,s=string.find(a,"<(%/?)([%w_:]+)(.-)(%/?)>",o)if not r then break end local r=string.sub(a,o,r-1)if not
- string.find(r,"^%s*$")then
- local n=(n:value()or"")..self:FromXmlString(r)e[#e]:setValue(n)end
- if s=="/"then local e=i(t)self:ParseArgs(e,l)n:addChild(e)elseif d==""then local t=i(t)self:ParseArgs(t,l)table.insert(e,t)n=t else local o=table.remove(e)n=e[#e]if#e<1 then error("XmlParser: nothing to close with "..t)end if o:name()~=t then
- error("XmlParser: trying to close "..o.name.." with "..t)end n:addChild(o)end o=c+1 end local t=string.sub(a,o)if#e>1 then
- error("XmlParser: unclosed "..e[#e]:name())end return n end
- function o:loadFile(n,e)if not e then e=system.ResourceDirectory end
- local e=system.pathForFile(n,e)local e,n=io.open(e,"r")if e and not n then local n=e:read("*a")io.close(e)return self:ParseXmlText(n),nil else print(n)return nil end end return o end
- r["libraries"]["module"]=function(...)return function(e)local e,n=pcall(l,e)return e and n or nil end end
- r["libraries"]["process"]=function(...)local a={}local t={}local o=0
- local i=dofile("rom/modules/main/cc/require.lua").make
- function t:new(n,e,r,...)local l={...}local t=setmetatable({path=n},{__index=self})t.window=e e.current=term.current e.redirect=term.redirect
- t.processId=o
- if(type(n)=="string")then
- t.coroutine=coroutine.create(function()local t=shell.resolveProgram(n)local e=setmetatable(r,{__index=_ENV})e.shell=shell
- e.basaltProgram=true e.arg={[0]=n,table.unpack(l)}e.require,e.package=i(e,fs.getDir(t))if(fs.exists(t))then local t=fs.open(t,"r")local o=t.readAll()t.close()local e=load(o,n,"bt",e)if(e~=nil)then return e()end end end)elseif(type(n)=="function")then
- t.coroutine=coroutine.create(function()n(table.unpack(l))end)else return end a[o]=t o=o+1 return t end
- function t:resume(e,...)local t=term.current()term.redirect(self.window)if(self.filter~=nil)then if(e~=self.filter)then return end self.filter=nil end local n,e=coroutine.resume(self.coroutine,e,...)if n then
- self.filter=e else printError(e)end term.redirect(t)return n,e end
- function t:isDead()if(self.coroutine~=nil)then
- if(coroutine.status(self.coroutine)=="dead")then table.remove(a,self.processId)return true end else return true end return false end
- function t:getStatus()if(self.coroutine~=nil)then
- return coroutine.status(self.coroutine)end return nil end
- function t:start()coroutine.resume(self.coroutine)end return t end
- r["libraries"]["tHex"]=function(...)return{[colors.white]="0",[colors.orange]="1",[colors.magenta]="2",[colors.lightBlue]="3",[colors.yellow]="4",[colors.lime]="5",[colors.pink]="6",[colors.gray]="7",[colors.lightGray]="8",[colors.cyan]="9",[colors.purple]="a",[colors.blue]="b",[colors.brown]="c",[colors.green]="d",[colors.red]="e",[colors.black]="f"}end
- r["libraries"]["utils"]=function(...)local o,r,c=string.sub,string.find,string.reverse
- local function d(e,l)local t={}if e==""or l==""then return t end local n=1
- local a,i=r(e,l,n)while a do table.insert(t,o(e,n,a-1))n=i+1
- a,i=r(e,l,n)end
- table.insert(t,o(e,n))return t end
- local a={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local l,i,t={},{},{}for e=0,15 do i[2^e]=e end
- do local n="0123456789abcdef"for e=1,16 do l[n:sub(e,e)]=e-1 l[e-1]=n:sub(e,e)t[n:sub(e,e)]=2^(e-1)t[2^(e-1)]=n:sub(e,e)local e=a[e-1]for n=1,#e do
- e[n]=2^e[n]end end end
- local function s(e)local n=a[i[e[#e][1]]]for t=1,#n do local t=n[t]for n=1,#e-1 do if
- e[n][1]==t then return n end end end return 1 end
- local function u(n,o)if not o then local t={}o={}for l=1,6 do local e=n[l]local n=o[e]o[e],t[l]=n and(n+1)or 1,e end n=t end local e={}for t,n in pairs(o)do e[#e+1]={t,n}end
- if#e>1 then
- while#e>2 do
- table.sort(e,function(e,n)return e[2]>n[2]end)local t,l=s(e),#e local a,r=e[l][1],e[t][1]for o=1,6 do if n[o]==a then
- n[o]=r e[t][2]=e[t][2]+1 end end e[l]=nil end local o=128
- for e=1,#n-1 do if n[e]~=n[6]then o=o+2^(e-1)end end return string.char(o),t[e[1][1]==n[6]and e[2][1]or e[1][1]],t[n[6]]else
- return"\128",t[n[1]],t[n[1]]end end
- return{getTextHorizontalAlign=function(e,l,r,n)e=o(e,1,l)local t=l-string.len(e)if(r=="right")then e=string.rep(n or" ",t)..e elseif(r=="center")then
- e=string.rep(n or" ",math.floor(t/2))..e..string.rep(n or" ",math.floor(t/2))e=e..(string.len(e)<l and(n or" ")or"")else e=e..string.rep(n or" ",t)end return e end,getTextVerticalAlign=function(n,t)local e=0
- if(t=="center")then e=math.ceil(n/2)if(e<1)then e=1 end end if(t=="bottom")then e=n end if(e<1)then e=1 end return e end,rpairs=function(n)return function(n,e)e=e-1 if e~=0 then return e,n[e]end end,n,#n+1 end,tableCount=function(n)local e=0 if(n~=nil)then for n,n in pairs(n)do e=e+1 end end return e end,splitString=d,createText=function(e,l)local e=d(e,"\n")local t={}for n,e in pairs(e)do if(#e==0)then table.insert(t,"")end
- while#e>l do local n=r(c(o(e,1,l))," ")if not n then n=l else
- n=l-n+1 end local l=o(e,1,n)table.insert(t,l)e=o(e,n+1)end if#e>0 then table.insert(t,e)end end return t end,getValueFromXML=function(t,n)local e if(type(n)~="table")then return end if(n[t]~=nil)then
- if(type(n[t])=="table")then if(n[t].value~=nil)then e=n[t]:value()end end end if(e==nil)then
- e=n["@"..t]end if(e=="true")then e=true elseif(e=="false")then e=false elseif(tonumber(e)~=nil)then
- e=tonumber(e)end return e end,numberFromString=function(e)return load("return "..e)()end,uuid=function()local e=math.random
- local function t()local n='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'return
- string.gsub(n,'[xy]',function(n)local e=(n=='x')and e(0,15)or e(8,11)return string.format('%x',e)end)end return t()end,array=function(e,n)return
- load("return {"..("nil,"):rep(e)..("[0]=nil,"):rep(n).."}")()end,shrink=function(n,e)local e,l,t,c={{},{},{}},0,#n+#n%3,e or colours.black for e=1,#n do if#n[e]>l then l=#n[e]end end
- for o=0,t-1,3 do
- local i,d,s,t={},{},{},1
- for a=0,l-1,2 do local e,l={},{}for t=1,3 do
- for r=1,2 do
- e[#e+1]=(n[o+t]and n[o+t][a+r])and(n[o+t][a+r]==0 and c or n[o+t][a+r])or c l[e[#e]]=l[e[#e]]and(l[e[#e]]+1)or 1 end end i[t],d[t],s[t]=u(e,l)t=t+1 end
- e[1][#e[1]+1],e[2][#e[2]+1],e[3][#e[3]+1]=table.concat(i),table.concat(d),table.concat(s)end e.width,e.height=#e[1][1],#e[1]return e end}end return r["main"]()end,["pine3d.Pine3D"]=function(...)local T=a("pine3d.betterblittle")local u={}for e=1,16 do
- u[2^(e-1)]=("0123456789abcdef"):sub(e,e)end
- local n=math.pow(10,99)local function m(e,o,t,l)local t=t-e
- if t==0 then
- return n,-n*e
- end
- local n=(l-o)/t
- return n,o-n*e
- end
- local t=math.min
- local n=math.max
- local o=math.floor
- local s=math.ceil
- local function S(a,r,e,l)local a={x1=a,y1=r,x2=e,y2=l,width=e-a+1,height=l-r+1,screenBuffer={{}},blittleWindow=nil,blittleOn=false,backgroundColor=colors.lightBlue}function a:setBufferSize(n,e,o,t)self.x1=n
- self.y1=e
- self.x2=o
- self.y2=t
- self.width=o-n+1
- self.height=t-e+1
- if self.blittleWindow then
- self.blittleWindow=self.blittleWindow.reposition(self.x1,self.y1,self.x1+self.width-1,self.y1+self.height-1)end
- self:clear()end
- function a:clear()local e=self.screenBuffer
- e.c2={}e.depth={}local t=e.c2
- local n=e.depth
- local l=math.huge
- local r=self.width
- local o=self.backgroundColor
- if self.blittleOn then
- for e=1,self.height do
- t[e]={}n[e]={}local t=t[e]local n=n[e]for e=1,r do
- t[e]=o
- n[e]=l
- end
- end
- else
- local i=u[o]e.c1={}local a=e.c1
- e.chars={}local o=e.chars
- for e=1,self.height do
- a[e]={}t[e]={}o[e]={}n[e]={}local a=a[e]local t=t[e]local o=o[e]local n=n[e]for e=1,r do
- a[e]=i
- t[e]=i
- o[e]=" "n[e]=l
- end
- end
- end
- end
- function a:fastClearNormal()local n=self.backgroundColor
- local e=self.screenBuffer
- local t=e.chars
- local i=e.c1
- local r=e.c2
- local a=self.screenBuffer.depth
- local n=u[n]local l=math.huge
- local o=self.width
- for e=1,self.height do
- local t=t[e]local i=i[e]local d=r[e]local r=a[e]for e=1,o do
- t[e]=" "i[e]=n
- d[e]=n
- r[e]=l
- end
- end
- end
- function a:fastClearBLittle()local r=self.backgroundColor
- local n=self.screenBuffer.c2
- local t=self.screenBuffer.depth
- local o=math.huge
- local l=self.width
- for e=1,self.height do
- local n=n[e]local t=t[e]for e=1,l do
- n[e]=r
- t[e]=o
- end
- end
- end
- function a:setPixel(e,n,o,l,t)e=math.floor(e+.5)n=math.floor(n+.5)if e>=1 and e<=self.width then
- if n>=1 and n<=self.height then
- local t=self.screenBuffer
- if self.blittleOn then
- t.c2[n][e]=l or o
- else
- t.c1[n][e]=u[o]t.c2[n][e]=u[l or o]t.chars[n][e]=" "end
- end
- end
- end
- function a:image(n,t,e)for o,e in pairs(e)do
- for l,e in pairs(e)do
- if e and e>0 then
- if self.blittleOn then
- self:setPixel(l+(n-1)*2,o+(t-1)*3,e,e," ")else
- self:setPixel(l+n-1,o+t-1,e,e," ")end
- end
- end
- end
- end
- function a:loadLineNormal(y,_,g,b,f,c,a,i,d,e)local l=self.screenBuffer
- local u=l.c1
- local m=l.c2
- local p=l.chars
- local l=l.depth
- local h=self.width
- local r=self.height
- if g>=y then
- for t=n(s(y),1),t(o(g),h)do
- local n=o(i*t+d+.5)if n>0 and n<=r and e<=l[n][t]then
- u[n][t]=a
- m[n][t]=f
- p[n][t]=c
- l[n][t]=e
- end
- end
- else
- for t=n(s(g),1),t(o(y),h)do
- local n=o(i*t+d+.5)if n>0 and n<=r and e<=l[n][t]then
- u[n][t]=a
- m[n][t]=f
- p[n][t]=c
- l[n][t]=e
- end
- end
- end
- if b>=_ then
- for t=n(s(_),1),t(o(b),r)do
- local n=o((t-d)/i+.5)local o=l[t]if n>0 and n<=h and e<=o[n]then
- u[t][n]=a
- m[t][n]=f
- p[t][n]=c
- o[n]=e
- end
- end
- else
- for t=n(s(b),1),t(o(_),r)do
- local n=o((t-d)/i+.5)local o=l[t]if n>0 and n<=h and e<=o[n]then
- u[t][n]=a
- m[t][n]=f
- p[t][n]=c
- o[n]=e
- end
- end
- end
- end
- function a:loadLineBLittle(f,h,m,p,d,c,r,e)local l=self.screenBuffer
- local a=l.c2
- local l=l.depth
- local i=self.width
- local u=self.height
- if m>=f then
- for t=n(s(f),1),t(o(m),i)do
- local n=o(c*t+r+.5)if n>0 and n<=u and e<=l[n][t]then
- a[n][t]=d
- l[n][t]=e
- end
- end
- else
- for t=n(s(m),1),t(o(f),i)do
- local n=o(c*t+r+.5)if n>0 and n<=u and e<=l[n][t]then
- a[n][t]=d
- l[n][t]=e
- end
- end
- end
- if p>=h then
- for t=n(s(h),1),t(o(p),u)do
- local n=o((t-r)/c+.5)local o=l[t]if n>0 and n<=i and e<=o[n]then
- a[t][n]=d
- o[n]=e
- end
- end
- else
- for t=n(s(p),1),t(o(h),u)do
- local n=o((t-r)/c+.5)local o=l[t]if n>0 and n<=i and e<=o[n]then
- a[t][n]=d
- o[n]=e
- end
- end
- end
- end
- local C=colors.black
- function a:drawTriangleNormal(i,l,a,e,d,r,y,f,b,k,h)if i<1 and a<1 and d<1 or l<1 and e<1 and r<1 then return end
- local c=self.width
- if i>c and a>c and d>c then return end
- local p=self.height
- if l>p and e>p and r>p then return end
- if l>e then
- l,e=e,l
- i,a=a,i
- end
- if e>r then
- r,e=e,r
- d,a=a,d
- end
- if l>e then
- l,e=e,l
- i,a=a,i
- end
- local g=self.screenBuffer
- local o,s=o,s
- local n,t=t,n
- local S=n(t(1,s(l)),p)local _=n(t(0,o(e)),p)local B=n(t(1,o(r)),p)local w=g.c1
- local p=g.c2
- local x=g.chars
- local v=g.depth
- local n=(a-i)/(e-l)local T=(i-d)/(l-r)f=f or" "b=b or y
- local g=u[y]local s=u[b]if l~=e and l~=r then
- for e=S,_ do
- local m=w[e]local u=p[e]local a=x[e]local t=v[e]local n=(e-l)*n+i
- local e=(e-r)*T+d
- if e<n then n,e=e,n end
- if n<1 then n=1 end
- if n>c then n=c+1 end
- if e<1 then e=0 end
- if e>c then e=c end
- for e=o(n+.5),o(e+.5)do
- if h<t[e]then
- t[e]=h
- m[e]=s
- u[e]=g
- a[e]=f
- end
- end
- end
- end
- local n=(d-a)/(r-e)local b=(i-d)/(l-r)if r~=e and l~=r then
- for t=_+1,B do
- local i=w[t]local u=p[t]local m=x[t]local l=v[t]local n=(t-e)*n+a
- local e=(t-r)*b+d
- if e<n then n,e=e,n end
- if n<1 then n=1 end
- if n>c then n=c+1 end
- if e<1 then e=0 end
- if e>c then e=c end
- for e=o(n+.5),o(e+.5)do
- if h<l[e]then
- l[e]=h
- i[e]=s
- u[e]=g
- m[e]=f
- end
- end
- end
- end
- local n=k
- if n or self.triangleEdges then
- local y,g=m(i,l,a,e)local b,p=m(a,e,d,r)local o,c=m(i,l,d,r)local t=self.loadLineNormal
- local n=u[n or C]t(self,i,l,a,e,n,f,s,y,g,h)t(self,a,e,d,r,n,f,s,b,p,h)t(self,d,r,i,l,n,f,s,o,c,h)end
- end
- function a:drawTriangleBLittle(i,l,a,e,d,r,p,c,c,_,u)if i<1 and a<1 and d<1 or l<1 and e<1 and r<1 then return end
- local c=self.width
- if i>c and a>c and d>c then return end
- local f=self.height
- if l>f and e>f and r>f then return end
- if l>e then
- l,e=e,l
- i,a=a,i
- end
- if e>r then
- r,e=e,r
- d,a=a,d
- end
- if l>e then
- l,e=e,l
- i,a=a,i
- end
- local g=self.screenBuffer
- local o,s=o,s
- local t,n=t,n
- local b=t(n(1,s(l)),f)local h=t(n(0,o(e)),f)local y=t(n(1,o(r)),f)local f=g.c2
- local s=g.depth
- local n=(a-i)/(e-l)local g=(i-d)/(l-r)if l~=e and l~=r then
- for e=b,h do
- local a=f[e]local t=s[e]local n=(e-l)*n+i
- local e=(e-r)*g+d
- if e<n then n,e=e,n end
- if n<1 then n=1 end
- if n>c then n=c+1 end
- if e<1 then e=0 end
- if e>c then e=c end
- for e=o(n+.5),o(e+.5)do
- if u<t[e]then
- t[e]=u
- a[e]=p
- end
- end
- end
- end
- local n=(d-a)/(r-e)local g=(i-d)/(l-r)if r~=e and l~=r then
- for t=h+1,y do
- local i=f[t]local l=s[t]local n=(t-e)*n+a
- local e=(t-r)*g+d
- if e<n then n,e=e,n end
- if n<1 then n=1 end
- if n>c then n=c+1 end
- if e<1 then e=0 end
- if e>c then e=c end
- for e=o(n+.5),o(e+.5)do
- if u<l[e]then
- l[e]=u
- i[e]=p
- end
- end
- end
- end
- local n=_
- if n or self.triangleEdges then
- local p,h=m(i,l,a,e)local s,f=m(a,e,d,r)local o,c=m(i,l,d,r)local t=self.loadLineBLittle
- local n=n or C
- t(self,i,l,a,e,n,p,h,u)t(self,a,e,d,r,n,s,f,u)t(self,d,r,i,l,n,o,c,u)end
- end
- function a:drawBufferNormal()local d=self.x1
- local i=self.y1
- local e=self.screenBuffer
- local a=term.setCursorPos
- local r=term.blit
- local t=e.chars
- local o=e.c1
- local l=e.c2
- local n=table.concat
- for e=1,self.height do
- a(d,e+i-1)local a=n(t[e])local t=n(o[e])local e=n(l[e])r(a,t,e)end
- end
- function a:drawBufferBLittle()local e=self.blittleWindow
- if not e then
- self.blittleWindow=window.create(term.current(),self.x1,self.y1,self.x1+self.width-1,self.y1+self.height-1,false)e=self.blittleWindow
- end
- T.drawBuffer(self.screenBuffer.c2,e)e.setVisible(true)e.setVisible(false)end
- function a:highResMode(e)self.blittleOn=e
- self.drawTriangle=e and self.drawTriangleBLittle or self.drawTriangleNormal
- self.fastClear=e and self.fastClearBLittle or self.fastClearNormal
- self.drawBuffer=e and self.drawBufferBLittle or self.drawBufferNormal
- self:clear()end
- function a:useTriangleEdges(e)self.triangleEdges=e
- end
- a:highResMode(true)return a
- end
- local function z(l,o,t,n,e)local r=e[1]local a=e[2]local e=e[3]local o=o and(o-r)or 0
- local t=t and(t-a)or 0
- local r=n and(n-e)or 0
- for e=1,#l do
- local e=l[e]local n=o+(e[1]+e[4]+e[7])/3
- local t=t+(e[2]+e[5]+e[8])/3
- local o=r+(e[3]+e[6]+e[9])/3
- e[16]=n*n+t*t+o*o
- end
- end
- local k=math.rad
- local b=math.sin
- local y=math.cos
- local function f(l,t,o,n,e)local r=e*o-n*t
- local e=n*o+e*t
- local n=r
- return l,e,n
- end
- local function s(e,l,n,o,t)local r=t*n-o*e
- local n=o*n+t*e
- local e=r
- return n,l,e
- end
- local function u(o,t,l,e,n)local l=n*t-e*o
- local e=e*t+n*o
- local n=l
- return e,n
- end
- local function B(e,h,p,m)local C,T=0,1
- local x,v=0,1
- local w,_=0,1
- if h==0 then h=nil end
- if h then C,T=b(h),y(h)end
- if p==0 then p=nil end
- if p then x,v=b(p),y(p)end
- if m==0 then m=nil end
- if m then w,_=b(m),y(m)end
- local n={}for t,e in pairs(e)do
- local i,a,d=e[1],e[2],e[3]local t,r,c=e[4],e[5],e[6]local o,l,g=e[7],e[8],e[9]if p then
- i,a,d=s(i,a,d,x,v)t,r,c=s(t,r,c,x,v)o,l,g=s(o,l,g,x,v)end
- if m then
- i,a=u(i,a,d,w,_)t,r=u(t,r,c,w,_)o,l=u(o,l,g,w,_)end
- if h then
- i,a,d=f(i,a,d,C,T)t,r,c=f(t,r,c,C,T)o,l,g=f(o,l,g,C,T)end
- n[#n+1]={i,a,d,t,r,c,o,l,g}n[#n][10]=e[10]n[#n][11]=e[11]n[#n][12]=e[12]n[#n][13]=e[13]n[#n][14]=e[14]end
- return n
- end
- local r={}function r.invertTriangles(n)if not n or type(n)~="table"then
- error"transforms.invertTriangles expected arg#1 to be a table (model)"end
- for t=1,#n do
- local e=n[t]n[t]={x1=e.x1,y1=e.y1,z1=e.z1,x2=e.x3,y2=e.y3,z2=e.z3,x3=e.x2,y3=e.y2,z3=e.z2,c=e.c,char=e.char,charc=e.charc,forceRender=e.forceRender,outlineColor=e.outlineColor,}end
- return n
- end
- function r.setOutline(e,n)if not e or type(e)~="table"then
- error"transforms.invertTriangles expected arg#1 to be a table (model)"end
- for t=1,#e do
- local e=e[t]if type(n)=="table"then
- e.outlineColor=n[e.c]or e.outlineColor
- else
- e.outlineColor=n
- end
- end
- return e
- end
- function r.mapColor(e,n)if not e or type(e)~="table"then
- error"transforms.mapColor expected arg#1 to be a table (model)"end
- for t=1,#e do
- local e=e[t]if type(n)=="table"then
- e.c=n[e.c]or e.c
- else
- e.c=n
- end
- end
- return e
- end
- function r.center(c)local o,r=math.huge,-math.huge
- local l,a=math.huge,-math.huge
- local d,i=math.huge,-math.huge
- for e=1,#c do
- local e=c[e]o,r=t(o,e.x1),n(r,e.x1)o,r=t(o,e.x2),n(r,e.x2)o,r=t(o,e.x3),n(r,e.x3)l,a=t(l,e.y1),n(a,e.y1)l,a=t(l,e.y2),n(a,e.y2)l,a=t(l,e.y3),n(a,e.y3)d,i=t(d,e.z1),n(i,e.z1)d,i=t(d,e.z2),n(i,e.z2)d,i=t(d,e.z3),n(i,e.z3)end
- local t=-(r+o)*.5
- local n=-(a+l)*.5
- local o=-(i+d)*.5
- for e=1,#c do
- local e=c[e]e.x1=e.x1+t
- e.x2=e.x2+t
- e.x3=e.x3+t
- e.y1=e.y1+n
- e.y2=e.y2+n
- e.y3=e.y3+n
- e.z1=e.z1+o
- e.z2=e.z2+o
- e.z3=e.z3+o
- end
- return c
- end
- function r.normalizeScale(o)local e=-math.huge
- for t=1,#o do
- local t=o[t]e=n(e,t.x1)e=n(e,t.x2)e=n(e,t.x3)e=n(e,t.y1)e=n(e,t.y2)e=n(e,t.y3)e=n(e,t.z1)e=n(e,t.z2)e=n(e,t.z3)end
- for n=1,#o do
- local n=o[n]n.x1=n.x1/e
- n.x2=n.x2/e
- n.x3=n.x3/e
- n.y1=n.y1/e
- n.y2=n.y2/e
- n.y3=n.y3/e
- n.z1=n.z1/e
- n.z2=n.z2/e
- n.z3=n.z3/e
- end
- return o
- end
- function r.normalizeScaleY(o)local t=-math.huge
- for e=1,#o do
- local e=o[e]t=n(t,e.y1)t=n(t,e.y2)t=n(t,e.y3)end
- for e=1,#o do
- local e=o[e]e.x1=e.x1/t
- e.x2=e.x2/t
- e.x3=e.x3/t
- e.y1=e.y1/t
- e.y2=e.y2/t
- e.y3=e.y3/t
- e.z1=e.z1/t
- e.z2=e.z2/t
- e.z3=e.z3/t
- end
- return o
- end
- function r.scale(t,n)for e=1,#t do
- local e=t[e]e.x1=e.x1*n
- e.x2=e.x2*n
- e.x3=e.x3*n
- e.y1=e.y1*n
- e.y2=e.y2*n
- e.y3=e.y3*n
- e.z1=e.z1*n
- e.z2=e.z2*n
- e.z3=e.z3*n
- end
- return t
- end
- function r.translate(l,o,t,n)for e=1,#l do
- local e=l[e]e.x1=e.x1+(o or 0)e.x2=e.x2+(o or 0)e.x3=e.x3+(o or 0)e.y1=e.y1+(t or 0)e.y2=e.y2+(t or 0)e.y3=e.y3+(t or 0)e.z1=e.z1+(n or 0)e.z2=e.z2+(n or 0)e.z3=e.z3+(n or 0)end
- return l
- end
- function r.rotate(T,m,h,p)local x,v=0,1
- local C,w=0,1
- local _,g=0,1
- if m==0 then m=nil end
- if m then x,v=b(m),y(m)end
- if h==0 then h=nil end
- if h then C,w=b(h),y(h)end
- if p==0 then p=nil end
- if p then _,g=b(p),y(p)end
- for e=1,#T do
- local e=T[e]local o,l,c=e.x1,e.y1,e.z1
- local n,a,i=e.x2,e.y2,e.z2
- local r,t,d=e.x3,e.y3,e.z3
- if h then
- o,l,c=s(o,l,c,C,w)n,a,i=s(n,a,i,C,w)r,t,d=s(r,t,d,C,w)end
- if p then
- o,l=u(o,l,c,_,g)n,a=u(n,a,i,_,g)r,t=u(r,t,d,_,g)end
- if m then
- o,l,c=f(o,l,c,x,v)n,a,i=f(n,a,i,x,v)r,t,d=f(r,t,d,x,v)end
- e.x1,e.y1,e.z1=o,l,c
- e.x2,e.y2,e.z2=n,a,i
- e.x3,e.y3,e.z3=r,t,d
- end
- return T
- end
- function r.alignBottom(o)local e=math.huge
- for n=1,#o do
- local n=o[n]e=t(e,n.y1)e=t(e,n.y2)e=t(e,n.y3)end
- for n=1,#o do
- local n=o[n]n.y1=n.y1-e
- n.y2=n.y2-e
- n.y3=n.y3-e
- end
- return o
- end
- function r.decimate(a,i,d)local e={}local o={}local function t(t,o,l)for n=#e,1,-1 do
- local e=e[n]if e[1]==t and e[2]==o and e[3]==l then
- return n
- end
- end
- end
- for n=1,#a do
- local n=a[n]local l=t(n.x1,n.y1,n.z1)if not l then
- e[#e+1]={n.x1,n.y1,n.z1}l=#e
- end
- local r=t(n.x2,n.y2,n.z2)if not r then
- e[#e+1]={n.x2,n.y2,n.z2}r=#e
- end
- local t=t(n.x3,n.y3,n.z3)if not t then
- e[#e+1]={n.x3,n.y3,n.z3}t=#e
- end
- local e={l,r,t,n.c,n.char,n.charc,n.forceRender}o[#o+1]=e
- end
- local function l(n,e)local t=n[1]-e[1]local o=n[2]-e[2]local e=n[3]-e[3]return(t*t+o*o+e*e)^.5
- end
- local n={}for t=1,#o do
- local t=o[t]local r=l(e[t[1]],e[t[2]])local o=l(e[t[2]],e[t[3]])local e=l(e[t[1]],e[t[3]])n[#n+1]={length=r,vA=t[1],vB=t[2],}n[#n+1]={length=o,vA=t[2],vB=t[3],}n[#n+1]={length=e,vA=t[1],vB=t[3],}end
- local function c(n,t)local l=e[n]local r=e[t]local l={(l[1]+r[1])*.5,(l[2]+r[2])*.5,(l[3]+r[3])*.5,}e[#e+1]=l
- local l=#e
- for r=#o,1,-1 do
- local e=o[r]if e[1]==n or e[1]==t or e[2]==n or e[2]==t or e[3]==n or e[3]==t then
- if e[1]==n or e[1]==t then
- e[1]=l
- end
- if e[2]==n or e[2]==t then
- e[2]=l
- end
- if e[3]==n or e[3]==t then
- e[3]=l
- end
- if e[1]==e[2]or e[2]==e[3]or e[1]==e[3]then
- table.remove(o,r)end
- end
- end
- return l
- end
- local t=i
- if d~="polys"then
- t=(#a)*i
- end
- while#o>t do
- local o=math.huge
- local l
- for t=1,#n do
- local e=n[t]if e.length<o then
- o=e.length
- l=t
- end
- end
- local t=n[l]local l=c(t.vA,t.vB)for r=#n,1,-1 do
- local e=n[r]local o=e.vA==t.vA or e.vA==t.vB
- local t=e.vB==t.vA or e.vB==t.vB
- if o and t then
- table.remove(n,r)elseif o then
- e.vA=l
- elseif t then
- e.vB=l
- end
- end
- end
- local t={}for n=1,#o do
- local n=o[n]local o=e[n[1]]local l=e[n[2]]local e=e[n[3]]t[#t+1]={x1=o[1],y1=o[2],z1=o[3],x2=l[1],y2=l[2],z2=l[3],x3=e[1],y3=e[2],z3=e[3],c=n[4],char=n[5],charc=n[6],forceRender=n[7],}end
- for n,e in pairs(r)do
- t[n]=e
- end
- return t
- end
- local v,h
- function r.toLoD(n,e)e=e or{}local e={minQuality=e.minQuality or .1,variantCount=e.variantCount or 4,qualityHalvingDistance=e.qualityHalvingDistance or 5,quickInitWorseRuntime=e.quickInitWorseRuntime or false,}local o,t=h(n)local o={{quality=1,collapsedModel=o,size=t,}}local n=n
- local t=#n
- for l=1,e.variantCount do
- local e=(1-e.minQuality)*(1-l/e.variantCount)+e.minQuality
- local t=math.floor(t*e+.5)local t=n:decimate(t,"polys")local l,r=h(t)n=t
- local e={quality=e,collapsedModel=l,size=r,}o[#o+1]=e
- end
- local function r(e)local o={}for t=1,#e do
- local n=e[t]local e=n.collapsedModel
- local l={}for n=1,#e do
- local e=e[n]local e={e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],}l[n]=e
- end
- local e={quality=n.quality,size=n.size,collapsedModel=l,}o[t]=e
- end
- return o
- end
- local l={}function e:initObject(t)local n
- if e.quickInitWorseRuntime then
- n=o
- else
- n=r(o)end
- l[t]=n
- t[7]=n[1].collapsedModel
- t[8]=n[1].size
- t[9]=e
- end
- function e:update(n,t)local o=l[n]if o then
- local r=t[1]-n[1]local l=t[2]-n[2]local t=t[3]-n[3]local t=(r*r+l*l+t*t)^.5
- local t=math.min(1,math.max(e.minQuality,1/(t/e.qualityHalvingDistance)))local e=(e.variantCount+1)-e.variantCount*(t-e.minQuality)/(1-e.minQuality)local e=math.floor(e+.5)local e=o[e]n[7]=e.collapsedModel
- n[8]=e.size
- end
- end
- return e
- end
- local l=math.sqrt
- function h(e)local n={}local t=0
- for o=1,#e do
- local e=e[o]n[#n+1]={}n[#n][1]=e.x1
- n[#n][2]=e.y1
- n[#n][3]=e.z1
- n[#n][4]=e.x2
- n[#n][5]=e.y2
- n[#n][6]=e.z2
- n[#n][7]=e.x3
- n[#n][8]=e.y3
- n[#n][9]=e.z3
- n[#n][10]=e.forceRender
- n[#n][11]=e.c
- n[#n][12]=e.char
- n[#n][13]=e.charc
- n[#n][14]=e.outlineColor
- local o=l(e.x1*e.x1+e.y1*e.y1+e.z1*e.z1)local n=l(e.x2*e.x2+e.y2*e.y2+e.z2*e.z2)local e=l(e.x3*e.x3+e.y3*e.y3+e.z3*e.z3)if o>t then
- t=o
- end
- if n>t then
- t=n
- end
- if e>t then
- t=e
- end
- end
- return n,t
- end
- function v(n)local e=fs.open(n,"r")if not e then
- error("Could not find model for an object at path: "..n)end
- local n=e.readAll()e.close()local e=textutils.unserialise(n)for n,t in pairs(r)do
- e[n]=t
- end
- return e
- end
- local d=math.pi
- local i=math.sin
- local a=math.cos
- local C=math.tan
- local T=math.sqrt
- local function F(n,e,d,r)local l,t=term.getSize()if n and d then
- l=d-n+1
- end
- if e and r then
- t=r-e+1
- end
- local n=n or 1
- local e=e or 1
- local d=d or(l-n+1)local r=r or(t-e+1)local n={camera={1e-6,1e-6,1e-6,nil,0,0,},buffer=S(n,e,d,r),x1=n,y1=e,x2=d,y2=r,width=l,height=t,blittleOn=false,pixelratio=1.5,}n.FoV=90
- n.camera[7]=k(n.FoV)n.t=C(k(n.FoV/2))*2*1e-4
- local x,y,b,w
- function n:setBackgroundColor(n)local e=self.buffer
- e.backgroundColor=n
- e:fastClear()end
- local function _()x=o(n.width*.5)+1
- y=o(n.height*.5)b=1e-4*n.width/n.t
- w=-1e-4*n.width/(n.t*n.height*n.pixelratio)*n.height
- end
- function n:setSize(n,e,t,o)self.x1=n
- self.y1=e
- self.x2=t
- self.y2=o
- if not self.blittleOn then
- self.buffer:setBufferSize(n,e,t,o)self.width=t-n+1
- self.height=o-e+1
- self.pixelratio=1.5
- else
- self.width=(t-n+1)*2
- self.height=(o-e+1)*3
- self.pixelratio=1
- self.buffer:setBufferSize(n,e,n+self.width-1,e+self.height-1)end
- _()end
- function n:highResMode(e)self.blittleOn=e
- self.buffer:highResMode(e)if e then
- self.width=(self.x2-self.x1+1)*2
- self.height=(self.y2-self.y1+1)*3
- self.buffer:setBufferSize(self.x1,self.y1,self.x1+self.width-1,self.y1+self.height-1)self.pixelratio=1
- else
- self.buffer:setBufferSize(self.x1,self.y1,self.x2,self.y2)self.width=self.x2-self.x1+1
- self.height=self.y2-self.y1+1
- self.pixelratio=1.5
- end
- _()end
- function n:map3dTo2d(n,t,s)local e=self.camera
- local o=i(e[4]or 0)local c=a(e[4]or 0)local d=i(-e[5])local l=a(-e[5])local r=i(e[6])local a=a(e[6])local n=n-e[1]local t=t-e[2]local e=s-e[3]local i=l*n-d*e
- e=d*n+l*e
- n=i
- local l=a*t-r*n
- n=r*t+a*n
- t=l
- if o~=0 then
- local n=o*e-c*t
- t=c*e+o*t
- e=n
- end
- local e=(e/n)*b+x
- local t=(t/n)*w+y
- return e,t,n>=1e-4
- end
- function n:drawObject(e,t,n)local o=e[1]local r=e[2]local l=e[3]local k=n[1]local S=n[2]local s=n[3]local c=n[4]local m=n[5]local p=n[6]local d=o and(o-t[1])or 0
- local h=r and(r-t[2])or 0
- local _=l and(l-t[3])or 0
- local n=e[9]if n then
- n:update(e,t)end
- local g=e[7]if#g<=0 then
- return
- end
- local n=e[8]local u=d
- local C=h
- local f=_
- local T=c*u-s*f
- local v=s*u+c*f
- local u=T
- local u=m*C+p*u
- if u<-n then
- return
- end
- local f=.5*t[7]local i=i(f)local a=a(f)if(u+n)*i+(v+n)*a<0 then
- return
- end
- if(u+n)*i-(v-n)*a<0 then
- return
- end
- local a=e[4]local i=e[5]local e=e[6]if(a and a~=0)or(i and i~=0)or(e and e~=0)then
- g=B(g,a,i,e)end
- z(g,o,r,l,t)local v=d*d+h*h+_*_<n*n*4
- local t=x
- local r=y
- local o=b
- local l=w
- local n=k
- local f=S
- local s=s
- local c=c
- local u=m
- local a=p
- local m=d
- local p=h
- local h=_
- local function b(e,i,n)local d=c*e-s*n
- n=s*e+c*n
- e=d
- local d=a*i-u*e
- e=u*i+a*e
- i=d
- local t=(n/e)*o+t
- local n=(i/e)*l+r
- return t,n,e
- end
- if n~=0 then
- function b(e,d,i)local h=c*e-s*i
- i=s*e+c*i
- e=h
- local c=a*d-u*e
- e=u*d+a*e
- d=c
- local a=n*i-f*d
- d=f*i+n*d
- i=a
- local n=(i/e)*o+t
- local t=(d/e)*l+r
- return n,t,e
- end
- end
- local e=g
- local d=self.buffer
- for i=1,#e do
- local e=e[i]local i=e[16]local _,w,g=b(e[1]+m,e[2]+p,e[3]+h)if g>.00010000001 then
- local g,y,x=b(e[4]+m,e[5]+p,e[6]+h)if x>.00010000001 then
- local x,b,C=b(e[7]+m,e[8]+p,e[9]+h)if C>.00010000001 then
- if e[10]or(g-_)*(b-y)-(y-w)*(x-g)<0 then
- d:drawTriangle(_,w,g,y,x,b,e[11],e[12],e[13],e[14],i)end
- elseif v then
- local function g(e,i,d)local e=e+m
- local i=i+p
- local d=d+h
- local h=c*e-s*d
- d=s*e+c*d
- e=h
- local c=a*i-u*e
- e=u*i+a*e
- i=c
- if n~=0 then
- local e=n*d-f*i
- i=f*d+n*i
- d=e
- end
- local t=(d/e)*o+t
- local n=(i/e)*l+r
- return t,n,e,i,d
- end
- local m,h,s,_,y=g(e[1],e[2],e[3])local c,a,v,x,w=g(e[4],e[5],e[6])local u,u,n,p,b=g(e[7],e[8],e[9])local u=math.abs
- local n=u(n-1e-4)local s=u(s-1e-4)local f=s+n
- local y=(b*s+y*n)/f
- local _=(p*s+_*n)/f
- local g,f,r,s=t,o,r,l
- local t=(y*10000)*f+g
- local l=(_*10000)*s+r
- if e[10]or(c-m)*(l-a)-(a-h)*(t-c)<0 then
- d:drawTriangle(m,h,c,a,t,l,e[11],e[12],e[13],e[14],i)local o=u(v-1e-4)local u=o+n
- local h=(w*n+b*o)/u
- local n=(x*n+p*o)/u
- local o=(h*10000)*f+g
- local n=(n*10000)*s+r
- d:drawTriangle(o,n,c,a,t,l,e[11],e[12],e[13],e[14],i)end
- end
- elseif v then
- local function g(e,i,d)local e=e+m
- local i=i+p
- local d=d+h
- local h=c*e-s*d
- d=s*e+c*d
- e=h
- local c=a*i-u*e
- e=u*i+a*e
- i=c
- if n~=0 then
- local e=n*d-f*i
- i=f*d+n*i
- d=e
- end
- local t=(d/e)*o+t
- local n=(i/e)*l+r
- return t,n,e,i,d
- end
- local c,s,_,u,f=g(e[1],e[2],e[3])local n,n,v,y,b=g(e[4],e[5],e[6])local g,h,m,x,w=g(e[7],e[8],e[9])local n=math.abs
- if m>.00010000001 then
- local a=n(v-1e-4)local p=n(_-1e-4)local _=p+a
- local v=(b*p+f*a)/_
- local _=(y*p+u*a)/_
- local r,u,p,f=t,o,r,l
- local t=(v*10000)*u+r
- local o=(_*10000)*f+p
- if e[10]or(t-c)*(h-o)-(o-s)*(g-t)<0 then
- d:drawTriangle(c,s,t,o,g,h,e[11],e[12],e[13],e[14],i)local n=n(m-1e-4)local l=a+n
- local c=(b*n+w*a)/l
- local n=(y*n+x*a)/l
- local l=(c*10000)*u+r
- local n=(n*10000)*f+p
- d:drawTriangle(l,n,t,o,g,h,e[11],e[12],e[13],e[14],i)end
- else
- local a=n(_-1e-4)local h=n(v-1e-4)local m=n(m-1e-4)local n=a+h
- local p=a+m
- local g=(f*h+b*a)/n
- local n=(u*h+y*a)/n
- local h,r,o,l=t,o,r,l
- local t=(g*10000)*r+h
- local n=(n*10000)*l+o
- local f=(f*m+w*a)/p
- local a=(u*m+x*a)/p
- local r=(f*10000)*r+h
- local o=(a*10000)*l+o
- if e[10]or(t-c)*(o-n)-(n-s)*(r-t)<0 then
- d:drawTriangle(c,s,t,n,r,o,e[11],e[12],e[13],e[14],i)end
- end
- end
- elseif v then
- local function g(e,i,d)local e=e+m
- local i=i+p
- local d=d+h
- local h=c*e-s*d
- d=s*e+c*d
- e=h
- local c=a*i-u*e
- e=u*i+a*e
- i=c
- if n~=0 then
- local e=n*d-f*i
- i=f*d+n*i
- d=e
- end
- local n=(d/e)*o+t
- local t=(i/e)*l+r
- return n,t,e,i,d
- end
- local n,n,x,p,m=g(e[1],e[2],e[3])local c,a,y,_,b=g(e[4],e[5],e[6])local f,h,u,g,w=g(e[7],e[8],e[9])local n=math.abs
- if y>.00010000001 then
- if u>.00010000001 then
- local s=n(x-1e-4)local y=n(y-1e-4)local x=s+y
- local v=(m*y+b*s)/x
- local x=(p*y+_*s)/x
- local y,_,b,r=t,o,r,l
- local t=(v*10000)*_+y
- local o=(x*10000)*r+b
- if e[10]or(c-t)*(h-a)-(a-o)*(f-c)<0 then
- d:drawTriangle(t,o,c,a,f,h,e[11],e[12],e[13],e[14],i)local n=n(u-1e-4)local l=s+n
- local a=(m*n+w*s)/l
- local l=(p*n+g*s)/l
- local n=(a*10000)*_+y
- local l=(l*10000)*r+b
- d:drawTriangle(t,o,n,l,f,h,e[11],e[12],e[13],e[14],i)end
- else
- local f=n(x-1e-4)local s=n(y-1e-4)local n=n(u-1e-4)local h=s+f
- local u=s+n
- local m=(m*s+b*f)/h
- local f=(p*s+_*f)/h
- local t,o,l,h=t,o,r,l
- local r=(m*10000)*o+t
- local f=(f*10000)*h+l
- local m=(b*n+w*s)/u
- local n=(_*n+g*s)/u
- local t=(m*10000)*o+t
- local n=(n*10000)*h+l
- if e[10]or(c-r)*(n-a)-(a-f)*(t-c)<0 then
- d:drawTriangle(r,f,c,a,t,n,e[11],e[12],e[13],e[14],i)end
- end
- else
- if u>.00010000001 then
- local a=n(x-1e-4)local c=n(y-1e-4)local n=n(u-1e-4)local s=n+a
- local u=n+c
- local y=(m*n+w*a)/s
- local m=(p*n+g*a)/s
- local s,t,r,a=t,o,r,l
- local o=(y*10000)*t+s
- local l=(m*10000)*a+r
- local m=(b*n+w*c)/u
- local n=(_*n+g*c)/u
- local t=(m*10000)*t+s
- local n=(n*10000)*a+r
- if e[10]or(t-o)*(h-n)-(n-l)*(f-t)<0 then
- d:drawTriangle(o,l,t,n,f,h,e[11],e[12],e[13],e[14],i)end
- end
- end
- end
- end
- end
- function n:drawObjects(n)local e=self.camera
- local o={i(e[4]or 0),a(e[4]or 0),i(-e[5]),a(-e[5]),i(e[6]),a(e[6]),}local n=n
- for t=1,#n do
- self:drawObject(n[t],e,o)end
- end
- function n:drawBuffer()local e=self.buffer
- e:drawBuffer()e:fastClear()end
- function n:setCamera(t,i,a,o,l,r)local n=math.rad
- if type(t)=="table"then
- local e=t
- self.camera={e.x or self.camera[1]or 0,e.y or self.camera[2]or 0,e.z or self.camera[3]or 0,e.rotX and n(e.rotX+90)or self.camera[4]or 0,e.rotY and n(e.rotY)or self.camera[5]or 0,e.rotZ and n(e.rotZ)or self.camera[6]or 0,self.camera[7],}else
- self.camera={t or self.camera[1]or 0,i or self.camera[2]or 0,a or self.camera[3]or 0,o and n(o+90)or self.camera[4]or 0,l and n(l)or self.camera[5]or 0,r and n(r)or self.camera[6]or 0,self.camera[7],}end
- if self.camera[4]==math.pi*.5 then
- self.camera[4]=nil
- end
- end
- function n:setFoV(e)self.FoV=e or 90
- self.t=C(k(self.FoV/2))*2*1e-4
- _()self.camera[7]=k(self.FoV)end
- function n:setWireFrame(e)self.buffer:useTriangleEdges(e)end
- function n:getObjectIndexTrace(l,n)local function e(t,r,o,l,n,e)return(t-n)*(l-e)-(o-n)*(r-e)end
- local function v(n,t,i,a,d,r,o,l)local c=e(n,t,i,a,d,r)<0
- local r=e(n,t,d,r,o,l)<0
- if c~=r then return false end
- return r==(e(n,t,o,l,i,a)<0)end
- local d=self.blittleOn
- local r=self.x1
- local e=self.y1
- local o=self.x2
- local t=self.y2
- if d then
- r,e,o,t=(r-1)*2+1,(e-1)*3+1,(o)*2,(t+1)*3
- end
- for t=1,#n do
- local o,e=n[t].x,n[t].y
- e=e-1
- if d then
- o=o*2
- e=e*3+1
- end
- n[t].x,n[t].y=o,e
- end
- local e=self.camera
- local t={i(e[4]or 0),a(e[4]or 0),i(-e[5]),a(-e[5]),i(e[6]),a(e[6]),}local i=t[1]local c=t[2]local f=t[3]local h=t[4]local u=t[5]local s=t[6]local d={}for e=1,#n do
- d[e]={depth=math.huge}end
- for g=1,#l do
- local t=l[g]local o=t[7]local a=t[4]local r=t[5]local l=t[6]if(a and a~=0)or(r and r~=0)or(l and l~=0)then
- o=B(o,a,r,l)end
- local r=t[1]local l=t[2]local t=t[3]local _=x
- local a=y
- local b=b
- local y=w
- local r=r-e[1]local m=l-e[2]local p=t-e[3]local function l(e,t,n)local e=e+r
- local t=t+m
- local n=n+p
- local o=h*e-f*n
- n=f*e+h*n
- e=o
- local o=s*t-u*e
- e=u*t+s*e
- t=o
- if i~=0 then
- local e=i*n-c*t
- t=c*n+i*t
- n=e
- end
- local n=(n/e)*b+_
- local t=(t/e)*y+a
- return n,t,e>0
- end
- for u=1,#o do
- local e=o[u]local s,c,t=l(e[1],e[2],e[3])if t then
- local o,t,a=l(e[4],e[5],e[6])if a then
- local i,a,l=l(e[7],e[8],e[9])if l then
- if e[10]or(o-s)*(a-t)-(t-c)*(i-o)<0 then
- local r=r+(e[1]+e[4]+e[7])/3
- local l=m+(e[2]+e[5]+e[8])/3
- local e=p+(e[3]+e[6]+e[9])/3
- local l=r*r+l*l+e*e
- for e=1,#n do
- local n=n[e]local e=d[e]local r,n=n.x,n.y
- if v(r,n,s,c,o,t,i,a)and l<e.depth then
- e.objectIndex=g
- e.polygonIndex=u
- e.depth=l
- end
- end
- end
- end
- end
- end
- end
- end
- return d
- end
- function n:newObject(t,o,l,r,i,a,d)local n=nil
- local e=nil
- if type(t)=="table"then
- if t.initObject then
- else
- n,e=h(t)end
- else
- local t=v(t)n,e=h(t)end
- local o={o,l,r,i,a,d,n,e,}o.frame=self
- function o:setPos(n,t,e)self[1]=n or self[1]self[2]=t or self[2]self[3]=e or self[3]end
- function o:setRot(t,n,e)self[4]=t or self[4]self[5]=n or self[5]self[6]=e or self[6]end
- function o:setModel(t)if type(t)=="table"then
- n,e=h(t)self[7]=n
- self[8]=e
- else
- local t=v(t)n,e=h(t)self[7]=n
- self[8]=e
- end
- end
- if type(t)=="table"then
- if t.initObject then
- t:initObject(o)end
- end
- return o
- end
- _()n:highResMode(true)return n
- end
- local c={}local function l(e,n,t,o,r,l,c,i,d,a)local e={x1=e,y1=n,z1=t,x2=o,y2=r,z2=l,x3=c,y3=i,z3=d,c=a,}return e
- end
- function c:cube(e)e.color=e.color or colors.red
- local e={l(-.5,-.5,-.5,.5,-.5,.5,-.5,-.5,.5,e.bottom or e.color),l(-.5,-.5,-.5,.5,-.5,-.5,.5,-.5,.5,e.bottom2 or e.bottom or e.color),l(-.5,.5,-.5,-.5,.5,.5,.5,.5,.5,e.top or e.color),l(-.5,.5,-.5,.5,.5,.5,.5,.5,-.5,e.top or e.color),l(-.5,-.5,-.5,-.5,-.5,.5,-.5,.5,-.5,e.side or e.color),l(-.5,-.5,.5,-.5,.5,.5,-.5,.5,-.5,e.side2 or e.side or e.color),l(.5,-.5,-.5,.5,.5,.5,.5,-.5,.5,e.side or e.color),l(.5,-.5,-.5,.5,.5,-.5,.5,.5,.5,e.side2 or e.side or e.color),l(-.5,-.5,-.5,.5,.5,-.5,.5,-.5,-.5,e.side or e.color),l(-.5,-.5,-.5,-.5,.5,-.5,.5,.5,-.5,e.side2 or e.side or e.color),l(-.5,-.5,.5,.5,-.5,.5,-.5,.5,.5,e.side or e.color),l(.5,-.5,.5,.5,.5,.5,-.5,.5,.5,e.side2 or e.side or e.color),}for n,t in pairs(r)do
- e[n]=t
- end
- return e
- end
- function c:sphere(e)e.res=e.res or 32
- e.color=e.color or colors.red
- local l={}local t={}for n=0,e.res do
- local o=.5*a(n/e.res*d)local u={}for n=0,e.res do
- local r=.5*T(1-(o*2)*(o*2))local s=a(n/e.res*d*2)*r
- local c=i(n/e.res*d*2)*r
- local a=a((n+1)/e.res*d*2)*r
- local r=i((n+1)/e.res*d*2)*r
- if(t[n])then
- l[#l+1]={x1=t[(n+1)%e.res].x,y1=t[(n+1)%e.res].y,z1=t[(n+1)%e.res].z,x2=s,y2=o,z2=c,x3=t[n].x,y3=t[n].y,z3=t[n].z,c=e.color,}l[#l+1]={x1=a,y1=o,z1=r,x2=s,y2=o,z2=c,x3=t[(n+1)%e.res].x,y3=t[(n+1)%e.res].y,z3=t[(n+1)%e.res].z,c=e.color2 or e.color,}end
- u[n]={x=s,y=o,z=c}end
- t=u
- end
- if e.colors or e.top or e.bottom then
- for n=1,#l do
- local n=l[n]local t=(n.y1+n.y2+n.y3)/3
- if e.colors then
- local t=o((-t+.5)*(#e.colors)+1)n.c=e.colors[t]or n.c
- else
- if t>=0 then
- n.c=e.top or n.c
- else
- n.c=e.bottom or n.c
- end
- end
- end
- end
- for e,n in pairs(r)do
- l[e]=n
- end
- return l
- end
- function c:icosphere(n)n.res=n.res or 1
- local e=(1+T(5))/2
- local t={{e,1,0},{e,-1,0},{-e,-1,0},{-e,1,0},{1,0,e},{-1,0,e},{-1,0,-e},{1,0,-e},{0,e,1},{0,e,-1},{0,-e,-1},{0,-e,1},}local function e(e,o,r)return l(t[e][1],t[e][2],t[e][3],t[o][1],t[o][2],t[o][3],t[r][1],t[r][2],t[r][3],n.colors and 1 or n.color)end
- local i={e(11,2,12),e(11,8,2),e(11,7,8),e(11,3,7),e(11,12,3),e(4,7,3),e(4,10,7),e(4,9,10),e(4,6,9),e(4,3,6),e(5,6,12),e(5,9,6),e(5,1,9),e(5,2,1),e(5,12,2),e(3,12,6),e(1,8,10),e(1,10,9),e(1,2,8),e(10,8,7),}local function d()local a={}for e=1,#i do
- local e=i[e]local r={x=(e.x1+e.x2)/2,y=(e.y1+e.y2)/2,z=(e.z1+e.z2)/2,}local t={x=(e.x1+e.x3)/2,y=(e.y1+e.y3)/2,z=(e.z1+e.z3)/2,}local o={x=(e.x2+e.x3)/2,y=(e.y2+e.y3)/2,z=(e.z2+e.z3)/2,}local i=e.c
- if n.colorsFractal then
- i=(i%#n.colors)+1
- end
- a[#a+1]=l(r.x,r.y,r.z,o.x,o.y,o.z,t.x,t.y,t.z,e.c)a[#a+1]=l(e.x1,e.y1,e.z1,r.x,r.y,r.z,t.x,t.y,t.z,i)a[#a+1]=l(r.x,r.y,r.z,e.x2,e.y2,e.z2,o.x,o.y,o.z,i)a[#a+1]=l(t.x,t.y,t.z,o.x,o.y,o.z,e.x3,e.y3,e.z3,i)end
- i=a
- end
- for e=1,n.res-1 do
- d()end
- local function l(o,e,n)local t=math.sqrt(o*o+e*e+n*n)local t=.5/t
- return o*t,e*t,n*t
- end
- for e=1,#i do
- local e=i[e]e.x1,e.y1,e.z1=l(e.x1,e.y1,e.z1)e.x2,e.y2,e.z2=l(e.x2,e.y2,e.z2)e.x3,e.y3,e.z3=l(e.x3,e.y3,e.z3)if not n.colorsFractal then
- local t=(e.y1+e.y2+e.y3)/3
- if(n.colors)then
- local t=math.floor((-t+.5)*(#n.colors)+1)e.c=n.colors[t]or e.c
- else
- if(t>=0)then
- e.c=n.top or e.c
- else
- e.c=n.bottom or e.c
- end
- end
- else
- e.c=n.colors[e.c]end
- end
- for n,e in pairs(r)do
- i[n]=e
- end
- return i
- end
- function c:plane(e)e.color=e.color or colors.lime
- e.size=e.size or 1
- e.y=e.y or 0
- local e={l(-1*e.size,e.y,1*e.size,1*e.size,e.y,-1*e.size,-1*e.size,e.y,-1*e.size,e.color),l(-1*e.size,e.y,1*e.size,1*e.size,e.y,1*e.size,1*e.size,e.y,-1*e.size,e.color),}for n,t in pairs(r)do
- e[n]=t
- end
- return e
- end
- function c:mountains(e)e.res=e.res or 20
- e.randomOffset=e.randomOffset or 0
- e.height=e.height or 1
- e.randomHeight=e.randomHeight or 0
- e.y=e.y or 0
- e.scale=e.scale or 100
- e.color=e.color or colors.green
- e.snowColor=e.snowColor or colors.white
- local p=3/e.res*e.height/(e.randomHeight+1)local u=3/e.res*e.height*(e.randomHeight+1)local l={}for r=0,e.res do
- local o=math.random(-e.randomOffset*100,e.randomOffset*100)/100
- local o=r+o
- local f=a((o-1)/e.res*d*2)*e.scale
- local h=i((o-1)/e.res*d*2)*e.scale
- local c=a((o-.5)/e.res*d*2)*e.scale
- local s=i((o-.5)/e.res*d*2)*e.scale
- local m=a(o/e.res*d*2)*e.scale
- local i=i(o/e.res*d*2)*e.scale
- local a=math.random(p*100,u*100)/100*e.scale
- local o={x1=f,y1=e.y,z1=h,x2=m,y2=e.y,z2=i,x3=c,y3=e.y+a,z3=s,c=e.color,forceRender=true,}l[#l+1]=o
- if e.snow then
- local r=.93
- local o=e.snowHeight or .5
- local o=1-(o*u)/(a/e.scale)o=n(0,t(1,o))if o>.2 then
- local e={x1=(f*o+c*(1-o))*r,y1=e.y+a*(1-o),z1=(h*o+s*(1-o))*r,x2=(m*o+c*(1-o))*r,y2=e.y+a*(1-o),z2=(i*o+s*(1-o))*r,x3=c*r,y3=e.y+a,z3=s*r,c=e.snowColor,forceRender=true,}l[#l+1]=e
- end
- end
- end
- for e,n in pairs(r)do
- l[e]=n
- end
- return l
- end
- return{newFrame=F,loadModel=v,newBuffer=S,linear=m,models=c,}end,["pine3d.betterblittle"]=function(...)local f=math.floor
- local g=table.concat
- local u={}for e=1,16 do
- u[2^(e-1)]=("0123456789abcdef"):sub(e,e)end
- local function m(o,a,l,r,n,t)local e={}e[o]=1
- e[a]=(e[a]or 0)+1
- e[l]=(e[l]or 0)+1
- e[r]=(e[r]or 0)+1
- e[n]=(e[n]or 0)+1
- e[t]=(e[t]or 0)+1
- local t=o
- local n=0
- local o=o
- local l=0
- for r,e in pairs(e)do
- if e>l then
- if e>n then
- o=t
- l=n
- t=r
- n=e
- else
- o=r
- l=e
- end
- end
- end
- return t,o
- end
- local e={[0]={8,4,3,6,5},{4,14,8,7},{6,10,8,7},{9,11,8,0},{1,14,8,0},{13,12,8,0},{2,10,8,0},{15,8,10,11,12,14},{0,7,1,9,2,13},{3,11,8,7},{2,6,7,15},{9,3,7,15},{13,5,7,15},{5,12,8,7},{1,4,7,15},{7,10,11,12,14}}local t={}for n=0,15 do
- local e=e[n]for n=1,#e do
- e[n]=math.pow(2,e[n])end
- t[math.pow(2,n)]=e
- end
- local function o(e,o,l)local e=t[e]for n=1,#e do
- if e[n]==o then return true
- elseif e[n]==l then return false end
- end
- return false
- end
- local n=string.char
- local c={}for e=128,128+31 do
- c[e]=n(e)end
- local h=bit.bxor
- local function w(n,e,s,d,a,l,r,i)local o=o
- local t=128
- if s==n or s~=e and o(s,n,e)then t=t+1 end
- if d==n or d~=e and o(d,n,e)then t=t+2 end
- if a==n or a~=e and o(a,n,e)then t=t+4 end
- if l==n or l~=e and o(l,n,e)then t=t+8 end
- if r==n or r~=e and o(r,n,e)then t=t+16 end
- if i==n or i~=e and o(i,n,e)then
- return c[h(31,t)],true
- end
- return c[t],false
- end
- local t={}for e=1,16 do
- t[2^(e-1)]={}end
- local function _(e,n)local l=#e
- local o=#e[1]local o=f(o/2)local b=n.setCursorPos
- local y=n.blit
- local r=u
- local t=t
- for p=1,f(l/3)do
- local n=(p-1)*3+1
- local a=e[n]local i=e[n+1]local f=e[n+2]local l={nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil}local d={nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil}local h={nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil}for e=1,o do
- local o=(e-1)*2+1
- local n=a[o]local s=a[o+1]local u=i[o]local i=i[o+1]local c=f[o]local o=f[o+1]if n==s and s==u and u==i and i==c and c==o then
- local n=r[n]l[e]=n
- d[e]=n
- h[e]="\x80"else
- local a=s..u..i..c..o
- local f=t[n][a]if f then
- l[e]=f[1]d[e]=f[2]h[e]=f[3]else
- local m,f=m(n,s,u,i,c,o)local o,i=w(m,f,n,s,u,i,c,o)if i then
- local i=r[f]local r=r[m]l[e]=i
- d[e]=r
- if t[n]then
- t[n][a]={i,r,o,}else
- t[n]={[a]={i,r,o,}}end
- else
- local i=r[f]local r=r[m]l[e]=r
- d[e]=i
- if t[n]then
- t[n][a]={r,i,o,}else
- t[n]={[a]={r,i,o,}}end
- end
- h[e]=o
- end
- end
- end
- local e=g
- local n=e(h)local t=e(l)local e=e(d)b(1,p)y(n,t,e)end
- end
- return{drawBuffer=_,}end,["pine3d.metadata.Buffer.methods"]=function(...)return{{name="setPixel",parameters={{name="x",type="number"},{name="y",type="number"},{name="c1",type="number",description="color for the pixel"},{name="c2",type="number",description="optional: char color for the pixel"},{name="char",type="number",description="optional: charfor the pixel"}}},{name="image",parameters={{name="x",type="number"},{name="y",type="number"},{name="image",type="PaintUtilsImage",description="load with paintutils"}}},{name="setBufferSize",parameters={{name="x1",type="number",description="x of starting position of the buffer's window"},{name="y1",type="number",description="y of starting position of the buffer's window"},{name="x2",type="number",description="x of ending position of the buffer's window"},{name="y2",type="number",description="y of ending position of the buffer's window"}}},{name="clear",parameters={{name="color",type="number",description="color from CC's colors library to use for clearning the buffer for the first time"}}},{name="fastClear",parameters={{name="color",type="number",description="color from CC's colors library to use for clearning the buffer quickly, after the screenBuffer has been initialized"}}},{name="drawTriangle",parameters={{name="x1",type="number"},{name="y1",type="number"},{name="x2",type="number"},{name="y2",type="number"},{name="x3",type="number"},{name="y3",type="number"},{name="c",type="number",description="fill color"},{name="char",type="char",description="fill character"},{name="charc",type="number",description="fill character color"}}},{name="useTriangleEdges",parameters={{name="enabled",type="boolean",description="if enabled, uses black as default outline color for triangles"}}}}end,["pine3d.metadata.Buffer.properties"]=function(...)return{{name="x1",type="number"},{name="y1",type="number"},{name="x2",type="number"},{name="y2",type="number"},{name="width",type="number"},{name="height",type="number"},{name="screenBuffer",type="table"},{name="blittleWindow",type="window"},{name="blittleOn",type="boolean"}}end,["pine3d.metadata.Buffer"]=function(...)local e={}local n=a("pine3d.metadata.Buffer.methods")local t=a("pine3d.metadata.Buffer.properties")e.methods=n
- e.properties=t
- return e
- end,["pine3d.metadata.CameraAngles.methods"]=function(...)return{}end,["pine3d.metadata.CameraAngles.properties"]=function(...)return{{name="[1]: sin(Camera[4])",type="number"},{name="[2]: cos(Camera[4])",type="number"},{name="[3]: sin(Camera[5])",type="number"},{name="[4]: cos(Camera[5])",type="number"},{name="[5]: sin(Camera[6])",type="number"},{name="[6]: cos(Camera[6])",type="number"}}end,["pine3d.metadata.CameraAngles"]=function(...)local e={}local n=a("pine3d.metadata.CameraAngles.methods")local t=a("pine3d.metadata.CameraAngles.properties")e.methods=n
- e.properties=t
- return e
- end,["pine3d.metadata.CollapsedCamera.methods"]=function(...)return{}end,["pine3d.metadata.CollapsedCamera.properties"]=function(...)return{{name="[1]: x",type="number"},{name="[2]: y",type="number"},{name="[3]: z",type="number"},{name="[4]: rotationX",type="number",description="the camera rotation around the x axis (why would you do this if you don't want to puke, unless you're making something fancy like KSP, Space Engineers or a racing game with curved roads and fancy cameras)"},{name="[5]: rotationY",type="number",description="the camera rotation around the y axis (horizontal rotation)"},{name="[6]: rotationZ",type="number",description="the camera rotation around the z axis (vertical rotation)"},{name="[7]: FoV",type="number",description="the Field of View in radians"}}end,["pine3d.metadata.CollapsedCamera"]=function(...)local e={}local n=a("pine3d.metadata.CollapsedCamera.methods")local t=a("pine3d.metadata.CollapsedCamera.properties")e.methods=n
- e.properties=t
- return e
- end,["pine3d.metadata.CollapsedModel.methods"]=function(...)return{}end,["pine3d.metadata.CollapsedModel.properties"]=function(...)return{}end,["pine3d.metadata.CollapsedModel"]=function(...)local e={}local t=a("pine3d.metadata.CollapsedModel.methods")local n=a("pine3d.metadata.CollapsedModel.properties")e.methods=t
- e.properties=n
- return e
- end,["pine3d.metadata.CollapsedPolygon.methods"]=function(...)return{}end,["pine3d.metadata.CollapsedPolygon.properties"]=function(...)return{{name="[1]: x1",type="number"},{name="[2]: y1",type="number"},{name="[3]: z1",type="number"},{name="[4]: x2",type="number"},{name="[5]: y2",type="number"},{name="[6]: z2",type="number"},{name="[7]: x3",type="number"},{name="[8]: y3",type="number"},{name="[9]: z3",type="number"},{name="[10]: forceRender",type="boolean",description="if true, always renders polygon from both sides, regardless of orientation"},{name="[11]: c",type="number",description="CC color from the colors library"},{name="[12]: char",type="char",description="character used to fill the polygon when drawn without BLittle mode"},{name="[13]: charc",type="number",description="color for the character used to fill the polygon when drawn without BLittle mode"},{name="[14]: outlineColor",type="number",description="color used as outline for the polygon"}}end,["pine3d.metadata.CollapsedPolygon"]=function(...)local e={}local t=a("pine3d.metadata.CollapsedPolygon.methods")local n=a("pine3d.metadata.CollapsedPolygon.properties")e.methods=t
- e.properties=n
- return e
- end,["pine3d.metadata.Model.methods"]=function(...)return{{name="invertTriangles",parameters={{name="model",type="Model",description="Model to transform and invert the triangles of"}},["return"]={{name="model with polygons facing the other direction",type="Model"}}},{name="setOutline",parameters={{name="model",type="Model",description="Model to transform"},{name="options",type="color or table",description="if color, will set the outline color for each polygon. If table, it is a mapping of triangle colors to the outline color they should have"}},["return"]={{name="new model with changed outline colors",type="Model"}}},{name="mapColor",parameters={{name="model",type="Model",description="Model to transform"},{name="options",type="color or table",description="if color, will set the color for each polygon. If table, it is a mapping of triangle colors to the color they should have"}},["return"]={{name="new model with updated colors",type="Model"}}},{name="center",parameters={{name="model",type="Model",description="Model to center"}},["return"]={{name="new centered model",type="Model"}}},{name="normalizeScale",parameters={{name="model",type="Model",description="Model to update. Rescales the model such that the largest value of any coordinate is equal to 1"}},["return"]={{name="new model",type="Model"}}},{name="normalizeScaleY",parameters={{name="model",type="Model",description="Model to update. Similar to normalizeScale, rescales the model, but only uses the y coordinate to determine how much it is scaled (normalizes height)"}},["return"]={{name="new model",type="Model"}}},{name="scale",parameters={{name="model",type="Model",description="Model to scale"},{name="scale",type="number",description="factor to scale the model with"}},["return"]={{name="new model",type="Model"}}},{name="translate",parameters={{name="model",type="Model",description="Model to scale"},{name="dx",type="number",description="translation amount for the x-axis (optional)"},{name="dy",type="number",description="translation amount for the y-axis (optional)"},{name="dz",type="number",description="translation amount for the z-axis (optional)"}},["return"]={{name="new model",type="Model"}}},{name="rotate",parameters={{name="model",type="Model",description="Model to rotate"},{name="rotX",type="number",description="rotation around the x-axis (optional, radians)"},{name="rotY",type="number",description="rotation around the y-axis (optional, radians)"},{name="rotZ",type="number",description="rotation around the z-axis (optional, radians)"}},["return"]={{name="new model",type="Model"}}},{name="alignBottom",parameters={{name="model",type="Model",description="Model to align"}},["return"]={{name="new model",type="Model"}}}}end,["pine3d.metadata.Model.properties"]=function(...)return{}end,["pine3d.metadata.Model"]=function(...)local e={}local t=a("pine3d.metadata.Model.methods")local n=a("pine3d.metadata.Model.properties")e.methods=t
- e.properties=n
- return e
- end,["pine3d.metadata.ModelGenerator.methods"]=function(...)return{{name="cube",parameters={{name="options",type="table",description="Options for the cube. Available options: color, bottom, bottom2, top, top2, side, side2"}},["return"]={{name="cube",type="Model"}}},{name="sphere",parameters={{name="options",type="table",description="Options for the sphere. Available options: res, color"}},["return"]={{name="sphere",type="Model"}}},{name="icosphere",parameters={{name="options",type="table",description="Options for the icosphere. Available options: res, color, top (color), bottom (color), colors (table of colors for gradient), colorsFractal"}},["return"]={{name="icosphere",type="Model"}}},{name="plane",parameters={{name="options",type="table",description="Options for the plane. Available options: color, size, y"}},["return"]={{name="flat plane",type="Model"}}},{name="mountains",parameters={{name="options",type="table",description="Options for the mountains. Available options: res, randomOffset, height, randomHeight, y, scale, color, snow (bool), snowColor"}},["return"]={{name="mountains",type="Model"}}}}end,["pine3d.metadata.ModelGenerator.properties"]=function(...)return{}end,["pine3d.metadata.ModelGenerator"]=function(...)local e={}local t=a("pine3d.metadata.ModelGenerator.methods")local n=a("pine3d.metadata.ModelGenerator.properties")e.methods=t
- e.properties=n
- return e
- end,["pine3d.metadata.PineCamera.methods"]=function(...)return{}end,["pine3d.metadata.PineCamera.properties"]=function(...)return{{name="x",type="number"},{name="y",type="number"},{name="z",type="number"},{name="rotX",type="number",description="the camera rotation around the x axis (why would you do this if you don't want to puke, unless you're making something fancy like KSP, Space Engineers or a racing game with curved roads and fancy cameras)"},{name="rotY",type="number",description="the camera rotation around the y axis (horizontal rotation)"},{name="rotZ",type="number",description="the camera rotation around the z axis (vertical rotation)"}}end,["pine3d.metadata.PineCamera"]=function(...)local e={}local t=a("pine3d.metadata.PineCamera.methods")local n=a("pine3d.metadata.PineCamera.properties")e.methods=t
- e.properties=n
- return e
- end,["pine3d.metadata.PineObject.methods"]=function(...)return{{name="setPos",parameters={{name="x",type="number",description="new x position (optional)"},{name="y",type="number",description="new y position (optional)"},{name="z",type="number",description="new z position (optional)"}}},{name="setRot",parameters={{name="rotX",type="number",description="new rotation around the x axis in radians (optional)"},{name="rotY",type="number",description="new rotation around the y axis in radians (optional)"},{name="rotZ",type="number",description="new rotation around the z axis in radians (optional)"}}},{name="setModel",parameters={{name="model",type="string or Model",description="if string, used as path to load the serialized Model"}}}}end,["pine3d.metadata.PineObject.properties"]=function(...)return{{name="[1]: x",type="number"},{name="[2]: y",type="number"},{name="[3]: z",type="number"},{name="[4]: rotationX",type="number",description="the objects rotation around the x axis (you're probably not using this unless you want to attempt 3d physics)"},{name="[5]: rotationY",type="number",description="the objects rotation around the y axis (horizontal rotation)"},{name="[6]: rotationZ",type="number",description="the objects rotation around the z axis (vertical rotation)"},{name="[7]: model",type="CollapsedModel",description="the model that is rendered for this object"},{name="[8]: modelSize",type="number",description="largest distance of a vertex from the center of the model"}}end,["pine3d.metadata.PineObject"]=function(...)local e={}local n=a("pine3d.metadata.PineObject.methods")local t=a("pine3d.metadata.PineObject.properties")e.methods=n
- e.properties=t
- return e
- end,["pine3d.metadata.Polygon.methods"]=function(...)return{}end,["pine3d.metadata.Polygon.properties"]=function(...)return{{name="x1",type="number"},{name="y1",type="number"},{name="z1",type="number"},{name="x2",type="number"},{name="y2",type="number"},{name="z2",type="number"},{name="x3",type="number"},{name="y3",type="number"},{name="z3",type="number"},{name="forceRender",type="boolean",description="if true, always renders polygon from both sides, regardless of orientation"},{name="c",type="number",description="CC color from the colors library"},{name="char",type="char",description="character used to fill the polygon when drawn without BLittle mode"},{name="charc",type="number",description="color for the character used to fill the polygon when drawn without BLittle mode"},{name="outlineColor",type="number",description="color used as outline for the polygon"}}end,["pine3d.metadata.Polygon"]=function(...)local e={}local t=a("pine3d.metadata.Polygon.methods")local n=a("pine3d.metadata.Polygon.properties")e.methods=t
- e.properties=n
- return e
- end,["pine3d.metadata.ThreeDFrame.methods"]=function(...)return{{name="setSize",parameters={{name="x1",type="number",description="x of starting position of the 3d rendering window"},{name="y1",type="number",description="y of starting position of the 3d rendering window"},{name="x2",type="number",description="x of ending position of the 3d rendering window"},{name="y2",type="number",description="y of ending position of the 3d rendering window"}}},{name="setBackgroundColor",parameters={{name="color",type="number",description="CC color from the colors library"}}},{name="highResMode",parameters={{name="enabled",type="boolean",description="if true, enables the use of characters 128-168 for a higher quality, seemingly larger resolution. Enabled by default"}}},{name="setCamera",parameters={{name="cameraX",type="number",description="x coordinate of the new camera position (optional)"},{name="cameraY",type="number",description="y coordinate of the new camera position (optional)"},{name="cameraZ",type="number",description="z coordinate of the new camera position (optional)"},{name="rotX",type="number",description="new camera rotation around the x axis (optional)"},{name="rotY",type="number",description="new camera rotation around the y axis (optional)"},{name="rotZ",type="number",description="new camera rotation around the z axis (optional)"}}},{name="setCamera",parameters={{name="camera",type="PineCamera",description="string indexed table with values for x, y, z, rotX, rotY, rotZ (all optional)"}}},{name="setFoV",parameters={{name="FoV",type="number",description="the new field of view of the camera in degrees"}}},{name="newObject",parameters={{name="model",type="string or Model",description="if string, used as path to load the serialized Model"},{name="x",type="number",description="x coordinate of the PineObject"},{name="y",type="number",description="y coordinate of the PineObject"},{name="z",type="number",description="z coordinate of the PineObject"},{name="rotX",type="number",description="rotation around the x axis (optional)"},{name="rotY",type="number",description="rotation around the y axis (optional)"},{name="rotZ",type="number",description="rotation around the z axis (optional)"}},["return"]={{name="object",type="PineObject",description="newly created object"}}},{name="getObjectIndexTrace",["return"]={{name="objectIndex",type="number",description="the index in the objects array for the PineObject that is rendered at the given position"},{name="polygonIndex",type="number",description="the index of the polygon in the Model rendered at the given position that corresponds to the PineObject at the given position"}},parameters={{name="objects",type="array of PineObject",description=""},{name="x",type="number",description="x coordinate on the screen"},{name="y",type="number",description="y coordinate on the screen"}}},{name="map3dTo2d",["return"]={{name="screenX",type="number"},{name="screenY",type="number"},{name="visible",type="boolean"}},parameters={{name="x",type="number",description="x coordinate in 3d space"},{name="y",type="number",description="y coordinate in 3d space"},{name="z",type="number",description="z coordinate in 3d space"}}},{name="drawObject",parameters={{name="object",type="PineObject",description="the PineObject to draw to the internal Buffer"},{name="cameraAngles",type="CameraAngles",description="CameraAngles for fast calculations. Can be dirived from CollapsedCamera"}}},{name="drawObjects",parameters={{name="objects",type="array of PineObject",description="table of objects to draw to the internal Buffer"}}},{name="drawBuffer",parameters={}}}end,["pine3d.metadata.ThreeDFrame.properties"]=function(...)return{{name="camera",type="CollapsedCamera"},{name="buffer",type="Buffer"},{name="x1",type="number"},{name="y1",type="number"},{name="x2",type="number"},{name="y2",type="number"},{name="width",type="number"},{name="height",type="number"}}end,["pine3d.metadata.ThreeDFrame"]=function(...)local e={}local n=a("pine3d.metadata.ThreeDFrame.methods")local t=a("pine3d.metadata.ThreeDFrame.properties")e.methods=n
- e.properties=t
- return e
- end,["generate-typings"]=function(...)local e=a("lualib_bundle")local l=e.__TS__StringReplaceAll
- local i=e.__TS__StringStartsWith
- local d=e.__TS__ArrayFilter
- local r=e.__TS__ArrayMap
- local c=e.__TS__StringEndsWith
- local s={}local u=a("pine3d.metadata.Buffer")local m=a("pine3d.metadata.CameraAngles")local f=a("pine3d.metadata.CollapsedCamera")local x=a("pine3d.metadata.CollapsedModel")local _=a("pine3d.metadata.CollapsedPolygon")local w=a("pine3d.metadata.Model")local y=a("pine3d.metadata.ModelGenerator")local p=a("pine3d.metadata.PineCamera")local g=a("pine3d.metadata.PineObject")local b=a("pine3d.metadata.Polygon")local v=a("pine3d.metadata.ThreeDFrame")local function e(e)local e,n=io.open(e,"rb")if not e then
- error("could not open file: "..n)end
- local n=e:read("*a")if not n then
- error"could not read file"end
- e:close()return n
- end
- local function C(e,o)local n,t=io.open(e,"wb")if not n then
- error((("could not open file "..e)..": ")..t)end
- local o,t=n:write(o)if not o then
- error((("could not write to file "..e)..": ")..t)end
- n:close()end
- local function t(e)local n={{"(%w+) indexed table of (%w+)","LuaTable<%1, %2>"},{"table of (%w+)","LuaTable<number, %1>"},{"array of (%w+)","%1[]"},{"table","LuaTable<AnyNotNil, any>"}}for t,n in ipairs(n)do
- local t=n[1]local n=n[2]e=string.gsub(e,t,n)end
- return l(l(e," or ","|"),"char","string")end
- local function h(o)local e={}local a={}for o,n in ipairs(o.properties)do
- if i(n.name,"[")then
- local e=string.match(n.name,"^%[(%d+)%]:")a[tonumber(e)]=t(n.type)..(" /*"..n.name).."*/"else
- e[#e+1]=((n.name..": ")..t(n.type)).."\n"end
- end
- for n,o in ipairs(o.methods)do
- e[#e+1]="\n/**\n"for t,n in ipairs(o.parameters)do
- local t=n.description or""if#t>0 then
- e[#e+1]=(((" * @param "..n.name).." ")..t).."\n"end
- end
- local n=o["return"]if n and#d(n,function(n,e)return e.description end)>0 then
- e[#e+1]=" * @returns "..table.concat(r(n,function(n,e)return e.description or""end),"")end
- e[#e+1]=" */\n"e[#e+1]=o.name
- e[#e+1]="("local l={}for o,n in ipairs(o.parameters)do
- local e=n.description or""local e=(i(e,"optional")or c(e,"(optional)"))and"?"or""l[#l+1]=((n.name..e)..": ")..t(n.type)end
- e[#e+1]=table.concat(l,", ")e[#e+1]=")"if n then
- if#n==1 then
- e[#e+1]=": "..t(n[1].type)else
- e[#e+1]=": LuaMultiReturn<["e[#e+1]=table.concat(r(n,function(n,e)return t(e.type)end),", ")e[#e+1]="]>"end
- else
- e[#e+1]=": void"end
- e[#e+1]="\n"end
- return a,e
- end
- local function a(...)local e={{"Buffer",u},{"CameraAngles",m},{"CollapsedCamera",f},{"CollapsedModel",x},{"CollapsedPolygon",_},{"Model",w},{"ModelGenerator",y},{"PineCamera",p},{"PineObject",g},{"Polygon",b},{"ThreeDFrame",v}}C("/src/pine3d/integrate-me",table.concat(r(e,function(n,e)local t
- local n
- n=e[1]t=e[2]local r,e=h(t)local t=("{\n\t"..l(l(table.concat(e,""),"\n","\n\t").."\n","\t\n","\n")).."}"local o=#r
- if o==0 then
- return((("export interface "..n).." ")..t).."\n"else
- local e={}for n=1,o do
- e[#e+1]="null"end
- for n,t in pairs(r)do
- e[n]=t
- end
- return((((("export type "..n).." = [\n\t")..table.concat(e,",\n\t")).."\n] & ")..t)..";\n"end
- end),"\n"))end
- a(...)return s
- end,}return a("game",...)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement