added check for pipeworks' fake players
This commit is contained in:
parent
4b5de2831c
commit
ceca6bebff
@ -48,7 +48,7 @@ A global function is available for mods to change player stamina levels:
|
||||
stamina.change(player, change)
|
||||
|
||||
This mod has added support for POVA and player_monoids for overrides to play
|
||||
nicely.
|
||||
nicely, it also has some pipeworks checks for fake players.
|
||||
|
||||
|
||||
License:
|
||||
|
8
init.lua
8
init.lua
@ -29,6 +29,8 @@ SPRINT_DRAIN = 0.35 -- how fast to drain satation while sprinting (0-1)
|
||||
|
||||
local function get_int_attribute(player, key)
|
||||
|
||||
if not player.get_attribute then return nil end -- pipeworks fake player check
|
||||
|
||||
local level = player:get_attribute(key)
|
||||
|
||||
if level then
|
||||
@ -41,6 +43,8 @@ end
|
||||
|
||||
local function stamina_update_level(player, level)
|
||||
|
||||
if not player.get_attribute then return nil end -- pipeworks fake player check
|
||||
|
||||
local old = get_int_attribute(player, "stamina:level")
|
||||
|
||||
if level == old then -- To suppress HUD update
|
||||
@ -343,6 +347,10 @@ end
|
||||
-- override core.do_item_eat() so we can redirect hp_change to stamina
|
||||
core.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing)
|
||||
|
||||
if user.is_fake_player then
|
||||
return -- abort if called by fake player (eg. pipeworks-wielder)
|
||||
end
|
||||
|
||||
local old_itemstack = itemstack
|
||||
|
||||
itemstack = stamina.eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
|
||||
|
Loading…
x
Reference in New Issue
Block a user