Rename mcl_playerphysics to playerphysics

This commit is contained in:
Wuzzy 2018-10-23 18:51:19 +02:00
parent e0fe5b2c66
commit b076bafaa7
12 changed files with 34 additions and 34 deletions

View File

@ -1,4 +1,4 @@
mcl_playerphysics
playerphysics
mcl_sounds?
mcl_worlds?
mcl_wool?

View File

@ -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

View File

@ -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()

View File

@ -4,7 +4,7 @@ mcl_achievements?
mcl_hunger?
mcl_core?
mcl_mobitems?
mcl_playerphysics?
playerphysics?
doc?
doc_identifier?
mesecons_button?

View File

@ -1 +0,0 @@
name=mcl_playerphysics

View File

@ -3,7 +3,7 @@ mcl_core
mcl_particles
mcl_hunger
mcl_death_messages
mcl_playerphysics
playerphysics
mcl_playerinfo
3d_armor?
mcl_weather

View File

@ -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

View File

@ -1,3 +1,3 @@
mcl_playerinfo
mcl_playerphysics
playerphysics
mcl_hunger

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -0,0 +1 @@
name = playerphysics