aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_mainmenu.cpp
Commit message (Expand)AuthorAge
* Sanitize world directory names on create. Keep original name separate (#9432)Hugues Ross2020-07-28
* Add core.open_url() to main menu API (#8592)rubenwardy2020-05-17
* Give the online lua mainmenu also the client_list and mods (#8691)Lejo2020-05-01
* Formspecs: Add state-selection to style elements (#9378)Hugues Ross2020-04-11
* Add support for set_formspec_prepend in main menu (#8611)rubenwardy2019-08-12
* Hide uninstall package button on unmodifiable paths (#8255)rubenwardy2019-03-05
* Fix extract zip writing lowercase files (#8221)rubenwardy2019-02-14
* Content store: Fix storage leak by storing screenshots in cache (#8137)rubenwardy2019-01-31
* Fix pkgmgr game install with RUN_IN_PLACE=0 (#8113)Paul Ouellette2019-01-26
* Fix various bugs (Anticheat, Lua helpers) (#8013)SmallJoker2019-01-06
* Fix ContentDB packages timing out by using download_file instead (#7891)rubenwardy2018-12-11
* Content store: Add setting to filter non-free packages (#7766)rubenwardy2018-11-08
* Add protocol_version and supported package types to ContentDB urlsrubenwardy2018-07-29
* Modernize lua read (part 2 & 3): C++ templating assurance (#7410)Loïc Blot2018-06-30
* Fix world deletion (#7494)Vitaliy2018-06-30
* Update to new ContentDB APIrubenwardy2018-06-18
* Add screenshots to online content browserrubenwardy2018-05-20
* Add updating to online content browserrubenwardy2018-05-16
* Add online content repositoryrubenwardy2018-04-19
* Load dependencies and description from mod.confAndrew Ward2018-03-28
* Load files from subfolders in texturepacksnumber Zero2017-11-17
* Move files to subdirectories (#6599)Vitaliy2017-11-08
* Network: Remove large parts of deprecated legacy code (#6404)SmallJoker2017-09-12
* Modernize source code: last part (#6285)Loïc Blot2017-08-20
* Remove remaining modstore code (#6120)Elijah Duffy2017-07-14
* Main Menu: Allow copying directories from non-Minetest locations (#6095)Elijah Duffy2017-07-04
* Isolate irrlicht references and use a singleton (#6041)Loïc Blot2017-06-26
* Improve the path select GUI (#5852)red-0012017-06-11
* Main Menu: Add get_clientmodpath API (#5912)Elijah Duffy2017-06-06
* Use a settings object for the main settingsShadowNinja2017-05-06
* Fix various points reported by cppcheck (#5656)Loïc Blot2017-04-25
* [CSM] sound_play & sound_stop support + client_lua_api doc (#5096)Loïc Blot2017-03-13
* Serverlist: Add ping indicators (#5164)kilbith2017-02-03
* Add version APIShadowNinja2016-10-31
* Mapgen: Refactor mapgen creation and managementkwolekr2016-07-03
* Add option to not send pre v25 init packetest312016-03-15
* Remove wstrgettextest312015-10-18
* Hide mapgens from main menu not intended for end userskwolekr2015-10-04
* Add emerge completion callback mechanismkwolekr2015-10-04
* Optional reconnect functionalityest312015-07-23
* Use UTF-8 instead of narrowest312015-07-08
* Use utf-8 in formspecsIlya Zhuravlev2015-06-13
* Add core.get_dir_listShadowNinja2015-05-16
* Move globals from main.cpp to more sane locationsCraig Robbins2015-04-01
* Fix typoCraig Robbins2015-03-29
* Add Lua function get_video_modes() for main menuCraig Robbins2015-03-28
* Clean up and tweak build systemShadowNinja2015-03-27
* Fix game minetest.conf default settingsest312015-03-18
* For usages of assert() that are meant to persist in Release builds (when NDEB...Craig Robbins2015-03-07
* Server: announce MIN/MAX protocol version supported to serverlist. Client: ch...est312015-02-18
e); lua_setmetatable(L, -2); // Add object reference // This should be userdata with metatable ObjectRef push_objectRef(L, id); luaL_checktype(L, -1, LUA_TUSERDATA); if (!luaL_checkudata(L, -1, "ObjectRef")) luaL_typerror(L, -1, "ObjectRef"); lua_setfield(L, -2, "object"); // core.luaentities[id] = object lua_getglobal(L, "core"); lua_getfield(L, -1, "luaentities"); luaL_checktype(L, -1, LUA_TTABLE); lua_pushnumber(L, id); // Push id lua_pushvalue(L, object); // Copy object to top of stack lua_settable(L, -3); return true; } void ScriptApiEntity::luaentity_Activate(u16 id, const std::string &staticdata, u32 dtime_s) { SCRIPTAPI_PRECHECKHEADER verbosestream << "scriptapi_luaentity_activate: id=" << id << std::endl; int error_handler = PUSH_ERROR_HANDLER(L); // Get core.luaentities[id] luaentity_get(L, id); int object = lua_gettop(L); // Get on_activate function lua_getfield(L, -1, "on_activate"); if (!lua_isnil(L, -1)) { luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self lua_pushlstring(L, staticdata.c_str(), staticdata.size()); lua_pushinteger(L, dtime_s); setOriginFromTable(object); PCALL_RES(lua_pcall(L, 3, 0, error_handler)); } else { lua_pop(L, 1); } lua_pop(L, 2); // Pop object and error handler } void ScriptApiEntity::luaentity_Remove(u16 id) { SCRIPTAPI_PRECHECKHEADER verbosestream << "scriptapi_luaentity_rm: id=" << id << std::endl; // Get core.luaentities table lua_getglobal(L, "core"); lua_getfield(L, -1, "luaentities"); luaL_checktype(L, -1, LUA_TTABLE); int objectstable = lua_gettop(L); // Set luaentities[id] = nil lua_pushnumber(L, id); // Push id lua_pushnil(L); lua_settable(L, objectstable); lua_pop(L, 2); // pop luaentities, core } std::string ScriptApiEntity::luaentity_GetStaticdata(u16 id) { SCRIPTAPI_PRECHECKHEADER //infostream<<"scriptapi_luaentity_get_staticdata: id="<<id<<std::endl; int error_handler = PUSH_ERROR_HANDLER(L); // Get core.luaentities[id] luaentity_get(L, id); int object = lua_gettop(L); // Get get_staticdata function lua_getfield(L, -1, "get_staticdata"); if (lua_isnil(L, -1)) { lua_pop(L, 2); // Pop entity and get_staticdata return ""; } luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self setOriginFromTable(object); PCALL_RES(lua_pcall(L, 1, 1, error_handler)); lua_remove(L, object); lua_remove(L, error_handler); size_t len = 0; const char *s = lua_tolstring(L, -1, &len); lua_pop(L, 1); // Pop static data return std::string(s, len); } void ScriptApiEntity::luaentity_GetProperties(u16 id, ObjectProperties *prop) { SCRIPTAPI_PRECHECKHEADER //infostream<<"scriptapi_luaentity_get_properties: id="<<id<<std::endl; // Get core.luaentities[id] luaentity_get(L, id); // Set default values that differ from ObjectProperties defaults prop->hp_max = 10; /* Read stuff */ prop->hp_max = getintfield_default(L, -1, "hp_max", 10); getboolfield(L, -1, "physical", prop->physical); getboolfield(L, -1, "collide_with_objects", prop->collideWithObjects); getfloatfield(L, -1, "weight", prop->weight); lua_getfield(L, -1, "collisionbox"); if (lua_istable(L, -1)) prop->collisionbox = read_aabb3f(L, -1, 1.0); lua_pop(L, 1); getstringfield(L, -1, "visual", prop->visual); getstringfield(L, -1, "mesh", prop->mesh); // Deprecated: read object properties directly read_object_properties(L, -1, prop, getServer()->idef()); // Read initial_properties lua_getfield(L, -1, "initial_properties"); read_object_properties(L, -1, prop, getServer()->idef()); lua_pop(L, 1); } void ScriptApiEntity::luaentity_Step(u16 id, float dtime) { SCRIPTAPI_PRECHECKHEADER //infostream<<"scriptapi_luaentity_step: id="<<id<<std::endl; int error_handler = PUSH_ERROR_HANDLER(L); // Get core.luaentities[id] luaentity_get(L, id); int object = lua_gettop(L); // State: object is at top of stack // Get step function lua_getfield(L, -1, "on_step"); if (lua_isnil(L, -1)) { lua_pop(L, 2); // Pop on_step and entity return; } luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self lua_pushnumber(L, dtime); // dtime setOriginFromTable(object); PCALL_RES(lua_pcall(L, 2, 0, error_handler)); lua_pop(L, 2); // Pop object and error handler } // Calls entity:on_punch(ObjectRef puncher, time_from_last_punch, // tool_capabilities, direction, damage) bool ScriptApiEntity::luaentity_Punch(u16 id, ServerActiveObject *puncher, float time_from_last_punch, const ToolCapabilities *toolcap, v3f dir, s16 damage) { SCRIPTAPI_PRECHECKHEADER //infostream<<"scriptapi_luaentity_step: id="<<id<<std::endl; int error_handler = PUSH_ERROR_HANDLER(L); // Get core.luaentities[id] luaentity_get(L,id); int object = lua_gettop(L); // State: object is at top of stack // Get function lua_getfield(L, -1, "on_punch"); if (lua_isnil(L, -1)) { lua_pop(L, 2); // Pop on_punch and entity return false; } luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self objectrefGetOrCreate(L, puncher); // Clicker reference lua_pushnumber(L, time_from_last_punch); push_tool_capabilities(L, *toolcap); push_v3f(L, dir); lua_pushnumber(L, damage); setOriginFromTable(object); PCALL_RES(lua_pcall(L, 6, 1, error_handler)); bool retval = lua_toboolean(L, -1); lua_pop(L, 2); // Pop object and error handler return retval; } // Calls entity:on_rightclick(ObjectRef clicker) void ScriptApiEntity::luaentity_Rightclick(u16 id, ServerActiveObject *clicker) { SCRIPTAPI_PRECHECKHEADER //infostream<<"scriptapi_luaentity_step: id="<<id<<std::endl; int error_handler = PUSH_ERROR_HANDLER(L); // Get core.luaentities[id] luaentity_get(L, id); int object = lua_gettop(L); // State: object is at top of stack // Get function lua_getfield(L, -1, "on_rightclick"); if (lua_isnil(L, -1)) { lua_pop(L, 2); // Pop on_rightclick and entity return; } luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self objectrefGetOrCreate(L, clicker); // Clicker reference setOriginFromTable(object); PCALL_RES(lua_pcall(L, 2, 0, error_handler)); lua_pop(L, 2); // Pop object and error handler }