27 struct luascript_func_hash;
28 struct luascript_signal_hash;
29 struct luascript_signal_name_list;
34 const char *format, ...)
44 QHash<QString, struct luascript_func *> *
funcs;
58 bool secured_environment);
69 const
char *format, va_list args);
72 enum api_types *parg_types, va_list args);
74 int nreturns, enum api_types *preturn_types,
85 int nargs, enum api_types *parg_types,
100 #define LUASCRIPT_ASSERT(L, check, ...) \
102 luascript_error(L, "in %s() [%s::%d]: the assertion '%s' failed.", \
103 __FUNCTION__, __FILE__, __FC_LINE__, #check); \
104 return __VA_ARGS__; \
107 #define LUASCRIPT_ASSERT(check, ...)
110 #define LUASCRIPT_CHECK_STATE(L, ...) \
112 qCritical("No lua state available"); \
113 return __VA_ARGS__; \
117 #define LUASCRIPT_CHECK(L, check, msg, ...) \
119 luascript_error(L, msg); \
120 return __VA_ARGS__; \
124 #define LUASCRIPT_CHECK_ARG(L, check, narg, msg, ...) \
126 luascript_arg_error(L, narg, msg); \
127 return __VA_ARGS__; \
131 #define LUASCRIPT_CHECK_ARG_NIL(L, value, narg, type, ...) \
132 if ((value) == nullptr) { \
133 luascript_arg_error(L, narg, "got 'nil', '" #type "' expected"); \
134 return __VA_ARGS__; \
139 #define LUASCRIPT_CHECK_SELF(L, value, ...) \
140 if ((value) == nullptr) { \
141 luascript_arg_error(L, 2, "got 'nil' for self"); \
142 return __VA_ARGS__; \
void luascript_pop_returns(struct fc_lua *fcl, const char *func_name, int nreturns, enum api_types *preturn_types, va_list args)
Pop return values from the Lua stack.
void luascript_push_args(struct fc_lua *fcl, int nargs, enum api_types *parg_types, va_list args)
Push arguments into the Lua stack.
void luascript_log(struct fc_lua *fcl, QtMsgType level, const char *format,...) fc__attribute((__format__(__printf__
void luascript_init(fc_lua *fcl)
Sets the freeciv lua struct for a lua state.
struct fc_lua * luascript_new(luascript_log_func_t outputfct, bool secured_environment)
Initialize the scripting state.
bool luascript_check_function(struct fc_lua *fcl, const char *funcname)
Return if the function 'funcname' is define in the lua state 'fcl->state'.
int luascript_error(lua_State *L, const char *format,...) fc__attribute((__format__(__printf__
int int luascript_error_vargs(lua_State *L, const char *format, va_list vargs)
Internal api error function.
int luascript_arg_error(lua_State *L, int narg, const char *msg)
Like script_error, but using a prefix identifying the called lua function:
bool luascript_callback_invoke(struct fc_lua *fcl, const char *callback_name, int nargs, enum api_types *parg_types, va_list args)
Invoke the 'callback_name' Lua function.
void luascript_remove_exported_object(struct fc_lua *fcl, void *object)
Mark any, if exported, full userdata representing 'object' in the current script state as 'Nonexisten...
int luascript_do_string(struct fc_lua *fcl, const char *str, const char *name)
lua_dostring replacement with error message showing on errors.
int luascript_do_file(struct fc_lua *fcl, const char *filename)
Parse and execute the script at filename.
void luascript_vars_load(struct fc_lua *fcl, struct section_file *file, const char *section)
Load lua variables from file.
const Direction * luascript_dir(enum direction8)
Returns a pointer to a given value of enum direction8 (always the same address for the same value),...
void luascript_common_z(lua_State *L)
Runs tolua_common_z.lua.
void void luascript_log_vargs(struct fc_lua *fcl, QtMsgType level, const char *format, va_list args)
Print a message to the selected output handle.
void luascript_vars_save(struct fc_lua *fcl, struct section_file *file, const char *section)
Save lua variables to file.
void luascript_common_a(lua_State *L)
Runs tolua_common_a.lua.
void(* luascript_log_func_t)(struct fc_lua *fcl, QtMsgType level, const char *format,...) fc__attribute((__format__(__printf__
struct fc_lua * luascript_get_fcl(lua_State *L)
Get the freeciv lua struct from a lua state.
int luascript_call(struct fc_lua *fcl, int narg, int nret, const char *code)
Evaluate a Lua function call or loaded script on the stack.
void luascript_destroy(struct fc_lua *fcl)
Free the scripting data.
enum direction8 Direction
static void static sol::state * fcl
Lua virtual machine state.
struct setting_list * level[OLEVELS_NUM]
struct connection * caller
QVector< QString > * signal_names
luascript_log_func_t output_fct
QHash< QString, struct signal * > * signals_hash
QHash< QString, struct luascript_func * > * funcs
int fc__attribute((nonnull(1, 3)))