From 21c908792c19c30d32200713b7ecc9bf0b188eff Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Fri, 16 Nov 2018 08:05:42 +0100 Subject: [PATCH] only shoot in warzone --- cannon.lua | 1 + util.lua | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cannon.lua b/cannon.lua index 9310d39..560490a 100644 --- a/cannon.lua +++ b/cannon.lua @@ -1,4 +1,5 @@ + local register_spacecannon = function(def) local entity_texture = "energycube_" .. def.color .. ".png" diff --git a/util.lua b/util.lua index 0a9485a..2961acf 100644 --- a/util.lua +++ b/util.lua @@ -1,4 +1,4 @@ - +local has_warzone_mod = minetest.get_modpath("warzone") spacecannon.update_formspec = function(meta) meta:set_string("formspec", "size[8,2;]" .. @@ -6,6 +6,19 @@ spacecannon.update_formspec = function(meta) 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 + end + -- check fuel/power local meta = minetest.get_meta(pos) local owner = meta:get_string("owner")