aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
Commit message (Expand)AuthorAge
* Breath cheat fix: server sideLoic Blot2017-01-01
* Dont compare short with bool (#4963)adrido2016-12-28
* Fix warning reported by clang (possible bug in Settings lua api)sfan52016-12-21
* Mod security: Allow read-only access to all mod pathsShadowNinja2016-12-20
* Simple decorations: Fix range check for deco->deco_param2Auke Kok2016-12-08
* Simple deco: Allow setting param2 value on placementAuke Kok2016-12-07
* Allow restricting detached inventories to one playersfan52016-11-28
* Revert "Adding particle blend, glow and animation (#4705)"sfan52016-11-14
* Adding particle blend, glow and animation (#4705)Foghrye42016-11-15
* Fix crash when attached object no longer existsRogier2016-11-13
* Add minetest.get_server_uptime() function to Lua API (#4702)Brandon2016-11-02
* Add version APIShadowNinja2016-10-31
* Lua voxelmanip: Add optional buffer param for 'get param2 data'paramat2016-10-31
* Fix overloading problems mentioned by clangLoic Blot2016-10-30
* PlayerSAO/LocalPlayer refactor: (#4612)Ner'zhul2016-10-30
* Adding LuaError on attempt to assign vectors with values out of rangeFoghrye42016-10-25
* Emergeblocks: Fix occasional crashRogier2016-10-16
* Attached particle spawnersraymoo2016-10-13
* Move RemotePlayer code to its own cpp/headerLoic Blot2016-10-08
* RemotePlayer/LocalPlayer Player base class proper separation (code cleanup) (...Loic Blot2016-10-08
* More code cleanup (UNORDERED + RemotePlayer/LocalPlayer)Loic Blot2016-10-08
* Player/LocalPlayer/RemotePlayer inheritance cleanup (part 2 on X)Loic Blot2016-10-08
* Prevent attached models from disappearing during parent reload (#4128)Foghrye42016-10-08
* Player/LocalPlayer/RemotePlayer inheritance cleanup (part 1 on X)Loic Blot2016-10-08
* Use more unordered_maps to improve performance in c++11 buildsLoic Blot2016-10-06
* Replace various std::map with UNORDERED_MAP + various cleanupsLoic Blot2016-10-05
* Decorations: Generalise 'spawn by' to be used by all decoration typesparamat2016-09-14
* Return nil on empty get_area() (#4508)James Stevenson2016-09-10
* Add minetest.unregister_item and minetest.register_alias_forcepaly22016-09-08
* Script API: Make the craft recipe field 'method' consistentSmallJoker2016-08-18
* Fixes for compiling with a newer (system) jsoncpp (#4429)Rogier-52016-08-10
* Permit usage of std::unordered_map & std::unorderered_set on c++11 compilers ...Ner'zhul2016-08-10
* Fix l_request_insecure_environment not ignoring all whitespace (#4395)Dorian Wouters2016-08-04
* Adding minetest.clear_craftFoghrye42016-07-05
* Add MapSettingsManager and new mapgen setting script API functionskwolekr2016-07-03
* Mapgen: Refactor mapgen creation and managementkwolekr2016-07-03
* Player: New get_look, set_look APIraymoo2016-06-24
* Make node timers more efficientEkdohibs2016-06-11
* Biome API: Add per-biome riverbed material and depthparamat2016-06-05
* Change internal type for seeds to s32kwolekr2016-06-04
* Add minetest.check_password_entry callbackest312016-05-30
* Particles: Add option to remove particles on collisionAuke Kok2016-05-28
* Add base64 encoding and decoding to the lua api. (#3919)red-0012016-05-27
* Fix MgStoneType and BiomeType enum nameskwolekr2016-05-27
* Move biome calculation to BiomeGenkwolekr2016-05-27
* Pathfinder: Fix styleest312016-05-01
* Add option to not send pre v25 init packetest312016-03-15
* Much better API for auth.{cpp, h}est312016-03-15
* Add consistent monotonic day counter - get_day_count()Auke Kok2016-03-09
* Add AreaStore custom ID APIShadowNinja2016-03-07
s="hl str">"movement_liquid_fluidity_smooth") * BS; movement_liquid_sink = g_settings->getFloat("movement_liquid_sink") * BS; movement_gravity = g_settings->getFloat("movement_gravity") * BS; // copy defaults m_cloud_params.density = 0.4f; m_cloud_params.color_bright = video::SColor(229, 240, 240, 255); m_cloud_params.color_ambient = video::SColor(255, 0, 0, 0); m_cloud_params.height = 120.0f; m_cloud_params.thickness = 16.0f; m_cloud_params.speed = v2f(0.0f, -2.0f); } void RemotePlayer::serializeExtraAttributes(std::string &output) { assert(m_sao); Json::Value json_root; const PlayerAttributes &attrs = m_sao->getExtendedAttributes(); for (const auto &attr : attrs) { json_root[attr.first] = attr.second; } output = fastWriteJson(json_root); m_sao->setExtendedAttributeModified(false); } void RemotePlayer::deSerialize(std::istream &is, const std::string &playername, PlayerSAO *sao) { Settings args; if (!args.parseConfigLines(is, "PlayerArgsEnd")) { throw SerializationError("PlayerArgsEnd of player " + playername + " not found!"); } m_dirty = true; //args.getS32("version"); // Version field value not used const std::string &name = args.get("name"); strlcpy(m_name, name.c_str(), PLAYERNAME_SIZE); if (sao) { try { sao->setHPRaw(args.getS32("hp")); } catch(SettingNotFoundException &e) { sao->setHPRaw(PLAYER_MAX_HP_DEFAULT); } try { sao->setBasePosition(args.getV3F("position")); } catch (SettingNotFoundException &e) {} try { sao->setPitch(args.getFloat("pitch")); } catch (SettingNotFoundException &e) {} try { sao->setYaw(args.getFloat("yaw")); } catch (SettingNotFoundException &e) {} try { sao->setBreath(args.getS32("breath"), false); } catch (SettingNotFoundException &e) {} try { const std::string &extended_attributes = args.get("extended_attributes"); std::istringstream iss(extended_attributes); Json::CharReaderBuilder builder; builder.settings_["collectComments"] = false; std::string errs; Json::Value attr_root; Json::parseFromStream(builder, iss, &attr_root, &errs); const Json::Value::Members attr_list = attr_root.getMemberNames(); for (const auto &it : attr_list) { Json::Value attr_value = attr_root[it]; sao->setExtendedAttribute(it, attr_value.asString()); } } catch (SettingNotFoundException &e) {} } inventory.deSerialize(is); if (inventory.getList("craftpreview") == NULL) { // Convert players without craftpreview inventory.addList("craftpreview", 1); bool craftresult_is_preview = true; if(args.exists("craftresult_is_preview")) craftresult_is_preview = args.getBool("craftresult_is_preview"); if(craftresult_is_preview) { // Clear craftresult inventory.getList("craftresult")->changeItem(0, ItemStack()); } } } void RemotePlayer::serialize(std::ostream &os) { // Utilize a Settings object for storing values Settings args; args.setS32("version", 1); args.set("name", m_name); // This should not happen assert(m_sao); args.setS32("hp", m_sao->getHP()); args.setV3F("position", m_sao->getBasePosition()); args.setFloat("pitch", m_sao->getPitch()); args.setFloat("yaw", m_sao->getYaw()); args.setS32("breath", m_sao->getBreath()); std::string extended_attrs; serializeExtraAttributes(extended_attrs); args.set("extended_attributes", extended_attrs); args.writeLines(os); os<<"PlayerArgsEnd\n"; inventory.serialize(os); } const RemotePlayerChatResult RemotePlayer::canSendChatMessage() { // Rate limit messages u32 now = time(NULL); float time_passed = now - m_last_chat_message_sent; m_last_chat_message_sent = now; // If this feature is disabled if (m_setting_chat_message_limit_per_10sec <= 0.0) { return RPLAYER_CHATRESULT_OK; } m_chat_message_allowance += time_passed * (m_setting_chat_message_limit_per_10sec / 8.0f); if (m_chat_message_allowance > m_setting_chat_message_limit_per_10sec) { m_chat_message_allowance = m_setting_chat_message_limit_per_10sec; } if (m_chat_message_allowance < 1.0f) { infostream << "Player " << m_name << " chat limited due to excessive message amount." << std::endl; // Kick player if flooding is too intensive m_message_rate_overhead++; if (m_message_rate_overhead > RemotePlayer::m_setting_chat_message_limit_trigger_kick) { return RPLAYER_CHATRESULT_KICK; } return RPLAYER_CHATRESULT_FLOODING; } // Reinit message overhead if (m_message_rate_overhead > 0) { m_message_rate_overhead = 0; } m_chat_message_allowance -= 1.0f; return RPLAYER_CHATRESULT_OK; }