From 8b0900ac82d91be3ee6550a6574cbc369f9e15af Mon Sep 17 00:00:00 2001 From: olliy <55839810+olliy1or@users.noreply.github.com> Date: Tue, 20 Apr 2021 20:34:11 +0500 Subject: [PATCH] clean up --- shooter_rocket/init.lua | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/shooter_rocket/init.lua b/shooter_rocket/init.lua index d4f6297..57e9059 100644 --- a/shooter_rocket/init.lua +++ b/shooter_rocket/init.lua @@ -137,25 +137,24 @@ end local timer = 0 minetest.register_globalstep(function(dtime) - timer = timer + dtime - if timer >= 1 then + timer = timer + dtime + if timer >= 1 then timer = 0 - 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() + 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() physics.set(name, "shooter_rocket:physics", { speed = 0.7 }) - else + else physics.remove(name, "shooter_rocket:physics") end - end - end + end + end end) - --Backwards compatibility minetest.register_alias("shooter:rocket", "shooter_rocket:rocket") minetest.register_alias("shooter:rocket_gun", "shooter_rocket:rocket_gun")