Make automatic firing a config option
This commit is contained in:
parent
18e22a38fb
commit
8ef3b1d379
2 changed files with 25 additions and 13 deletions
|
@ -3,7 +3,8 @@ shooter = {
|
||||||
}
|
}
|
||||||
|
|
||||||
shooter.config = {
|
shooter.config = {
|
||||||
admin_weapons = true,
|
automatic_weapons = true,
|
||||||
|
admin_weapons = false,
|
||||||
enable_blasting = false,
|
enable_blasting = false,
|
||||||
enable_particle_fx = true,
|
enable_particle_fx = true,
|
||||||
enable_protection = false,
|
enable_protection = false,
|
||||||
|
@ -260,11 +261,13 @@ shooter.fire_weapon = function(player, itemstack, spec)
|
||||||
if shots[name] and time <= shots[name] then
|
if shots[name] and time <= shots[name] then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if config.admin_weapons and minetest.check_player_privs(name,
|
if config.automatic_weapons then
|
||||||
{server=true}) then
|
if config.admin_weapons and minetest.check_player_privs(name,
|
||||||
spec.automatic = true
|
{server=true}) then
|
||||||
|
spec.automatic = true
|
||||||
|
end
|
||||||
|
shooting[name] = true
|
||||||
end
|
end
|
||||||
shooting[name] = true
|
|
||||||
spec.user = name
|
spec.user = name
|
||||||
fire_weapon(player, itemstack, spec)
|
fire_weapon(player, itemstack, spec)
|
||||||
return true
|
return true
|
||||||
|
@ -357,11 +360,6 @@ shooter.blast = function(pos, radius, fleshy, distance, user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
shooter.set_shooting = function(name, is_shooting)
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
shooting[name] = is_shooting and true or nil
|
||||||
local name = player:get_player_name()
|
end
|
||||||
if name then
|
|
||||||
shooting[name] = player:get_player_control().LMB == true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
|
@ -54,3 +54,17 @@ minetest.register_entity("shooter:turret_entity", {
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Automatic Firing
|
||||||
|
|
||||||
|
if shooter.config.automatic_weapons == true then
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if name then
|
||||||
|
shooter.set_shooting(name,
|
||||||
|
player:get_player_control().LMB == true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue