Load SSC fragments dynamicly

pull/122/head
Hleb Valoshka 2018-11-16 21:24:20 +03:00 committed by pirogronian
parent 358268ad61
commit 74c418dd1e
1 changed files with 19 additions and 0 deletions

View File

@ -3537,6 +3537,23 @@ static int celestia_play(lua_State*)
}
static int celestia_from_ssc(lua_State* l)
{
Celx_CheckArgs(l, 2, 2, "Function celestia:from_ssc requires exactly one argument");
CelestiaCore* appCore = this_celestia(l);
const char* s = Celx_SafeGetString(l, 2, AllErrors, "First argument to celestia:from_ssc must be a string");
if (s == nullptr)
{
lua_pushboolean(l, false);
return 1;
}
istringstream in(s);
bool ret = LoadSolarSystemObjects(in, *appCore->getSimulation()->getUniverse(), "");
lua_pushboolean(l, ret);
return 1;
}
static void CreateCelestiaMetaTable(lua_State* l)
{
Celx_CreateClassMetatable(l, Celx_Celestia);
@ -3639,6 +3656,8 @@ static void CreateCelestiaMetaTable(lua_State* l)
// Dummy command for compatibility purpose
Celx_RegisterMethod(l, "play", celestia_play);
Celx_RegisterMethod(l, "from_ssc", celestia_from_ssc);
lua_pop(l, 1);
}