aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_base.cpp
Commit message (Expand)AuthorAge
* Fix Lua panic when error() message is not a stringPaul Ouellette2020-06-07
* Drop content_sao.{cpp,h}Loic Blot2020-04-11
* Move PlayerSAO to dedicated filesLoic Blot2020-04-11
* Move serveractiveobject & unitsaoLoic Blot2020-04-11
* Work around LuaJIT issues on aarch64 (#9614)sfan52020-04-08
* Script API: Document ObjectRef handling in a commentsfan52020-02-23
* Load client mods into memory before execution.sfan52019-11-09
* Load CSM environment after the restrictions are knownSmallJoker2019-09-14
* Add node field to PlayerHPChangeReason table (#8368)Paul Ouellette2019-04-11
* HPChange Reason: Fix push after free, and type being overwritten (#8359)rubenwardy2019-03-12
* Move client-specific files to 'src/client' (#7902)Quentin Bazin2018-11-28
* Add a MSVC / Windows compatible snprintf function (#7353)nOOb31672018-07-22
* Modernize lua read (part 2 & 3): C++ templating assurance (#7410)Loïc Blot2018-06-30
* Add online content repositoryrubenwardy2018-04-19
* Add reasons to on_dieplayer and on_hpchangeAndrew Ward2018-03-28
* Move `setlocale` from Lua to C++.red-0012018-02-08
* [CSM] Don't Load the package library (#6944)red-0012018-01-22
* [CSM] Don't load the IO library. (#6087)red-0012018-01-04
* ServerEnv: Clean up object lifecycle handling (#6414)sfan52017-09-15
* Modernize source code: last part (#6285)Loïc Blot2017-08-20
* Create a filesystem abstraction layer for CSM and only allow accessing files ...red-0012017-06-30
* C++11 cleanup on constructors (#6000)Vincent Glize2017-06-19
* Fix a warning pointed by GCC 7.1Loic Blot2017-05-18
* [CSM] Add event on_place_node API lua (#5548)Vincent Glize2017-04-29
* [CSM] Client side moddingLoic Blot2017-03-13
* Make minetest abort on lua panicRogier2016-12-24
* Fix C++11 compilabilityest312016-01-23
* Fix Lua scripting synchronizationkwolekr2015-11-01
* Fix server crashing on Lua errorsShadowNinja2015-10-31
* Push error handler afresh each time lua_pcall is usedKahrl2015-08-27
* Use numeric indices and raw table access with LUA_REGISTRYINDEXKahrl2015-08-27
* SAPI: Track last executed mod and include in error messageskwolekr2015-08-12
* Improve Script CPP API diagnosticskwolekr2015-08-05
* Fix code style from recent commits and add misc. optimizationskwolekr2015-07-02
* Add Lua errors to error dialogrubenwardy2015-06-29
* Fix uninitialized variable errorest312015-06-02
* Add mod securityShadowNinja2015-05-16
* For usages of assert() that are meant to persist in Release builds (when NDEB...Craig Robbins2015-03-07
* Simplify loading of Android version of menuShadowNinja2014-11-20
* Fix object reference pushing functions when called from coroutinesShadowNinja2014-10-07
* Use "core" namespace internallyShadowNinja2014-05-08
* Organize builtin into subdirectoriesShadowNinja2014-05-07
* Only push the Lua error handler onceShadowNinja2014-04-27
* Remove lua_State parameter from LuaError::LuaErrorShadowNinja2014-03-15
* Pass arguments by referenceSelat2014-03-12
* Handle LuaErrors in Lua -> C++ calls on LuaJITShadowNinja2013-12-18
* Cleanup jthread and fix win32 buildsapier2013-12-01
* Pass a errfunc to lua_pcall to get a tracebackShadowNinja2013-11-15
* Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenuKahrl2013-08-14
* Move scriptapi to separate folder (by sapier)sapier2013-05-25
">{ return 20; } virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n) { INodeDefManager *ndef = env->getGameDef()->ndef(); ServerMap *map = &env->getServerMap(); MapNode n_top = map->getNodeNoEx(p+v3s16(0,1,0)); if((!ndef->get(n_top).light_propagates && n_top.getContent() != CONTENT_IGNORE) || ndef->get(n_top).isLiquid()) { n.setContent(ndef->getId("mapgen_dirt")); map->addNodeWithEvent(p, n); } } }; class MakeTreesFromSaplingsABM : public ActiveBlockModifier { private: content_t c_junglesapling; content_t c_dirt; content_t c_dirt_with_grass; public: MakeTreesFromSaplingsABM(ServerEnvironment *env, INodeDefManager *nodemgr) { c_junglesapling = nodemgr->getId("junglesapling"); c_dirt = nodemgr->getId("mapgen_dirt"); c_dirt_with_grass = nodemgr->getId("mapgen_dirt_with_grass"); } virtual std::set<std::string> getTriggerContents() { std::set<std::string> s; s.insert("sapling"); s.insert("junglesapling"); return s; } virtual float getTriggerInterval() { return 10.0; } virtual u32 getTriggerChance() { return 50; } virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n, u32 active_object_count, u32 active_object_count_wider) { INodeDefManager *ndef = env->getGameDef()->ndef(); ServerMap *map = &env->getServerMap(); MapNode n_below = map->getNodeNoEx(p - v3s16(0, 1, 0)); if (n_below.getContent() != c_dirt && n_below.getContent() != c_dirt_with_grass) return; bool is_jungle_tree = n.getContent() == c_junglesapling; actionstream <<"A " << (is_jungle_tree ? "jungle " : "") << "sapling grows into a tree at " << PP(p) << std::endl; std::map<v3s16, MapBlock*> modified_blocks; v3s16 tree_p = p; ManualMapVoxelManipulator vmanip(map); v3s16 tree_blockp = getNodeBlockPos(tree_p); vmanip.initialEmerge(tree_blockp - v3s16(1,1,1), tree_blockp + v3s16(1,1,1)); if (is_jungle_tree) { treegen::make_jungletree(vmanip, tree_p, ndef, myrand()); } else { bool is_apple_tree = myrand() % 4 == 0; treegen::make_tree(vmanip, tree_p, is_apple_tree, ndef, myrand()); } vmanip.blitBackAll(&modified_blocks); // update lighting std::map<v3s16, MapBlock*> lighting_modified_blocks; lighting_modified_blocks.insert(modified_blocks.begin(), modified_blocks.end()); map->updateLighting(lighting_modified_blocks, modified_blocks); // Send a MEET_OTHER event MapEditEvent event; event.type = MEET_OTHER; // event.modified_blocks.insert(modified_blocks.begin(), modified_blocks.end()); for(std::map<v3s16, MapBlock*>::iterator i = modified_blocks.begin(); i != modified_blocks.end(); ++i) { event.modified_blocks.insert(i->first); } map->dispatchEvent(&event); } }; class LiquidFlowABM : public ActiveBlockModifier { private: std::set<std::string> contents; public: LiquidFlowABM(ServerEnvironment *env, INodeDefManager *nodemgr) { std::set<content_t> liquids; nodemgr->getIds("group:liquid", liquids); for(std::set<content_t>::const_iterator k = liquids.begin(); k != liquids.end(); k++) contents.insert(nodemgr->get(*k).liquid_alternative_flowing); } virtual std::set<std::string> getTriggerContents() { return contents; } virtual float getTriggerInterval() { return 10.0; } virtual u32 getTriggerChance() { return 10; } virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n) { ServerMap *map = &env->getServerMap(); if (map->transforming_liquid_size() < 500) map->transforming_liquid_add(p); //if ((*map).m_transforming_liquid.size() < 500) (*map).m_transforming_liquid.push_back(p); } }; void add_legacy_abms(ServerEnvironment *env, INodeDefManager *nodedef) { env->addActiveBlockModifier(new GrowGrassABM()); env->addActiveBlockModifier(new RemoveGrassABM()); env->addActiveBlockModifier(new MakeTreesFromSaplingsABM(env, nodedef)); if (g_settings->getBool("liquid_finite")) env->addActiveBlockModifier(new LiquidFlowABM(env, nodedef)); }