From 655d4bb191852a456c4149af9f00e8384d2da76e Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Mon, 29 Jul 2019 11:10:24 +0200 Subject: [PATCH] can_shoot/destroy hooks --- util.lua | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/util.lua b/util.lua index e96db22..b8cff5e 100644 --- a/util.lua +++ b/util.lua @@ -1,21 +1,21 @@ -local has_warzone_mod = minetest.get_modpath("warzone") spacecannon.update_formspec = function(meta) meta:set_string("formspec", "size[8,2;]" .. "button_exit[0,1;8,1;fire;Fire]") end +spacecannon.can_shoot = function(pos) + return true +end + +spacecannon.can_destroy = function(pos) + return true +end + spacecannon.fire = function(pos, color, speed, range) - if has_warzone_mod then - -- check warzone height - local min_y = warzone.y_start - local max_y = warzone.y_start + warzone.y_height - - if pos.y < min_y or pos.y > max_y then - -- not in warzone - return - end + if not spacecannon.can_shoot(pos) then + return end -- check fuel/power @@ -46,6 +46,11 @@ end -- destroy stuff in range -- TODO: resilient material list spacecannon.destroy = function(pos,range) + + if not spacecannon.can_destroy(pos) then + return + end + for x=-range,range do for y=-range,range do for z=-range,range do