reply turned out to be a page or two of text, so I figured it best to post it
here instead of just sending it to 1 person (NOTE: the original questions
have been edited).
-----------------------------------------------------------------------------------------------
My notes:
1. LuaBZFS no longer exists, it has been renamed to LuaServer.
The current lua scripts for bzflag are:
Code: Select all
Execution Source
-------- ------
LuaServer server server file
LuaUser client client directory
LuaWorld client server directory bundled with the world data
LuaBzOrg client a managed URL link on http://bzflag.org
"plug-ins", so as to avoid confusion with the current bzfs C plug-ins. For
SpringRTS, I called the client-side scripts "widgets", and the server-side
scripts "gadgets" (actually, unsynced and synced lua code, but that's
something that doesn't really need to be explained here). A similar approach
will probably be used for the various bzflag lua scripting environments.
-----------------------------------------------------------------------------------------------
a) Is there any documentation beside the code itself?
No, but some of the documentation for SpringRTS is relevant
(example: the OpenGL API is very similar)
http://spring.clan-sy.com/wiki/Lua_Scripting
Once I get around to it, I'll post some example scripts (enough to
get you started, after which you can dig through the code for
details.) The lua/c++ interface code is usually pretty easy to read
through. Take a look through src/lua/LuaCallOuts.cxx for starters.
b) Can the plug-in control the client's appearance
Client-side lua modules can change the way everything is drawn
(GUI and viewport). There are call-outs to acquire "graphics blocks",
which block the engine's default rendering (see include/GfxBlock.h).
Note that LuaUser can not use the "world items" blocks, because it
has limited visibility of world state (this was done to forbid path
prediction scripts, etc...)
c) Can the plug-in affect the client's command line behaviour?
Client-side lua can grab almost all key and mouse events. With respect to
overriding chat command messages, you can use the bz.GetCmdToKeys()
call-out to determine which keys the user has bound to chat messaging.
Current input events that can not be grabbed are:
1. "F12" key events
2. Any key events while there's an active HUD element
(that includes the text compose line, menus, etc...)
* see playing.cxx:handleEvent() for the code
d) What is the syntax for the default slash commands?
/luaserver (server-side)
/luauser (client-side)
/luaworld (client-side)
/luabzorg (client-side)
They all have the following syntax:
/luaTAG <status | reload | disable | CUSTOM>
If the command is something other than status, reload, or disable, the
command line is passed to the associated lua script via the RecvCommand()
call-in.
-----------------------------------------------------------------------------------------------
P.S. Both the server-side and client-side scripts can use the new
MsgLuaData and MsgLuaDataFast network protocol packet types to
implement custom messaging. From playing.cxx:
Code: Select all
static void handleLuaData(void *msg)
{
PlayerId srcPlayerID;
int16_t srcScriptID;
PlayerId dstPlayerID;
int16_t dstScriptID;
uint8_t statusBits;
std::string data;
msg = nboUnpackUByte(msg, srcPlayerID);
msg = nboUnpackShort(msg, srcScriptID);
msg = nboUnpackUByte(msg, dstPlayerID);
msg = nboUnpackShort(msg, dstScriptID);
msg = nboUnpackUByte(msg, statusBits);
msg = nboUnpackStdStringRaw(msg, data);
eventHandler.RecvLuaData(srcPlayerID, srcScriptID,
dstPlayerID, dstScriptID,
statusBits, data);
}
the following:
- custom MsgLuaData messages could be used for all communications
- the client-side lua scripts can change how everything is rendered
- the client-side lua scripts can grab almost all keyboard and mouse events
- the client-side lua scripts can play sounds
Basically, you could setup a bzfs server with LuaServer and LuaWorld
scripts such that the connected clients play a game that is not bzflag.
You could also set it up so that observers play tic-tac-toe against each
other while watching the tankers do their thing