mirror of
https://github.com/lhofhansl/rangedweapons.git
synced 2024-12-11 16:43:22 +01:00
optional infinite ammo
This commit is contained in:
parent
2957951e9b
commit
0870636171
6
init.lua
6
init.lua
@ -71,6 +71,7 @@ if GunCaps ~= nil then
|
||||
gun_reload = GunCaps.gun_reload or 0.25
|
||||
end
|
||||
|
||||
local inf_ammo = minetest.settings:get_bool("infinite_ammo") or false
|
||||
local playerMeta = player:get_meta()
|
||||
local gunMeta = itemstack:get_meta()
|
||||
|
||||
@ -122,9 +123,11 @@ local ammoCount = gunMeta:get_int("RW_bullets")
|
||||
local ammoName = gunMeta:get_string("RW_ammo_name")
|
||||
local inv = player:get_inventory()
|
||||
|
||||
if inf_ammo then
|
||||
gunMeta:set_int("RW_bullets",clipSize)
|
||||
else
|
||||
inv:add_item("main",ammoName.." "..ammoCount)
|
||||
|
||||
|
||||
if inv:contains_item("main",reload_ammo:get_name().." "..clipSize) then
|
||||
inv:remove_item("main",reload_ammo:get_name().." "..clipSize)
|
||||
gunMeta:set_int("RW_bullets",clipSize)
|
||||
@ -132,6 +135,7 @@ else
|
||||
gunMeta:set_int("RW_bullets",reload_ammo:get_count())
|
||||
inv:remove_item("main",reload_ammo:get_name().." "..reload_ammo:get_count())
|
||||
end
|
||||
end
|
||||
|
||||
gunMeta:set_string("RW_ammo_name",reload_ammo:get_name())
|
||||
|
||||
|
2
settingtypes.txt
Normal file
2
settingtypes.txt
Normal file
@ -0,0 +1,2 @@
|
||||
# If true, a gun can always be reloaded (just need at least one matching bullet in the inventory)
|
||||
infinite_ammo (Inifinite Ammo) bool false
|
Loading…
Reference in New Issue
Block a user