forked from redo/BlockLua
fix commandToClient, handle net strings when passed to lua, misc readme additions
This commit is contained in:
@@ -194,6 +194,10 @@ local function valFromTs(val, name, name2)
|
||||
-- vector, box, or axis->matrix
|
||||
local vec = multinumericFromTs(val)
|
||||
if vec then return vec end
|
||||
-- net string
|
||||
if val:sub(1,1)=='\x01' then
|
||||
return _bllua_ts.call('getTaggedString', val)
|
||||
end
|
||||
-- string
|
||||
return val
|
||||
end
|
||||
@@ -676,7 +680,7 @@ luaLookup = function(tbl, name, set, val)
|
||||
local first, rest = name:match('^([^%.:]+)%.(.+)$')
|
||||
if not isValidFuncName(first) then
|
||||
error('luaLookup: invalid name \''..tostring(first)..'\'', 3) end
|
||||
if not tbl[first] then
|
||||
if tbl[first]==nil then
|
||||
if set then tbl[first] = {}
|
||||
else return nil end
|
||||
end
|
||||
@@ -691,7 +695,7 @@ luaLookup = function(tbl, name, set, val)
|
||||
error('luacall: invalid method name \''..tostring(first)..'\'', 3) end
|
||||
if not tbl[first] then
|
||||
error('luacall: no object named \''..rest..'\'', 3) end
|
||||
if not tbl[first][rest] then
|
||||
if tbl[first][rest]==nil then
|
||||
error('luacall: no method named \''..rest..'\'', 3) end
|
||||
return function(...)
|
||||
tbl[first][rest](tbl[first], ...)
|
||||
@@ -790,8 +794,9 @@ function bl.commandToServer(cmd, ...)
|
||||
_bllua_ts.call('addTaggedString', cmd),
|
||||
unpack(arglistToTs({...})))
|
||||
end
|
||||
function bl.commandToClient(cmd, ...)
|
||||
function bl.commandToClient(client, cmd, ...)
|
||||
_bllua_ts.call('commandToClient',
|
||||
valToTs(client),
|
||||
_bllua_ts.call('addTaggedString', cmd),
|
||||
unpack(arglistToTs({...})))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user