WIP: Auios' version - Do not merge. Only here for comparison #9
@@ -83,16 +83,16 @@ local toTsObject
|
||||
local function tsBool(v) return v ~= '' and v ~= '0' end
|
||||
-- Convert a Lua var into a TS string, or error if not possible
|
||||
local function valToTs(val)
|
||||
if val == nil then -- nil -> ''
|
||||
if val == nil then -- nil -> ''
|
||||
return ''
|
||||
elseif type(val) == 'boolean' then -- bool -> 0 or 1
|
||||
return val and '1' or '0'
|
||||
elseif type(val) == 'number' then -- number
|
||||
elseif type(val) == 'number' then -- number
|
||||
return tostring(val)
|
||||
elseif type(val) == 'string' then -- string
|
||||
elseif type(val) == 'string' then -- string
|
||||
return val
|
||||
elseif type(val) == 'table' then
|
||||
if val._tsObjectId then -- object -> object id
|
||||
if val._tsObjectId then -- object -> object id
|
||||
return tostring(val._tsObjectId)
|
||||
elseif isTsVector(val) then -- vector - > 3 numbers
|
||||
return table.concat(val, ' ')
|
||||
@@ -1023,9 +1023,9 @@ local function parseTsDecl(decl)
|
||||
if decl:find(' ') then -- class ...
|
||||
local cl, rest = decl:match('^([^ ]+) ([^ ]+)$')
|
||||
class = cl
|
||||
if rest:find(':') then -- class name:inherit
|
||||
if rest:find(':') then -- class name:inherit
|
||||
name, inherit = rest:match('^([^:]*):([^:]+)$')
|
||||
if not name then class = nil end -- error
|
||||
if not name then class = nil end -- error
|
||||
if name == '' then name = nil end -- class :inherit
|
||||
else
|
||||
name = rest
|
||||
|
||||
@@ -183,14 +183,14 @@ function require(mod)
|
||||
if require_memo[mod] then return unpack(require_memo[mod]) end
|
||||
local fp = mod:gsub('%.', '/')
|
||||
local fns = {
|
||||
'./' .. fp .. '.lua', -- local file
|
||||
'./' .. fp .. '.lua', -- local file
|
||||
'./' .. fp .. '/init.lua', -- local library
|
||||
fp .. '.lua', -- global file
|
||||
fp .. '/init.lua', -- global library
|
||||
fp .. '.lua', -- global file
|
||||
fp .. '/init.lua', -- global library
|
||||
}
|
||||
if fp:lower():find('^add-ons/') then
|
||||
local addonpath = fp:lower():match('^add-ons/[^/]+') .. '/'
|
||||
table.insert(fns, addonpath .. fp .. '.lua') -- add-on file
|
||||
table.insert(fns, addonpath .. fp .. '.lua') -- add-on file
|
||||
table.insert(fns, addonpath .. fp .. '/init.lua') -- add-on library
|
||||
end
|
||||
for _, fn in ipairs(fns) do
|
||||
|
||||
Reference in New Issue
Block a user