forked from redo/BlockLua
Merge branch 'master'
This commit is contained in:
@@ -202,11 +202,11 @@ setForceType = function(ftname, typ)
|
||||
error('bl.type: invalid type \''..typ..'\'', 2) end
|
||||
if not isValidFuncNameNsArgn(ftname) then
|
||||
error('bl.type: invalid function or variable name \''..ftname..'\'', 2) end
|
||||
|
||||
|
||||
ftname = ftname:lower()
|
||||
|
||||
|
||||
bl._forceType[ftname] = typ
|
||||
|
||||
|
||||
-- apply to child classes if present
|
||||
local cname, rest = classFromForceTypeStr(ftname)
|
||||
if cname then
|
||||
@@ -296,7 +296,7 @@ function bl.class(cname, inhname)
|
||||
if not ( inhname==nil or (type(inhname)=='string' and isValidFuncName(inhname)) ) then
|
||||
error('bl.class: argument #2: inherit name must be a string or nil', 2) end
|
||||
cname = cname:lower()
|
||||
|
||||
|
||||
local met = bl._objectUserMetas[cname] or {
|
||||
_name = cname,
|
||||
_inherit = nil,
|
||||
@@ -304,22 +304,22 @@ function bl.class(cname, inhname)
|
||||
}
|
||||
bl._objectUserMetas[cname] = met
|
||||
setmetatable(met, tsClassMeta)
|
||||
|
||||
|
||||
if inhname then
|
||||
inhname = inhname:lower()
|
||||
|
||||
|
||||
local inh = bl._objectUserMetas[inhname]
|
||||
if not inh then error('bl.class: argument #2: \''..inhname..'\' is not the '..
|
||||
'name of an existing class', 2) end
|
||||
|
||||
|
||||
inh._children[cname] = true
|
||||
|
||||
|
||||
local inhI = met._inherit
|
||||
if inhI and inhI~=inh then
|
||||
error('bl.class: argument #2: class already exists and '..
|
||||
'inherits a different parent.', 2) end
|
||||
met._inherit = inh
|
||||
|
||||
|
||||
-- apply inherited method and field types
|
||||
for ftname, typ in pairs(bl._forceType) do
|
||||
local cname2, rest = classFromForceTypeStr(ftname)
|
||||
@@ -521,11 +521,11 @@ toTsObject = function(idiS)
|
||||
error('toTsObject: input must be a string', 2) end
|
||||
idiS = idiS:lower()
|
||||
if bl._objectsWeak[idiS] then return bl._objectsWeak[idiS] end
|
||||
|
||||
|
||||
if not tsIsObject(idiS) then
|
||||
--error('toTsObject: object \''..idiS..'\' does not exist', 2) end
|
||||
return nil end
|
||||
|
||||
|
||||
local className = _bllua_ts.callobj(idiS, 'getClassName')
|
||||
local obj = {
|
||||
_tsObjectId = _bllua_ts.callobj(idiS, 'getId' ),
|
||||
@@ -534,7 +534,7 @@ toTsObject = function(idiS)
|
||||
_tsClassName = className:lower(),
|
||||
}
|
||||
setmetatable(obj, tsObjectMeta)
|
||||
|
||||
|
||||
bl._objectsWeak[obj._tsObjectId ] = obj
|
||||
bl._objectsWeak[obj._tsName:lower()] = obj
|
||||
return obj
|
||||
@@ -856,11 +856,11 @@ function bl.hook(pkg, name, time, func)
|
||||
error('bl.hook: argument #3: time must be \'before\' or \'after\'', 2) end
|
||||
if type(func)~='function' then
|
||||
error('bl.hook: argument #4: expected a function', 2) end
|
||||
|
||||
|
||||
bl._hooks[pkg] = bl._hooks[pkg] or {}
|
||||
bl._hooks[pkg][name] = bl._hooks[pkg][name] or {}
|
||||
bl._hooks[pkg][name][time] = func
|
||||
|
||||
|
||||
updateHook(pkg, name, bl._hooks[pkg][name])
|
||||
activatePackage(pkg)
|
||||
end
|
||||
@@ -874,7 +874,7 @@ function bl.unhook(pkg, name, time)
|
||||
error('bl.unhook: argument #2: invalid function name \''..tostring(name)..'\'', 2) end
|
||||
if time~='before' and time~='after' then
|
||||
error('bl.unhook: argument #3: time must be \'before\' or \'after\'', 2) end
|
||||
|
||||
|
||||
if not name then
|
||||
if bl._hooks[pkg] then
|
||||
for name,hk in pairs(bl._hooks[pkg]) do
|
||||
@@ -961,9 +961,9 @@ function bl.raycast(start, stop, mask, ignores)
|
||||
for _,v in ipairs(ignores) do
|
||||
table.insert(ignoresS, objToTs(v))
|
||||
end
|
||||
|
||||
|
||||
local retS = _bllua_ts.call('containerRaycast', startS, stopS, maskS, unpack(ignoresS))
|
||||
|
||||
|
||||
if retS=='0' then
|
||||
return nil
|
||||
else
|
||||
@@ -988,7 +988,7 @@ function bl.boxSearch(pos, size, mask)
|
||||
local posS = vecToTs(pos)
|
||||
local sizeS = vecToTs(size)
|
||||
local maskS = maskToTs(mask)
|
||||
|
||||
|
||||
_bllua_ts.call('initContainerBoxSearch', posS, sizeS, maskS)
|
||||
return tsContainerSearchIterator
|
||||
end
|
||||
@@ -998,7 +998,7 @@ function bl.radiusSearch(pos, radius, mask)
|
||||
error('bl.radiusSearch: argument #2: radius must be a number', 2) end
|
||||
local radiusS = tostring(radius)
|
||||
local maskS = maskToTs(mask)
|
||||
|
||||
|
||||
_bllua_ts.call('initContainerRadiusSearch', posS, radiusS, maskS)
|
||||
return tsContainerSearchIterator
|
||||
end
|
||||
@@ -1037,7 +1037,7 @@ local function createTsObj(keyword, class, name, inherit, props)
|
||||
table.insert(propsT, k..'="'..valToTs(v)..'";')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local objS = _bllua_ts.eval(
|
||||
'return '..keyword..' '..class..'('..
|
||||
(name or '')..(inherit and (':'..inherit) or '')..'){'..
|
||||
@@ -1045,7 +1045,7 @@ local function createTsObj(keyword, class, name, inherit, props)
|
||||
local obj = toTsObject(objS)
|
||||
if not obj then
|
||||
error('bl.new/bl.datablock: failed to create object', 3) end
|
||||
|
||||
|
||||
return obj
|
||||
end
|
||||
local function parseTsDecl(decl)
|
||||
|
||||
Reference in New Issue
Block a user