some improvements

fixed twisted cannonball names
moved alow inventory move and inventory put to global function
This commit is contained in:
adrido 2013-11-12 22:57:22 +01:00
parent e8e468840b
commit efa321a795
3 changed files with 34 additions and 58 deletions

@ -283,5 +283,4 @@ local ball_steel={
end,
}
canons.register_muni("canons:canon_ball_steel",ball_steel)
canons.register_muni("canons:canon_ball_steel",ball_steel)

@ -40,7 +40,32 @@ function canons.inventory_modified(pos)
meta:set_string("infotext","Canon is ready")
end
end
canons.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
stack = stack:to_table()
if listname == "gunpowder" and stack.name == "canons:gunpowder" then
return stack.count
elseif listname == "muni" and canons.is_muni(stack.name) then
return stack.count
else return 0
end
end
canons.allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local stack = inv:get_stack(from_list, from_index)
stack = stack:to_table()
if to_list == "gunpowder" and stack.name == "canons:gunpowder" then
return count
elseif to_list == "muni" and canons.is_muni(stack.name) then
return count
else
return 0
end
end
function canons.fire(pos,node,puncher)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()

@ -225,33 +225,8 @@ minetest.register_node("canons:canon", {
return true
end
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
stack = stack:to_table()
if listname == "gunpowder" and stack.name == "canons:gunpowder" then
return stack.count
elseif listname == "muni" and canons.is_muni(stack.name) then
return stack.count
else return 0
end
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local stack = inv:get_stack(from_list, from_index)
stack = stack:to_table()
if to_list == "gunpowder" and stack.name == "canons:gunpowder" then
return count
elseif to_list == "muni" and canons.is_muni(stack.name) then
return count
else
return 0
end
end,
allow_metadata_inventory_put = canons.allow_metadata_inventory_put,
allow_metadata_inventory_move = canons.allow_metadata_inventory_move,
on_metadata_inventory_put = canons.inventory_modified,
on_metadata_inventory_take = canons.inventory_modified,
@ -262,7 +237,7 @@ minetest.register_node("canons:canon", {
-- bronze cannon --
minetest.register_node("canons:bronze_canon", {
description = "Cannon",
description = "Cannon (bronze)",
stack_max = 1,
tiles = {"cannon_bronze_cannon_top.png","cannon_bronze_cannon_top.png","cannon_bronze_cannon_side.png","cannon_bronze_cannon_side.png","cannon_bronze_cannon_top.png^canons_canons_rim.png","cannon_bronze_cannon_side.png"},
drawtype = "nodebox",
@ -309,33 +284,10 @@ minetest.register_node("canons:bronze_canon", {
return true
end
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
stack = stack:to_table()
if listname == "gunpowder" and stack.name == "canons:gunpowder" then
return stack.count
elseif listname == "muni" and canons.is_muni(stack.name) then
return stack.count
else return 0
end
allow_metadata_inventory_put = canons.allow_metadata_inventory_put,
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local stack = inv:get_stack(from_list, from_index)
stack = stack:to_table()
if to_list == "gunpowder" and stack.name == "canons:gunpowder" then
return count
elseif to_list == "muni" and canons.is_muni(stack.name) then
return count
else
return 0
end
end,
allow_metadata_inventory_move = canons.allow_metadata_inventory_move,
on_metadata_inventory_put = canons.inventory_modified,
on_metadata_inventory_take = canons.inventory_modified,
@ -375,7 +327,7 @@ minetest.register_node("canons:canon_stand", {
},
})
minetest.register_node("canons:canon_ball_wood", {
description = "Cannon Ball Stone",
description = "Cannon Ball Wood",
stack_max = 99,
tiles = {"default_wood.png"},
drawtype = "nodebox",
@ -429,7 +381,7 @@ minetest.register_node("canons:canon_ball_stone", {
})
minetest.register_node("canons:canon_ball_steel", {
description = "Cannon Ball Wood",
description = "Cannon Ball Steel",
stack_max = 99,
tiles = {"cannon_cannon_top.png"},
drawtype = "nodebox",