Define default gunshot sound during gun registration itself

Every minor optimisation matters :)
This commit is contained in:
Anand S 2019-01-13 12:38:15 +05:30
parent 2b7de3cc9d
commit 1afd0ca267
No known key found for this signature in database
GPG Key ID: 3AD8A3C4A51AAB97

View File

@ -60,9 +60,7 @@ local function fire(stack, player)
local def = gunslinger.get_def(stack:get_name())
-- Play gunshot sound
local default_fire_sound = (def.style_of_fire ~= "splash")
and "gunslinger_fire1" or "gunslinger_fire2"
play_sound(def.fire_sound or default_fire_sound)
play_sound(def.fire_sound)
-- Take aim
local eye_offset = {x = 0, y = 1.625, z = 0} --player:get_eye_offset().offset_first
@ -267,6 +265,11 @@ function gunslinger.register_gun(name, def)
end
end
if not def.fire_sound then
def.fire_sound = (def.style_of_fire ~= "splash")
and "gunslinger_fire1" or "gunslinger_fire2"
end
if def.zoom and not def.scope then
error("gunslinger.register_gun: zoom requires scope to be defined!")
end