add player_monoids support

This commit is contained in:
Juraj Vajda 2022-10-05 21:26:43 -04:00
parent fe58ff5197
commit 62c39d1145
4 changed files with 12 additions and 5 deletions

View File

@ -11,5 +11,6 @@ read_globals = {
'armor', 'armor',
'playerphysics', 'playerphysics',
'hb', 'hb',
'mesecon' 'mesecon',
'player_monoids'
} }

View File

@ -6,6 +6,8 @@ x_bows = {
creative = minetest.settings:get_bool('creative_mode') or false, creative = minetest.settings:get_bool('creative_mode') or false,
mesecons = minetest.get_modpath('mesecons'), mesecons = minetest.get_modpath('mesecons'),
hbhunger = minetest.get_modpath('hbhunger'), hbhunger = minetest.get_modpath('hbhunger'),
playerphysics = minetest.get_modpath('playerphysics'),
player_monoids = minetest.get_modpath('player_monoids'),
registered_arrows = {}, registered_arrows = {},
registered_bows = {}, registered_bows = {},
player_bow_sneak = {}, player_bow_sneak = {},
@ -339,15 +341,19 @@ minetest.register_globalstep(function(dtime)
end end
if item == 'x_bows:bow_wood_charged' and not x_bows.player_bow_sneak[name].sneak then if item == 'x_bows:bow_wood_charged' and not x_bows.player_bow_sneak[name].sneak then
if minetest.get_modpath('playerphysics') then if x_bows.playerphysics then
playerphysics.add_physics_factor(player, 'speed', 'x_bows:bow_wood_charged', 0.25) playerphysics.add_physics_factor(player, 'speed', 'x_bows:bow_wood_charged', 0.25)
elseif x_bows.player_monoids then
player_monoids.speed:add_change(player, 0.25, 'x_bows:bow_wood_charged')
end end
x_bows.player_bow_sneak[name].sneak = true x_bows.player_bow_sneak[name].sneak = true
player:set_fov(0.9, true, 0.4) player:set_fov(0.9, true, 0.4)
elseif item ~= 'x_bows:bow_wood_charged' and x_bows.player_bow_sneak[name].sneak then elseif item ~= 'x_bows:bow_wood_charged' and x_bows.player_bow_sneak[name].sneak then
if minetest.get_modpath('playerphysics') then if x_bows.playerphysics then
playerphysics.remove_physics_factor(player, 'speed', 'x_bows:bow_wood_charged') playerphysics.remove_physics_factor(player, 'speed', 'x_bows:bow_wood_charged')
elseif x_bows.player_monoids then
player_monoids.speed:del_change(player, 'x_bows:bow_wood_charged')
end end
x_bows.player_bow_sneak[name].sneak = false x_bows.player_bow_sneak[name].sneak = false

View File

@ -1,5 +1,5 @@
name = x_bows name = x_bows
description = Adds bow and arrows to Minetest. description = Adds bow and arrows to Minetest.
depends = depends =
optional_depends = default, farming, 3d_armor, hbhunger, mesecons, playerphysics optional_depends = default, farming, 3d_armor, hbhunger, mesecons, playerphysics, player_monoids
min_minetest_version = 5.0 min_minetest_version = 5.0

View File

@ -32,7 +32,7 @@ minetest.register_node('x_bows:target', {
groups = {snappy=3, flammable=4, fall_damage_add_percent=-30}, groups = {snappy=3, flammable=4, fall_damage_add_percent=-30},
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
mesecons = {receptor = {state = 'off'}}, mesecons = {receptor = {state = 'off'}},
on_timer = function (pos, elapsed) on_timer = function (pos, elapsed) --luacheck:ignore
mesecon.receptor_off(pos) mesecon.receptor_off(pos)
return false return false
end, end,