mirror of
https://bitbucket.org/kingarthursteam/cannons.git
synced 2024-12-02 19:53:48 +01:00
moved formspec and nodebox to function.lua
This commit is contained in:
parent
0d30535653
commit
ea4b52fb6b
@ -40,6 +40,7 @@ function canons.inventory_modified(pos)
|
|||||||
meta:set_string("infotext","Canon is ready")
|
meta:set_string("infotext","Canon is ready")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
canons.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
canons.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -66,6 +67,53 @@ canons.allow_metadata_inventory_move = function(pos, from_list, from_index, to_l
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
canons.formspec =
|
||||||
|
"size[8,9]"..
|
||||||
|
"list[current_name;muni;2,1;1,1;] label[2,0.5;Muni:]"..
|
||||||
|
"list[current_name;gunpowder;2,3;1,1;] label[2,2.5;Gunpowder:]"..
|
||||||
|
"list[current_player;main;0,5;8,4;]"
|
||||||
|
canons.disabled_formspec =
|
||||||
|
"size[8,9]"..
|
||||||
|
"label[2,0.5;Canon is Disabled. Place it on a canonstand to activate it]"..
|
||||||
|
"list[current_player;main;0,5;8,4;]"
|
||||||
|
canons.on_construct = function(pos)
|
||||||
|
local node = minetest.get_node({x = pos.x ,y = pos.y-1, z = pos.z})
|
||||||
|
if node.name == "canons:canon_stand" then
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", canons.formspec)
|
||||||
|
meta:set_string("infotext", "Canon has no muni and no gunpowder")
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("gunpowder", 1)
|
||||||
|
inv:set_size("muni", 1)
|
||||||
|
else
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", canons.disabled_formspec)
|
||||||
|
meta:set_string("infotext", "Canon is out of Order")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
canons.nodebox = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.2, 0.2, -0.7, 0.2, -0.2, 0.9}, -- barrle --
|
||||||
|
{0.53, -0.1, 0.1, -0.53, 0.1, -0.1}, -- plinth --
|
||||||
|
|
||||||
|
-- side , top hight , depth , side , bottom, side,
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
canons.stand_nodebox = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, -- bottom --
|
||||||
|
{-0.5, -0.5, -0.5, -0.35, 1.0, 0.5}, -- side left --
|
||||||
|
{0.35, -0.5, -0.5, 0.5, 1.0, 0.5}, -- side right --
|
||||||
|
{0.35, -0.5, -0.2, 0.5, 1.2, 0.5}, -- side right --
|
||||||
|
{-0.5, -0.5, -0.2, -0.35, 1.2, 0.5}, -- side left --
|
||||||
|
|
||||||
|
-- side , top , side , side , bottom, side,
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
||||||
function canons.fire(pos,node,puncher)
|
function canons.fire(pos,node,puncher)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
85
items.lua
85
items.lua
@ -137,11 +137,7 @@ minetest.register_craft({
|
|||||||
--++++++++++++++++++++++++++++++++++++
|
--++++++++++++++++++++++++++++++++++++
|
||||||
--+ cannon stuff +
|
--+ cannon stuff +
|
||||||
--++++++++++++++++++++++++++++++++++++
|
--++++++++++++++++++++++++++++++++++++
|
||||||
canons.formspec =
|
|
||||||
"size[8,9]"..
|
|
||||||
"list[current_name;gunpowder;2,3;1,1;]"..
|
|
||||||
"list[current_name;muni;2,1;1,1;]"..
|
|
||||||
"list[current_player;main;0,5;8,4;]"
|
|
||||||
-- classic cannon --
|
-- classic cannon --
|
||||||
minetest.register_node("canons:canon", {
|
minetest.register_node("canons:canon", {
|
||||||
description = "Cannon",
|
description = "Cannon",
|
||||||
@ -153,33 +149,11 @@ minetest.register_node("canons:canon", {
|
|||||||
is_ground_content = true,
|
is_ground_content = true,
|
||||||
groups = {cracky=1},
|
groups = {cracky=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
node_box = {
|
node_box = canons.nodebox,
|
||||||
type = "fixed",
|
on_place = canons.on_place,
|
||||||
fixed = {
|
selection_box = canons.nodebox,
|
||||||
{-0.2, 0.2, -0.7, 0.2, -0.2, 0.9}, -- barrle --
|
|
||||||
{0.53, -0.1, 0.1, -0.53, 0.1, -0.1}, -- plinth --
|
|
||||||
|
|
||||||
-- side , top hight , depth , side , bottom, side,
|
|
||||||
|
|
||||||
},
|
|
||||||
},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.2, 0.2, -0.7, 0.2, -0.2, 0.9},
|
|
||||||
{0.53, -0.1, 0.1, -0.53, 0.1, -0.1},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
on_punch = canons.punched,
|
on_punch = canons.punched,
|
||||||
on_construct = function(pos)
|
on_construct = canons.on_construct,
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_string("formspec", canons.formspec)
|
|
||||||
meta:set_string("infotext", "Canon has no muni and no gunpowder")
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
inv:set_size("gunpowder", 1)
|
|
||||||
inv:set_size("muni", 1)
|
|
||||||
|
|
||||||
end,
|
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -214,33 +188,10 @@ minetest.register_node("canons:bronze_canon", {
|
|||||||
is_ground_content = true,
|
is_ground_content = true,
|
||||||
groups = {cracky=1},
|
groups = {cracky=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
node_box = {
|
node_box = canons.nodebox,
|
||||||
type = "fixed",
|
selection_box = canons.nodebox,
|
||||||
fixed = {
|
|
||||||
{-0.2, 0.2, -0.7, 0.2, -0.2, 0.9}, -- barrle --
|
|
||||||
{0.53, -0.1, 0.1, -0.53, 0.1, -0.1}, -- plinth --
|
|
||||||
|
|
||||||
-- side , top hight , depth , side , bottom, side,
|
|
||||||
|
|
||||||
},
|
|
||||||
},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.2, 0.2, -0.7, 0.2, -0.2, 0.9},
|
|
||||||
{0.53, -0.1, 0.1, -0.53, 0.1, -0.1},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
on_punch = canons.punched,
|
on_punch = canons.punched,
|
||||||
on_construct = function(pos)
|
on_construct = canons.on_construct,
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_string("formspec", canons.formspec)
|
|
||||||
meta:set_string("infotext", "Canon has no muni and no gunpowder")
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
inv:set_size("gunpowder", 1)
|
|
||||||
inv:set_size("muni", 1)
|
|
||||||
|
|
||||||
end,
|
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -274,25 +225,13 @@ minetest.register_node("canons:canon_stand", {
|
|||||||
is_ground_content = true,
|
is_ground_content = true,
|
||||||
groups = {cracky=2},
|
groups = {cracky=2},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
node_box = {
|
node_box = canons.stand_nodebox,
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, -- bottom --
|
|
||||||
{-0.5, -0.5, -0.5, -0.35, 1.0, 0.5}, -- side left --
|
|
||||||
{0.35, -0.5, -0.5, 0.5, 1.0, 0.5}, -- side right --
|
|
||||||
{0.35, -0.5, -0.2, 0.5, 1.2, 0.5}, -- side right --
|
|
||||||
{-0.5, -0.5, -0.2, -0.35, 1.2, 0.5}, -- side left --
|
|
||||||
|
|
||||||
-- side , top , side , side , bottom, side,
|
|
||||||
|
|
||||||
},
|
|
||||||
},
|
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
minetest.register_node("canons:canon_ball_wood", {
|
minetest.register_node("canons:canon_ball_wood", {
|
||||||
description = "Cannon Ball Wood",
|
description = "Cannon Ball Wood",
|
||||||
|
Loading…
Reference in New Issue
Block a user