aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_mapgen.cpp
Commit message (Expand)AuthorAge
...
* Move biome calculation to BiomeGenkwolekr2016-05-27
* Fix threshold typeest312015-12-07
* Fix spelling of noise_thresholdJun Zhang2015-12-06
* Schematics: Add core.place_schematic_on_vmanip APIkwolekr2015-11-05
* SAPI: Throw runtime error instead of if l_get_mapgen_object called in incorre...kwolekr2015-10-25
* SAPI: Mark all Lua API functions requiring envlockkwolekr2015-10-25
* Allow setting chunksize in core.set_mapgen_paramskwolekr2015-10-04
* Define and use limit constants for Irrlicht fixed-width typeskwolekr2015-10-04
* Add get_biome_id(biome_name) callbackDuane Robertson2015-10-02
* Ore: Add puff ore typekwolekr2015-09-17
* Ore: Add ore sheet column height range selectionkwolekr2015-09-13
* Biome API: Make fallback biome stone and water, disable fillerparamat2015-08-03
* Fix MSVC number conversion warningSmallJoker2015-07-25
* Mapgen objects: Enable heatmap and humidmap for all biome api mapgensparamat2015-06-20
* Make get_biome_list() error message more helpfulkwolekr2015-05-28
* Add some missing getter functions to the lua APITeTpaAka2015-05-28
* Fix null dereference when loading schematic from definition without a NodeDef...kwolekr2015-05-17
* Add mod securityShadowNinja2015-05-16
* Fix compiler warning about sign comparisonest312015-05-13
* Schematics: Add per-node force placement optionkwolekr2015-05-09
* Tests: Add schematic unittestskwolekr2015-05-08
* Schematics: Add indent-with-space option for schematic Lua table serializationkwolekr2015-05-07
* NodeResolver: Remove NodeResolveMethodkwolekr2015-05-07
* Ore: Add biomes parameterkwolekr2015-04-20
* Biome API: Add biome-specific river waterparamat2015-04-19
* Schematics: Fix core.schematic_create()kwolekr2015-04-17
* Switch to check_v3s16 in l_mapgen.cpp and l_vmanip.cpp for type safetykwolekr2015-04-17
* Biomes: Remove referenced biomes from Decorations on clearkwolekr2015-04-16
* Schematics: Refactor NodeResolver and add NodeResolveMethodkwolekr2015-04-16
* Schematics: Reorganize (de)serialization and add Lua serialization APIkwolekr2015-04-13
* Schematics: Prepend mod path to relative schematic filepathskwolekr2015-04-08
* Move globals from main.cpp to more sane locationsCraig Robbins2015-04-01
* ObjDefManager, Mapgen SAPI: Huge refactoringkwolekr2015-03-31
* GenElementManager: Pass opaque handles to Lua and rename to ObjDefManagerkwolekr2015-03-31
* lua_api/l_mapgen: generate_ores/decorations: make p1, p2 optionalparamat2015-03-24
* Add core.register_schematic() and cache schematics on usekwolekr2015-03-23
* Revert "Fix issue #2441: crash on respawn, since a conversion std::list to st...kwolekr2015-03-20
* lua_api/l_mapgen: Fix overlapping areas of minetest.generate_ores/decorationsparamat2015-03-11
* Fix issue #2441: crash on respawn, since a conversion std::list to std::vecto...Loic Blot2015-03-05
* Biome API: Re-calculate biome at every surface in a mapchunk columnparamat2015-02-26
* Shorten ManualMapVoxelManipulator to MMVManipkwolekr2015-01-05
* Add minetest.generate_ores() and minetest.generate_decorations()kwolekr2015-01-04
* Add warning about using deprecated fields in Mapgen API and update docskwolekr2015-01-04
* Replace instances of height_min/height_max with y_min/y_max to remove ambiguitykwolekr2014-12-30
* Decoration: Fix default parameter valueskwolekr2014-12-30
* Expose mapgen parameters on scripting initkwolekr2014-12-29
* Decoration: Add height_min and height_max parameterskwolekr2014-12-28
* Biome API: Add shore top and shore filler nodes, underwater node, water top n...paramat2014-12-28
* Ore: Add Vein ore typekwolekr2014-12-28
* Ore: Add Blob ore typekwolekr2014-12-28
ss="hl slc">// 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, ServerActiveObject *self, 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; // Deprecated: read object properties directly read_object_properties(L, -1, self, prop, getServer()->idef()); // Read initial_properties lua_getfield(L, -1, "initial_properties"); read_object_properties(L, -1, self, prop, getServer()->idef()); lua_pop(L, 1); } void ScriptApiEntity::luaentity_Step(u16 id, float dtime, const collisionMoveResult *moveresult) { SCRIPTAPI_PRECHECKHEADER 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 /* moveresult */ if (moveresult) push_collision_move_result(L, *moveresult); else lua_pushnil(L); setOriginFromTable(object); PCALL_RES(lua_pcall(L, 3, 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 = readParam<bool>(L, -1); lua_pop(L, 2); // Pop object and error handler return retval; } // Calls entity[field](ObjectRef self, ObjectRef sao) bool ScriptApiEntity::luaentity_run_simple_callback(u16 id, ServerActiveObject *sao, const char *field) { SCRIPTAPI_PRECHECKHEADER 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, field); if (lua_isnil(L, -1)) { lua_pop(L, 2); // Pop callback field and entity return false; } luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self objectrefGetOrCreate(L, sao); // killer reference setOriginFromTable(object); PCALL_RES(lua_pcall(L, 2, 1, error_handler)); bool retval = readParam<bool>(L, -1); lua_pop(L, 2); // Pop object and error handler return retval; } bool ScriptApiEntity::luaentity_on_death(u16 id, ServerActiveObject *killer) { return luaentity_run_simple_callback(id, killer, "on_death"); } // Calls entity:on_rightclick(ObjectRef clicker) void ScriptApiEntity::luaentity_Rightclick(u16 id, ServerActiveObject *clicker) { luaentity_run_simple_callback(id, clicker, "on_rightclick"); } void ScriptApiEntity::luaentity_on_attach_child(u16 id, ServerActiveObject *child) { luaentity_run_simple_callback(id, child, "on_attach_child"); } void ScriptApiEntity::luaentity_on_detach_child(u16 id, ServerActiveObject *child) { luaentity_run_simple_callback(id, child, "on_detach_child"); } void ScriptApiEntity::luaentity_on_detach(u16 id, ServerActiveObject *parent) { luaentity_run_simple_callback(id, parent, "on_detach"); }