From b076bafaa7419bd5445f4c560502272dd4c8b5d3 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 23 Oct 2018 18:51:19 +0200 Subject: [PATCH] Rename mcl_playerphysics to playerphysics --- mods/ITEMS/mcl_beds/depends.txt | 2 +- mods/ITEMS/mcl_beds/functions.lua | 8 ++++---- mods/ITEMS/mcl_bows/bow.lua | 8 ++++---- mods/ITEMS/mcl_bows/depends.txt | 2 +- mods/PLAYER/mcl_playerphysics/mod.conf | 1 - mods/PLAYER/mcl_playerplus/depends.txt | 2 +- mods/PLAYER/mcl_playerplus/init.lua | 6 +++--- mods/PLAYER/mcl_sprint/depends.txt | 2 +- mods/PLAYER/mcl_sprint/init.lua | 4 ++-- .../README.md | 16 ++++++++-------- .../init.lua | 16 ++++++++-------- mods/PLAYER/playerphysics/mod.conf | 1 + 12 files changed, 34 insertions(+), 34 deletions(-) delete mode 100644 mods/PLAYER/mcl_playerphysics/mod.conf rename mods/PLAYER/{mcl_playerphysics => playerphysics}/README.md (80%) rename mods/PLAYER/{mcl_playerphysics => playerphysics}/init.lua (58%) create mode 100644 mods/PLAYER/playerphysics/mod.conf diff --git a/mods/ITEMS/mcl_beds/depends.txt b/mods/ITEMS/mcl_beds/depends.txt index ad8c41c02..3285e5914 100644 --- a/mods/ITEMS/mcl_beds/depends.txt +++ b/mods/ITEMS/mcl_beds/depends.txt @@ -1,4 +1,4 @@ -mcl_playerphysics +playerphysics mcl_sounds? mcl_worlds? mcl_wool? diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index 702a1d0c2..480240eea 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -110,8 +110,8 @@ local function lay_down(player, pos, bed_pos, state, skip) player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0}) player:set_look_horizontal(math.random(1, 180) / 100) mcl_player.player_attached[name] = false - mcl_playerphysics.remove_physics_factor(player, "speed", "mcl_beds:sleeping") - mcl_playerphysics.remove_physics_factor(player, "jump", "mcl_beds:sleeping") + playerphysics.remove_physics_factor(player, "speed", "mcl_beds:sleeping") + playerphysics.remove_physics_factor(player, "jump", "mcl_beds:sleeping") player:set_attribute("mcl_beds:sleeping", "false") hud_flags.wielditem = true mcl_player.player_set_animation(player, "stand" , 30) @@ -129,8 +129,8 @@ local function lay_down(player, pos, bed_pos, state, skip) local dir = minetest.facedir_to_dir(param2) local p = {x = bed_pos.x + dir.x / 2, y = bed_pos.y, z = bed_pos.z + dir.z / 2} player:set_attribute("mcl_beds:sleeping", "true") - mcl_playerphysics.add_physics_factor(player, "speed", "mcl_beds:sleeping", 0) - mcl_playerphysics.add_physics_factor(player, "jump", "mcl_beds:sleeping", 0) + playerphysics.add_physics_factor(player, "speed", "mcl_beds:sleeping", 0) + playerphysics.add_physics_factor(player, "jump", "mcl_beds:sleeping", 0) player:setpos(p) mcl_player.player_attached[name] = true hud_flags.wielditem = false diff --git a/mods/ITEMS/mcl_bows/bow.lua b/mods/ITEMS/mcl_bows/bow.lua index 7e7d27e3e..857ccda37 100644 --- a/mods/ITEMS/mcl_bows/bow.lua +++ b/mods/ITEMS/mcl_bows/bow.lua @@ -127,8 +127,8 @@ end local reset_bow_state = function(player, also_reset_bows) bow_load[player:get_player_name()] = nil bow_index[player:get_player_name()] = nil - if minetest.get_modpath("mcl_playerphysics") then - mcl_playerphysics.remove_physics_factor(player, "speed", "mcl_bows:use_bow") + if minetest.get_modpath("playerphysics") then + playerphysics.remove_physics_factor(player, "speed", "mcl_bows:use_bow") end if also_reset_bows then reset_bows(player) @@ -222,9 +222,9 @@ controls.register_on_hold(function(player, key, time) if bow_load[name] == nil and wielditem:get_name()=="mcl_bows:bow" and (minetest.settings:get_bool("creative_mode") or inv:contains_item("main", "mcl_bows:arrow")) then wielditem:set_name("mcl_bows:bow_0") player:set_wielded_item(wielditem) - if minetest.get_modpath("mcl_playerphysics") then + if minetest.get_modpath("playerphysics") then -- Slow player down when using bow - mcl_playerphysics.add_physics_factor(player, "speed", "mcl_bows:use_bow", PLAYER_USE_BOW_SPEED) + playerphysics.add_physics_factor(player, "speed", "mcl_bows:use_bow", PLAYER_USE_BOW_SPEED) end bow_load[name] = minetest.get_us_time() bow_index[name] = player:get_wield_index() diff --git a/mods/ITEMS/mcl_bows/depends.txt b/mods/ITEMS/mcl_bows/depends.txt index 228a1357b..736cd117a 100644 --- a/mods/ITEMS/mcl_bows/depends.txt +++ b/mods/ITEMS/mcl_bows/depends.txt @@ -4,7 +4,7 @@ mcl_achievements? mcl_hunger? mcl_core? mcl_mobitems? -mcl_playerphysics? +playerphysics? doc? doc_identifier? mesecons_button? diff --git a/mods/PLAYER/mcl_playerphysics/mod.conf b/mods/PLAYER/mcl_playerphysics/mod.conf deleted file mode 100644 index ff2bed375..000000000 --- a/mods/PLAYER/mcl_playerphysics/mod.conf +++ /dev/null @@ -1 +0,0 @@ -name=mcl_playerphysics diff --git a/mods/PLAYER/mcl_playerplus/depends.txt b/mods/PLAYER/mcl_playerplus/depends.txt index 9eb53eaf0..3e89821cc 100644 --- a/mods/PLAYER/mcl_playerplus/depends.txt +++ b/mods/PLAYER/mcl_playerplus/depends.txt @@ -3,7 +3,7 @@ mcl_core mcl_particles mcl_hunger mcl_death_messages -mcl_playerphysics +playerphysics mcl_playerinfo 3d_armor? mcl_weather diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 4a454adba..1320028aa 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -96,13 +96,13 @@ minetest.register_globalstep(function(dtime) -- TODO: Also slow down mobs -- Slow down even more when soul sand is above certain block if node_stand_below == "mcl_core:ice" or node_stand_below == "mcl_core:packed_ice" or node_stand_below == "mcl_core:slimeblock" or node_stand_below == "mcl_core:water_source" then - mcl_playerphysics.add_physics_factor(player, "speed", "mcl_playerplus:surface", 0.1) + playerphysics.add_physics_factor(player, "speed", "mcl_playerplus:surface", 0.1) else - mcl_playerphysics.add_physics_factor(player, "speed", "mcl_playerplus:surface", 0.4) + playerphysics.add_physics_factor(player, "speed", "mcl_playerplus:surface", 0.4) end else -- Reset speed decrease - mcl_playerphysics.remove_physics_factor(player, "speed", "mcl_playerplus:surface") + playerphysics.remove_physics_factor(player, "speed", "mcl_playerplus:surface") end -- Is player suffocating inside node? (Only for solid full opaque cube type nodes diff --git a/mods/PLAYER/mcl_sprint/depends.txt b/mods/PLAYER/mcl_sprint/depends.txt index 3f814ad10..aa6711ef0 100644 --- a/mods/PLAYER/mcl_sprint/depends.txt +++ b/mods/PLAYER/mcl_sprint/depends.txt @@ -1,3 +1,3 @@ mcl_playerinfo -mcl_playerphysics +playerphysics mcl_hunger diff --git a/mods/PLAYER/mcl_sprint/init.lua b/mods/PLAYER/mcl_sprint/init.lua index c97ca801c..e1224bb72 100644 --- a/mods/PLAYER/mcl_sprint/init.lua +++ b/mods/PLAYER/mcl_sprint/init.lua @@ -45,9 +45,9 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player if players[playerName] then players[playerName]["sprinting"] = sprinting if sprinting == true then - mcl_playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED) + playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED) elseif sprinting == false then - mcl_playerphysics.remove_physics_factor(player, "speed", "mcl_sprint:sprint") + playerphysics.remove_physics_factor(player, "speed", "mcl_sprint:sprint") end return true end diff --git a/mods/PLAYER/mcl_playerphysics/README.md b/mods/PLAYER/playerphysics/README.md similarity index 80% rename from mods/PLAYER/mcl_playerphysics/README.md rename to mods/PLAYER/playerphysics/README.md index 909c6fbac..8356d3707 100644 --- a/mods/PLAYER/mcl_playerphysics/README.md +++ b/mods/PLAYER/playerphysics/README.md @@ -13,7 +13,7 @@ There is only one precondition to using this mod, but it is important: Mods *MUST NOT* call `set_physics_override` directly! Instead, to modify player physics, use this API. ## Functions -### `mcl_playerphysics.add_physics_factor(player, physic, id, value)` +### `playerphysics.add_physics_factor(player, physic, id, value)` Adds a factor for a player physic and updates the player physics immeiately. #### Parameters @@ -22,7 +22,7 @@ Adds a factor for a player physic and updates the player physics immeiately. * `id`: Unique identifier for this factor. Identifiers are stored on a per-player per-physics type basis * `value`: The factor to add to the list of products -### `mcl_playerphysics.remove_physics_factor(player, physic, id)` +### `playerphysics.remove_physics_factor(player, physic, id)` Removes the physics factor of the given ID and updates the player's physics. #### Parameters @@ -37,17 +37,17 @@ Here's what it could look like: Potions mod: ``` -mcl_playerphysics.add_physics_factor(player, "speed", "run_potion", 2) +playerphysics.add_physics_factor(player, "speed", "run_potion", 2) ``` Exhaustion mod: ``` -mcl_playerphysics.add_physics_factor(player, "jump", "exhausted", 0.75) +playerphysics.add_physics_factor(player, "jump", "exhausted", 0.75) ``` Electrocution mod: ``` -mcl_playerphysics.add_physics_factor(player, "jump", "shocked", 0.9) +playerphysics.add_physics_factor(player, "jump", "shocked", 0.9) ``` When the 3 mods have done their change, the real player speed is simply the product of all factors, that is: @@ -62,7 +62,7 @@ Let's take the example above. Now if the Electrocution mod is done with shocking the player, it just needs to call: ``` -mcl_playerphysics.remove_physics_factor(player, "jump", "shocked") +playerphysics.remove_physics_factor(player, "jump", "shocked") ``` The effect is now gone, so the new player speed will be: @@ -73,8 +73,8 @@ The effect is now gone, so the new player speed will be: To simulate sleeping by preventing all player movement, this can be done with this easy trick: ``` -mcl_playerphysics.add_physics_factor(player, "speed", "sleeping", 0) -mcl_playerphysics.add_physics_factor(player, "jump", "sleeping", 0) +playerphysics.add_physics_factor(player, "speed", "sleeping", 0) +playerphysics.add_physics_factor(player, "jump", "sleeping", 0) ``` This works regardless of the other factors because mathematics tell us that the factor 0 forces the product to be 0. diff --git a/mods/PLAYER/mcl_playerphysics/init.lua b/mods/PLAYER/playerphysics/init.lua similarity index 58% rename from mods/PLAYER/mcl_playerphysics/init.lua rename to mods/PLAYER/playerphysics/init.lua index b7b7d4512..0b9420b18 100644 --- a/mods/PLAYER/mcl_playerphysics/init.lua +++ b/mods/PLAYER/playerphysics/init.lua @@ -1,7 +1,7 @@ -mcl_playerphysics = {} +playerphysics = {} local function calculate_physic_product(player, physic) - local a = minetest.deserialize(player:get_attribute("mcl_playerphysics:physics")) + local a = minetest.deserialize(player:get_attribute("playerphysics:physics")) local product = 1 if a == nil or a[physic] == nil then return product @@ -15,8 +15,8 @@ local function calculate_physic_product(player, physic) return product end -function mcl_playerphysics.add_physics_factor(player, physic, id, value) - local a = minetest.deserialize(player:get_attribute("mcl_playerphysics:physics")) +function playerphysics.add_physics_factor(player, physic, id, value) + local a = minetest.deserialize(player:get_attribute("playerphysics:physics")) if a == nil then a = { [physic] = { [id] = value } } elseif a[physic] == nil then @@ -24,20 +24,20 @@ function mcl_playerphysics.add_physics_factor(player, physic, id, value) else a[physic][id] = value end - player:set_attribute("mcl_playerphysics:physics", minetest.serialize(a)) + player:set_attribute("playerphysics:physics", minetest.serialize(a)) local raw_value = calculate_physic_product(player, physic) player:set_physics_override({[physic] = raw_value}) end -function mcl_playerphysics.remove_physics_factor(player, physic, id) - local a = minetest.deserialize(player:get_attribute("mcl_playerphysics:physics")) +function playerphysics.remove_physics_factor(player, physic, id) + local a = minetest.deserialize(player:get_attribute("playerphysics:physics")) if a == nil or a[physic] == nil then -- Nothing to remove return else a[physic][id] = nil end - player:set_attribute("mcl_playerphysics:physics", minetest.serialize(a)) + player:set_attribute("playerphysics:physics", minetest.serialize(a)) local raw_value = calculate_physic_product(player, physic) player:set_physics_override({[physic] = raw_value}) end diff --git a/mods/PLAYER/playerphysics/mod.conf b/mods/PLAYER/playerphysics/mod.conf new file mode 100644 index 000000000..da01bf07e --- /dev/null +++ b/mods/PLAYER/playerphysics/mod.conf @@ -0,0 +1 @@ +name = playerphysics