Commit graph

106 commits

Author SHA1 Message Date
Chris Beck
720f4cdb83 use setfuncs instead of register, so we can do partial define 2014-11-10 15:34:13 -05:00
Chris Beck
76141a0de1 new code for lua protected calls in lua_kernel_base
In initial commit of the new lua kernels, I introduced a problem
by trying to use luaW_pcall and lua_pcall interchangeably via
polymorphism. This doesn't work because their return types don't
match, and it's alot of work to change luaW_pcall syntax. Besides
this there's no reason we can't use the custom error handler
everywhere.

This commits adds protected_call and load_string functions to lua
kernel base. These are an intended replacement for luaW_pcall,
and replace the "run" function. They do better error reporting
and allow to specify an error handler.

The error reporting is very flexible -- by default we select a
an error reporting function associated polymorphically to the lua
kernel, so the in-game lua kernel can send chat messages, and
others can do something else. However an arbitrary handler may
be specified, and exceptions instead of logging may also be
requested.
2014-11-10 15:32:19 -05:00
Chris Beck
ecc714e41e add application lua kernel and game launcher lua wrapper object
The application lua kernel is meant to interpret scripts to drive
the client. Its main features are, it stores a script in its
registry and provides a C++ function to call it with a config
as its argument. Its initialization also creates a "game_launcher"
object, which stands as a limited lua proxy for the C++
game_launcher object.

The game_launcher object is a table, holding a pointer to the
actual game_launcher it represents, and with metamethods to return
version info and the command line arguments. It also holds
callbacks to set the script for the current application lua kernel,
and to call the "play_multiplayer" function of game_launcher.
Currently it is readonly and you cannot write to its fields,
although that may change to allow the target server to be reset,
etc.

Some minor changes that are included in this commit:
- the actual C++ game launcher object provides an accessor to the
command line options.
- the scripting/lua_types.hpp file now has include guards
2014-11-09 20:47:26 -05:00
Chris Beck
ca309d98b2 branch off "lua_common" functions from api defn file
This includes the gettext and vconfig impl functions, and many
macros used to write lua callbacks. This code can't properly go in
the lua_kernel_base files, so it goes here.
2014-11-09 18:45:14 -05:00
Chris Beck
4541412ebc add lua_kernel_base as a super class of game_lua_kernel
This class holds some "basic" initialization and methods that we
would want in any lua kernel. It is not pure virtual, it could
be instantiated.
2014-11-09 18:45:14 -05:00
Chris Beck
042b72a4b8 rename scripting/lua.?pp to game_lua_kernel.?pp 2014-11-09 18:45:14 -05:00
Renamed from src/scripting/lua.cpp (Browse further)