mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
toggleable lua support during build
This commit is contained in:
@@ -50,6 +50,7 @@ option(USE_IMGUI_GL3 "Use OpenGL3+ imgui implementation" ON)
|
||||
option(WITH_OPENGL_MODERN "Compile with OpenGL modern renderer" ON)
|
||||
option(WITH_OPENGL_LEGACY "Compile with OpenGL legacy renderer" ON)
|
||||
option(WITH_UART "Compile with libserialport" ON)
|
||||
option(WITH_LUA "Compile with lua scripting support" ON)
|
||||
option(WITH_OPENVR "Compile with OpenVR" ON)
|
||||
option(WITH_ZMQ "Compile with cppzmq" OFF)
|
||||
option(WITH_CRASHPAD "Compile with crashpad" OFF)
|
||||
@@ -108,7 +109,6 @@ set(SOURCES
|
||||
"drivermouseinput.cpp"
|
||||
"translation.cpp"
|
||||
"material.cpp"
|
||||
"lua.cpp"
|
||||
"stdafx.cpp"
|
||||
"messaging.cpp"
|
||||
"scene.cpp"
|
||||
@@ -232,6 +232,11 @@ if (WITH_OPENVR)
|
||||
set(SOURCES ${SOURCES} "vr/openvr_imp.cpp")
|
||||
endif()
|
||||
|
||||
if (WITH_LUA)
|
||||
add_definitions(-DWITH_LUA)
|
||||
set(SOURCES ${SOURCES} "lua.cpp")
|
||||
endif()
|
||||
|
||||
if (WITH_OPENGL_MODERN)
|
||||
set(SOURCES ${SOURCES}
|
||||
"opengl33geometrybank.cpp"
|
||||
@@ -424,9 +429,11 @@ endif()
|
||||
find_package(SndFile REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} SndFile::sndfile)
|
||||
|
||||
find_package(LuaJIT REQUIRED)
|
||||
include_directories(${LUAJIT_INCLUDE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} ${LUAJIT_LIBRARIES})
|
||||
if (WITH_LUA)
|
||||
find_package(LuaJIT REQUIRED)
|
||||
include_directories(${LUAJIT_INCLUDE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} ${LUAJIT_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if (WITH_UART)
|
||||
find_package(libserialport REQUIRED)
|
||||
|
||||
@@ -2075,6 +2075,7 @@ friction_event::export_as_text_( std::ostream &Output ) const {
|
||||
Output << m_friction << ' ';
|
||||
}
|
||||
|
||||
#ifdef WITH_LUA
|
||||
lua_event::lua_event(lua::eventhandler_t func) {
|
||||
lua_func = func;
|
||||
}
|
||||
@@ -2118,6 +2119,7 @@ lua_event::export_as_text_( std::ostream &Output ) const {
|
||||
bool lua_event::is_instant() const {
|
||||
return m_delay == 0.0 && m_delayrandom == 0.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// prepares event for use
|
||||
void
|
||||
|
||||
7
Event.h
7
Event.h
@@ -14,10 +14,13 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Names.h"
|
||||
#include "EvLaunch.h"
|
||||
#include "Logs.h"
|
||||
#include "lua.h"
|
||||
#include "command.h"
|
||||
#include "comparison.h"
|
||||
|
||||
#ifdef WITH_LUA
|
||||
#include "lua.h"
|
||||
#endif
|
||||
|
||||
// common event interface
|
||||
class basic_event {
|
||||
|
||||
@@ -585,6 +588,7 @@ private:
|
||||
float m_friction{ -1.f };
|
||||
};
|
||||
|
||||
#ifdef WITH_LUA
|
||||
class lua_event : public basic_event {
|
||||
public:
|
||||
lua_event(lua::eventhandler_t func);
|
||||
@@ -599,6 +603,7 @@ private:
|
||||
|
||||
lua::eventhandler_t lua_func = nullptr;
|
||||
};
|
||||
#endif
|
||||
|
||||
class message_event : public basic_event {
|
||||
|
||||
|
||||
@@ -41,9 +41,12 @@ instance_table Instances;
|
||||
vehicle_table Vehicles;
|
||||
train_table Trains;
|
||||
light_array Lights;
|
||||
lua Lua;
|
||||
particle_manager Particles;
|
||||
|
||||
#ifdef WITH_LUA
|
||||
lua Lua;
|
||||
#endif
|
||||
|
||||
scene::basic_region *Region { nullptr };
|
||||
TTrain *Train { nullptr };
|
||||
|
||||
|
||||
@@ -11,11 +11,14 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "simulationstateserializer.h"
|
||||
#include "Classes.h"
|
||||
#include "lua.h"
|
||||
#include "Event.h"
|
||||
#include "Train.h"
|
||||
#include "particles.h"
|
||||
|
||||
#ifdef WITH_LUA
|
||||
#include "lua.h"
|
||||
#endif
|
||||
|
||||
namespace simulation {
|
||||
|
||||
class state_manager {
|
||||
@@ -78,8 +81,10 @@ extern vehicle_table Vehicles;
|
||||
extern train_table Trains;
|
||||
extern light_array Lights;
|
||||
extern sound_table Sounds;
|
||||
extern lua Lua;
|
||||
extern particle_manager Particles;
|
||||
#ifdef WITH_LUA
|
||||
extern lua Lua;
|
||||
#endif
|
||||
|
||||
extern scene::basic_region *Region;
|
||||
extern TTrain *Train;
|
||||
|
||||
@@ -319,7 +319,11 @@ void state_serializer::deserialize_lua( cParser &Input, scene::scratch_data &Scr
|
||||
Input.getTokens(1, false);
|
||||
std::string file;
|
||||
Input >> file;
|
||||
#ifdef WITH_LUA
|
||||
simulation::Lua.interpret(Global.asCurrentSceneryPath + file);
|
||||
#else
|
||||
ErrorLog(file + ": lua scripts not supported in this build.");
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user