From ea8af36b470fa992db4cc6b68ae00fbe9721c896 Mon Sep 17 00:00:00 2001 From: ANAND Date: Wed, 13 May 2020 17:18:30 +0530 Subject: [PATCH] Fix inventory corruption when using automatic weapons --- shooter/api.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shooter/api.lua b/shooter/api.lua index 964c0bf..6e95692 100644 --- a/shooter/api.lua +++ b/shooter/api.lua @@ -421,7 +421,7 @@ local function fire_weapon(player, itemstack, spec, extended) return end minetest.after(interval, function(...) - if shooting[spec.user] then + if shooting[spec.user] and player:get_wield_index() == spec.wield_idx then local arg = {...} fire_weapon(arg[1], arg[2], arg[3], true) end @@ -443,6 +443,7 @@ shooter.fire_weapon = function(player, itemstack, spec) end spec.user = name spec.name = itemstack:get_name() + spec.wield_idx = player:get_wield_index() fire_weapon(player, itemstack, spec) return true end