mirror of
https://github.com/pandorabox-io/spacecannon.git
synced 2025-01-02 02:57:29 +01:00
can_shoot/destroy hooks
This commit is contained in:
parent
a4771ba1b5
commit
655d4bb191
25
util.lua
25
util.lua
@ -1,21 +1,21 @@
|
|||||||
local has_warzone_mod = minetest.get_modpath("warzone")
|
|
||||||
|
|
||||||
spacecannon.update_formspec = function(meta)
|
spacecannon.update_formspec = function(meta)
|
||||||
meta:set_string("formspec", "size[8,2;]" ..
|
meta:set_string("formspec", "size[8,2;]" ..
|
||||||
"button_exit[0,1;8,1;fire;Fire]")
|
"button_exit[0,1;8,1;fire;Fire]")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
spacecannon.can_shoot = function(pos)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
spacecannon.can_destroy = function(pos)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
spacecannon.fire = function(pos, color, speed, range)
|
spacecannon.fire = function(pos, color, speed, range)
|
||||||
|
|
||||||
if has_warzone_mod then
|
if not spacecannon.can_shoot(pos) then
|
||||||
-- check warzone height
|
return
|
||||||
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
|
end
|
||||||
|
|
||||||
-- check fuel/power
|
-- check fuel/power
|
||||||
@ -46,6 +46,11 @@ end
|
|||||||
-- destroy stuff in range
|
-- destroy stuff in range
|
||||||
-- TODO: resilient material list
|
-- TODO: resilient material list
|
||||||
spacecannon.destroy = function(pos,range)
|
spacecannon.destroy = function(pos,range)
|
||||||
|
|
||||||
|
if not spacecannon.can_destroy(pos) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
for x=-range,range do
|
for x=-range,range do
|
||||||
for y=-range,range do
|
for y=-range,range do
|
||||||
for z=-range,range do
|
for z=-range,range do
|
||||||
|
Loading…
Reference in New Issue
Block a user