Beispiel #1
0
GameScripting::GameScripting(Server* server)
{
	setServer(server);

	// setEnv(env) is called by ScriptApiEnv::initializeEnvironment()
	// once the environment has been created

	//TODO add security

	luaL_openlibs(getStack());

	SCRIPTAPI_PRECHECKHEADER

	// Create the main minetest table
	lua_newtable(L);

	lua_newtable(L);
	lua_setfield(L, -2, "object_refs");

	lua_newtable(L);
	lua_setfield(L, -2, "luaentities");

	lua_setglobal(L, "minetest");

	// Initialize our lua_api modules
	lua_getglobal(L, "minetest");
	int top = lua_gettop(L);
	InitializeModApi(L, top);
	lua_pop(L, 1);

	infostream << "SCRIPTAPI: initialized game modules" << std::endl;
}
MainMenuScripting::MainMenuScripting(GUIMainMenu* guiengine)
{
	setGuiEngine(guiengine);

	//TODO add security

	luaL_openlibs(getStack());

	SCRIPTAPI_PRECHECKHEADER

	lua_pushstring(L, DIR_DELIM);
	lua_setglobal(L, "DIR_DELIM");

	lua_newtable(L);
	lua_setglobal(L, "gamedata");

	lua_newtable(L);
	lua_setglobal(L, "engine");

	// Initialize our lua_api modules
	lua_getglobal(L, "engine");
	int top = lua_gettop(L);
	InitializeModApi(L, top);
	lua_pop(L, 1);

	infostream << "SCRIPTAPI: initialized mainmenu modules" << std::endl;
}
GameScripting::GameScripting(Server* server)
{
    setServer(server);

    // setEnv(env) is called by ScriptApiEnv::initializeEnvironment()
    // once the environment has been created

    SCRIPTAPI_PRECHECKHEADER

    if (g_settings->getBool("secure.enable_security")) {
        initializeSecurity();
    }

    lua_getglobal(L, "core");
    int top = lua_gettop(L);

    lua_newtable(L);
    lua_setfield(L, -2, "object_refs");

    lua_newtable(L);
    lua_setfield(L, -2, "luaentities");

    // Initialize our lua_api modules
    InitializeModApi(L, top);
    lua_pop(L, 1);

    // Push builtin initialization type
    lua_pushstring(L, "game");
    lua_setglobal(L, "INIT");

    infostream << "SCRIPTAPI: Initialized game modules" << std::endl;
}
Beispiel #4
0
ClientScripting::ClientScripting(Client *client):
	ScriptApiBase(ScriptingType::Client)
{
	setGameDef(client);

	SCRIPTAPI_PRECHECKHEADER

	// Security is mandatory client side
	initializeSecurityClient();

	lua_getglobal(L, "core");
	int top = lua_gettop(L);

	lua_newtable(L);
	lua_setfield(L, -2, "ui");

	InitializeModApi(L, top);
	lua_pop(L, 1);

	if (client->getMinimap())
		LuaMinimap::create(L, client->getMinimap());

	// Push builtin initialization type
	lua_pushstring(L, "client");
	lua_setglobal(L, "INIT");

	infostream << "SCRIPTAPI: Initialized client game modules" << std::endl;
}