mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 04:19:19 +02:00
- Lua bindings are no longer using FFI in favor of the "classic" Lua C API. - This makes it work properly on native Linux builds. - Changed the Lua API slightly: - Removed the `api.event_preparefunc()` function because it is no longer necessary. Instead, you can pass any function you want without preparing it first. - Added an `api.event_exists()` function. Takes a single `name` argument. - Any `api.find_*()` functions return `nil` instead of an userdata representing a null pointer when the requested object is not found.
50 lines
1.7 KiB
C++
50 lines
1.7 KiB
C++
#pragma once
|
|
#include <lua.hpp>
|
|
#include <stdafx.h>
|
|
|
|
class basic_event;
|
|
class TMemCell;
|
|
class TDynamicObject;
|
|
|
|
class lua
|
|
{
|
|
lua_State *state;
|
|
|
|
static int atpanic(lua_State *s);
|
|
|
|
static int scriptapi_event_create(lua_State *L);
|
|
static int scriptapi_event_find(lua_State *L);
|
|
static int scriptapi_event_exists(lua_State *L);
|
|
static int scriptapi_event_getname(lua_State *L);
|
|
static int scriptapi_event_dispatch(lua_State *L);
|
|
static int scriptapi_event_dispatch_n(lua_State *L);
|
|
static int scriptapi_track_find(lua_State *L);
|
|
static int scriptapi_track_isoccupied(lua_State *L);
|
|
static int scriptapi_track_isoccupied_n(lua_State *L);
|
|
static int scriptapi_isolated_find(lua_State *L);
|
|
static int scriptapi_isolated_isoccupied(lua_State *L);
|
|
static int scriptapi_isolated_isoccupied_n(lua_State *L);
|
|
static int scriptapi_train_getname(lua_State *L);
|
|
static int scriptapi_dynobj_putvalues(lua_State *L);
|
|
static int scriptapi_memcell_find(lua_State *L);
|
|
static int scriptapi_memcell_read(lua_State *L);
|
|
static int scriptapi_memcell_read_n(lua_State *L);
|
|
static int scriptapi_memcell_update(lua_State *L);
|
|
static int scriptapi_memcell_update_n(lua_State *L);
|
|
static int scriptapi_random(lua_State *L);
|
|
static int scriptapi_writelog(lua_State *L);
|
|
static int scriptapi_writeerrorlog(lua_State *L);
|
|
|
|
public:
|
|
lua();
|
|
~lua();
|
|
|
|
std::string get_error() const;
|
|
void interpret(const std::string& file) const;
|
|
static void unref(lua_State *L, int ref);
|
|
static void dispatch_event(lua_State *L, int handler, basic_event *event, const TDynamicObject *activator);
|
|
static void push_memcell_values(lua_State *L, const TMemCell *mc);
|
|
|
|
struct memcell_values { const char *str; double num1; double num2; };
|
|
};
|