mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 20:11:50 +00:00
add project args & add vc.get_project_args
This commit is contained in:
parent
4565c6a3bd
commit
aa5bd51206
5 changed files with 48 additions and 3 deletions
|
|
@ -15,9 +15,12 @@
|
|||
#include "usertypes/lua_type_pcmstream.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
|
||||
static debug::Logger logger("lua-state");
|
||||
static lua::State* main_thread = nullptr;
|
||||
static bool headless_mode = false;
|
||||
namespace {
|
||||
debug::Logger logger("lua-state");
|
||||
lua::State* main_thread = nullptr;
|
||||
bool headless_mode = false;
|
||||
const std::unordered_map<std::string, std::string>* project_args;
|
||||
}
|
||||
|
||||
using namespace lua;
|
||||
|
||||
|
|
@ -151,6 +154,13 @@ void lua::init_state(State* L, StateType stateType) {
|
|||
pushboolean(L, headless_mode);
|
||||
setglobal(L, "__VC_HEADLESS");
|
||||
|
||||
createtable(L, 0, project_args->size());
|
||||
for (const auto& [key, value] : *project_args) {
|
||||
pushstring(L, value);
|
||||
setfield(L, key);
|
||||
}
|
||||
setglobal(L, "__VC_PROJECT_ARGS");
|
||||
|
||||
auto file = "res:scripts/stdmin.lua";
|
||||
auto src = io::read_string(file);
|
||||
lua::pop(L, lua::execute(L, 0, src, "core:scripts/stdmin.lua"));
|
||||
|
|
@ -181,6 +191,7 @@ void lua::initialize(const EnginePaths& paths, const CoreParameters& params) {
|
|||
logger.info() << LUAJIT_VERSION;
|
||||
|
||||
headless_mode = params.headless;
|
||||
project_args = ¶ms.projectArgs;
|
||||
main_thread = create_state(
|
||||
paths, params.headless ? StateType::SCRIPT : StateType::BASE
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue