From 0bdc630241d276887d27c89251eee823a66ab9b3 Mon Sep 17 00:00:00 2001 From: olliy <55839810+olliy1or@users.noreply.github.com> Date: Tue, 20 Apr 2021 19:28:51 +0500 Subject: [PATCH] slow player down while holding loaded rocket --- shooter_rocket/init.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/shooter_rocket/init.lua b/shooter_rocket/init.lua index bda2aa3..c42c1a9 100644 --- a/shooter_rocket/init.lua +++ b/shooter_rocket/init.lua @@ -135,9 +135,26 @@ if shooter.config.enable_crafting == true then }) end +local timer = 0 +minetest.register_globalstep(function(dtime) + timer = timer + dtime + if timer >= 0.1 then + for _, player in ipairs(minetest.get_connected_players()) do + local name = player and player:get_player_name() + local wielditem = player:get_wielded_item() + if wielditem:get_name() == "shooter_rocket:rocket_gun_loaded" then + local wielditem = player:get_wielded_item() + player:set_physics_override({ + speed = 0.7 + }) + timer = 0 + end + end + end +end) + --Backwards compatibility minetest.register_alias("shooter:rocket", "shooter_rocket:rocket") minetest.register_alias("shooter:rocket_gun", "shooter_rocket:rocket_gun") minetest.register_alias("shooter:rocket_gun_loaded", "shooter_rocket:rocket_gun_loaded") -