mirror of
https://github.com/a-bad-dev/simple-shooter-game.git
synced 2026-06-09 04:16:30 +00:00
Add the game
This commit is contained in:
parent
25eb4d0283
commit
38caa29558
863 changed files with 36331 additions and 0 deletions
42
mods/ctf_guns/rawf/init.lua
Normal file
42
mods/ctf_guns/rawf/init.lua
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
local api = {}
|
||||
local MODNAME = minetest.get_current_modname()
|
||||
rawset(_G, MODNAME, api)
|
||||
|
||||
local files = {
|
||||
"bullet.lua",
|
||||
"ammo.lua"
|
||||
}
|
||||
|
||||
for _, file in ipairs(files) do
|
||||
dofile(minetest.get_modpath(MODNAME).."/"..file)
|
||||
end
|
||||
|
||||
local checking = {}
|
||||
-- Returns false if the automatic timer is currently running, returns true otherwise
|
||||
function api.enable_automatic(fire_interval, itemstack, user)
|
||||
local pname = user:get_player_name()
|
||||
|
||||
if checking[pname] then return false end
|
||||
|
||||
checking[pname] = minetest.after(fire_interval, function()
|
||||
checking[pname] = nil
|
||||
|
||||
if user and user:get_player_control().LMB then
|
||||
local wielded = user:get_wielded_item()
|
||||
|
||||
if wielded:get_name() == itemstack:get_name() then
|
||||
user:set_wielded_item(itemstack:get_definition().on_use(wielded, user, {type = "nothing"}) or wielded)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local pname = player:get_player_name()
|
||||
|
||||
if checking[pname] then
|
||||
checking[pname]:cancel()
|
||||
end
|
||||
end)
|
||||
Loading…
Add table
Add a link
Reference in a new issue