2022-03-31 14:41:19 -04:00
|
|
|
makeclass('ug')
|
|
|
|
|
|
|
|
|
|
function ug.the()
|
|
|
|
|
return tangible.scan('globals',0,0,0,true)[1]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
lis=tangible.scan('globals',0,0,0,true)
|
|
|
|
|
if #lis==0 then
|
2023-07-24 17:19:25 -04:00
|
|
|
local ugid=tangible.build{class='ug', animstate={xyz={0,0,0}, plane='globals'}}
|
2022-03-31 14:41:19 -04:00
|
|
|
print("The global table is "..tangible.id(ugid))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ug.set(var,val)
|
|
|
|
|
ug.the()[var]=val
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ug.get(var)
|
|
|
|
|
return ug.the()[var]
|
|
|
|
|
end
|
|
|
|
|
|
2022-04-25 12:20:29 -04:00
|
|
|
function login.cb_uglytimedaemon()
|
|
|
|
|
if not ug.get('time') then ug.set('time',0) end
|
|
|
|
|
while true do
|
|
|
|
|
wait(1)
|
|
|
|
|
ug.set('time',ug.get('time')+1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function time() return ug.get('time') end
|
2022-05-18 13:20:48 -04:00
|
|
|
|
2022-05-21 12:49:54 -04:00
|
|
|
function isa(k1,k2,k3,k4)
|
|
|
|
|
if k1==k2 or k1==k3 or k1==k4 then return true end
|
2022-05-18 13:20:48 -04:00
|
|
|
if k1==nil then return false end
|
|
|
|
|
local mt=getmetatable(k1)
|
|
|
|
|
if not mt then return false end
|
2022-05-21 12:49:54 -04:00
|
|
|
return isa(mt.__index,k2,k3,k4)
|
2022-05-18 13:20:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function tabcat(t1,t2)
|
|
|
|
|
for i=1,#t2 do t1[#t1+1]=t2[i] end
|
|
|
|
|
end
|
|
|
|
|
|
2022-05-18 19:02:46 -04:00
|
|
|
-- Example: multistart(function(t) return tangible.id(t)%3==0 end,function() print("Tangible "..tangible.id(tangible.place()).." here") end)
|
2022-05-21 12:49:54 -04:00
|
|
|
function multistart(fil,closure)
|
2022-05-18 19:02:46 -04:00
|
|
|
local lis=tangible.scan('nowhere',0,0,100,false)
|
|
|
|
|
tabcat(lis,tangible.scan('main',0,0,100,true))
|
2022-05-21 12:49:54 -04:00
|
|
|
local filter=type(fil)=='function' and fil or function(t) return isa(t,fil) end
|
2022-05-18 19:02:46 -04:00
|
|
|
for _,t in ipairs(lis) do if filter(t) then tangible.start(t,closure) end end
|
2022-05-18 13:20:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|