MCPcopy Create free account
hub / github.com/Cubitect/cubiomes-viewer / loadScript

Function loadScript

src/scripts.cpp:200–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200lua_State *loadScript(QString path, QString *err)
201{
202 lua_State *L = luaL_newstate();
203 bool ok = false;
204 do
205 {
206 if (luaL_loadfile(L, path.toLocal8Bit().data()) != LUA_OK)
207 {
208 if (err) *err = lua_tostring(L, -1);
209 break;
210 }
211 luaL_openlibs(L);
212 if (lua_pcall(L, 0, LUA_MULTRET, 0) != LUA_OK)
213 {
214 if (err) *err = lua_tostring(L, -1);
215 break;
216 }
217 if (lua_getglobal(L, "check") != LUA_TFUNCTION)
218 {
219 if (err) *err = QApplication::translate("Filter", "function check() was not defined");
220 break;
221 }
222 lua_pop(L, 1);
223 for (int id = 0; id < 256; id++)
224 {
225 const char *bname = biome2str(MC_NEWEST, id);
226 if (bname)
227 {
228 lua_pushinteger(L, id);
229 lua_setglobal(L, bname);
230 const char *bname_old = biome2str(MC_1_13, id);
231 if (bname != bname_old)
232 {
233 lua_pushinteger(L, id);
234 lua_setglobal(L, bname);
235 }
236 }
237 }
238 struct { int value; const char *name; } values[] = {
239 {Desert_Pyramid, "Desert_Pyramid"},
240 {Jungle_Temple, "Jungle_Temple"},
241 {Swamp_Hut, "Swamp_Hut"},
242 {Igloo, "Igloo"},
243 {Village, "Village"},
244 {Ocean_Ruin, "Ocean_Ruin"},
245 {Shipwreck, "Shipwreck"},
246 {Monument, "Monument"},
247 {Mansion, "Mansion"},
248 {Outpost, "Outpost"},
249 {Ruined_Portal, "Ruined_Portal"},
250 {Ruined_Portal_N, "Ruined_Portal_N"},
251 {Treasure, "Treasure"},
252 {Mineshaft, "Mineshaft"},
253 {Fortress, "Fortress"},
254 {Bastion, "Bastion"},
255 {End_City, "End_City"},
256 {End_Gateway, "End_Gateway"},
257 {Ancient_City, "Ancient_City"},

Callers 1

initMethod · 0.85

Calls 7

luaL_newstateFunction · 0.85
luaL_openlibsFunction · 0.85
lua_getglobalFunction · 0.85
lua_pushintegerFunction · 0.85
lua_setglobalFunction · 0.85
lua_closeFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected