fire(): Return before declaring def, if stack is nil
This commit is contained in:
parent
40fa0fd4ca
commit
b23f5fa2de
7
api.lua
7
api.lua
@ -52,12 +52,13 @@ local function hide_scope(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function fire(stack, player)
|
local function fire(stack, player)
|
||||||
local def = gunslinger.get_def(stack:get_name())
|
-- Workaround to prevent function from executing if stack is nil
|
||||||
|
if not stack then
|
||||||
if not def or not stack then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local def = gunslinger.get_def(stack:get_name())
|
||||||
|
|
||||||
-- Play gunshot sound
|
-- Play gunshot sound
|
||||||
play_sound(def.fire_sound or "gunslinger_fire1")
|
play_sound(def.fire_sound or "gunslinger_fire1")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user