1
0
forked from redo/BlockLua

fix commandToClient, handle net strings when passed to lua, misc readme additions

This commit is contained in:
Redo
2025-12-07 11:52:40 -05:00
parent b71bfdb73e
commit ae34bb8b7a
3 changed files with 22 additions and 17 deletions

View File

@@ -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