diff --git a/BlockLua.dll b/BlockLua.dll index 0935a5b..6ba6f6d 100644 Binary files a/BlockLua.dll and b/BlockLua.dll differ diff --git a/readme.md b/readme.md index 24fce77..525343a 100644 --- a/readme.md +++ b/readme.md @@ -48,11 +48,21 @@ Lua scripting for Blockland `for object in bl.boxSearch(vector{centerX,y,z}, vector{sizeX,y,z}, 'objtype'/{'objtypes',...}) do` - Find all objects in the world of the specified type(s) whose bounding box overlaps with the specified box. See the Types section for a list of valid object types. `for object in bl.radiusSearch(vector{centerX,y,z}, radius, 'objtype'/{'objtypes',...}) do` - Find all objects of the specified type(s) whose bounding box overlaps with the specified sphere. See the Types section for a list of valid object types. +### List of Object Classes (for raycasts and searches) +`'all'` - Any object +`'player'` - Players or bots +`'item'` - Items +`'vehicle'` - Vehicles +`'projectile'` - Projectiles +`'brick'` - Bricks with raycasting enabled +`'brickalways'` - All bricks including those with raycasting disabled +Other types: `'static'`, `'environment'`, `'terrain'`, `'water'`, `'trigger'`, `'marker'`, `'gamebase'`, `'shapebase'`, `'camera'`, `'staticshape'`, `'vehicleblocker'`, `'explosion'`, `'corpse'`, `'debris'`, `'physicalzone'`, `'staticts'`, `'staticrendered'`, `'damagableitem'` + ### Server-Client Communication `bl.addServerCmd('commandName', function(client, args...) ... end)` - Register a /command on the server `bl.addClientCmd('commandName', function(args...) ... end)` - Register a client command on the client -`bl.commandToServer('commandName', args...)` - Execute a server command as a client -`bl.commandToClient('commandName', args...)` - As the server, execute a client command on a specific client +`bl.commandToServer('commandName', args...)` - As a client, execute a server command +`bl.commandToClient(client, 'commandName', args...)` - As the server, execute a client command on a specific client `bl.commandToAll('commandName', args...)` - As the server, execute a client command on all clients ### Packages/Hooks @@ -136,8 +146,8 @@ When reading from outside ZIPs, binary files are fully supported. WIP ### Extended Standard Lua Library -`string[index]` -`string[{start,stop}]` +`str[index]` +`str[{start,stop}]` `string.split(str, separator='' (splits into chars), noregex=false)` `string.bytes(str)` `string.trim(str, charsToTrim=' \t\r\n')` @@ -201,16 +211,6 @@ BlockLua can be built in Unsafe Mode by specifying the `-DBLLUA_UNSAFE` compiler A more limited option is `-DBLLUA_ALLOWFFI`, which allows the use of the `ffi` library. This can still be exploited to grant all the same access as full unsafe mode. Please do not publish add-ons that require either of these. -### List of Object Types -`'all'` - Any object -`'player'` - Players or bots -`'item'` - Items -`'vehicle'` - Vehicles -`'projectile'` - Projectiles -`'brick'` - Bricks with raycasting enabled -`'brickalways'` - All bricks including those with raycasting disabled -Other types: `'static'`, `'environment'`, `'terrain'`, `'water'`, `'trigger'`, `'marker'`, `'gamebase'`, `'shapebase'`, `'camera'`, `'staticshape'`, `'vehicleblocker'`, `'explosion'`, `'corpse'`, `'debris'`, `'physicalzone'`, `'staticts'`, `'staticrendered'`, `'damagableitem'` - ## Compiling With any *32-bit* variant of GCC installed (such as MinGW or MSYS2), run the following command in the repo directory: diff --git a/src/util/libbl.lua b/src/util/libbl.lua index c84806e..98250b3 100644 --- a/src/util/libbl.lua +++ b/src/util/libbl.lua @@ -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