added safe_areas setting

This commit is contained in:
Zemtzov7 2022-08-28 02:03:38 +05:00 committed by GitHub
parent 70da830923
commit 075558ff1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,7 @@
local default_radius = tonumber(core.settings:get("rocket_launcher_radius")) or 3 local default_radius = tonumber(core.settings:get("rocket_launcher_radius")) or 3
local ballistic = core.settings:get("rocket_launcher_ballistic") or true local ballistic = core.settings:get_bool("rocket_launcher_ballistic", true)
local safe_areas = core.settings:get_bool("rocket_launcher_safe_areas", true)
local reloading = {} local reloading = {}
local function reload(name) local function reload(name)
if not reloading[name] then if not reloading[name] then
@ -10,6 +12,14 @@ local function reload(name)
end end
end end
local function can_boom(pos)
if safe_areas == false then
return true
else
return not core.is_protected(pos,"")
end
end
core.register_chatcommand("rocket-radius", { core.register_chatcommand("rocket-radius", {
description = "Set rocket explosion radius for wielded rauncher", description = "Set rocket explosion radius for wielded rauncher",
params = "<number>", params = "<number>",
@ -71,7 +81,7 @@ core.register_tool("rocket_launcher:launcher", {
obj:set_yaw(yaw) obj:set_yaw(yaw)
end end
end end
core.sound_play('fire_extinguish_flame',{to_player = name, gain=0.5}) core.sound_play('fire_extinguish_flame',{to_player = name, gain = 0.5})
return itemstack return itemstack
end end
end}) end})
@ -128,7 +138,7 @@ rocket.on_step = function(self, dtime, moveresult)
local prop = obj:get_properties() local prop = obj:get_properties()
if not prop then goto nodes end if not prop then goto nodes end
if obj:is_player() or prop.collide_with_objects == true then if obj:is_player() or prop.collide_with_objects == true then
if not core.is_protected(pos,"") then if can_boom(pos) then
tnt.boom(pos,{radius=self["radius"]}) tnt.boom(pos,{radius=self["radius"]})
end end
self.object:remove() self.object:remove()
@ -137,7 +147,9 @@ rocket.on_step = function(self, dtime, moveresult)
end end
::nodes:: ::nodes::
if moveresult.collides then if moveresult.collides then
tnt.boom(pos,{radius=self["radius"]}) if can_boom(pos) then
tnt.boom(pos,{radius=self["radius"]})
end
self.object:remove() self.object:remove()
end end
end end