Rename mcl_playerphysics to playerphysics
This commit is contained in:
parent
e0fe5b2c66
commit
b076bafaa7
12 changed files with 34 additions and 34 deletions
|
@ -1 +0,0 @@
|
|||
name=mcl_playerphysics
|
|
@ -3,7 +3,7 @@ mcl_core
|
|||
mcl_particles
|
||||
mcl_hunger
|
||||
mcl_death_messages
|
||||
mcl_playerphysics
|
||||
playerphysics
|
||||
mcl_playerinfo
|
||||
3d_armor?
|
||||
mcl_weather
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
mcl_playerinfo
|
||||
mcl_playerphysics
|
||||
playerphysics
|
||||
mcl_hunger
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
|
@ -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
|
1
mods/PLAYER/playerphysics/mod.conf
Normal file
1
mods/PLAYER/playerphysics/mod.conf
Normal file
|
@ -0,0 +1 @@
|
|||
name = playerphysics
|
Loading…
Add table
Add a link
Reference in a new issue