guns4d-cd2025/init.lua
2023-06-11 23:34:28 -07:00

51 lines
1.4 KiB
Lua

local Vec = vector
Guns4d = {
players = {}
}
local path = minetest.get_modpath("guns4d")
dofile(path.."/misc_helpers.lua")
dofile(path.."/visual_effects.lua")
dofile(path.."/gun_api.lua")
dofile(path.."/block_values.lua")
path = path .. "/classes"
dofile(path.."/Instantiatable_class.lua")
dofile(path.."/Bullet_ray.lua")
dofile(path.."/Control_handler.lua")
dofile(path.."/Gun.lua")
dofile(path.."/Player_model_handler.lua")
dofile(path.."/Player_handler.lua")
--load after
path = minetest.get_modpath("guns4d")
local player_handler = Guns4d.player_handler
local gun = Guns4d.gun
minetest.register_on_joinplayer(function(player)
local pname = player:get_player_name()
Guns4d.players[pname] = {
handler = player_handler:new({player=player})
}
player:set_fov(80)
end)
minetest.register_on_leaveplayer(function(player)
local pname = player:get_player_name()
Guns4d.players[pname].handler:prepare_deletion()
Guns4d.players[pname] = nil
end)
TICK = 0
minetest.register_globalstep(function(dt)
TICK = TICK + 1
if TICK > 100000 then TICK = 0 end
for player, obj in pairs(Guns4d.players) do
if not obj.handler then
--spawn the player handler. The player handler handles the gun(s),
--the player's model, and controls
obj.handler = player_handler:new({player=player})
end
obj.handler:update(dt)
end
end)