mirror of
https://bitbucket.org/kingarthursteam/cannons.git
synced 2024-08-19 20:04:06 +02:00
some improvements
fixed twisted cannonball names moved alow inventory move and inventory put to global function
This commit is contained in:
parent
e8e468840b
commit
efa321a795
@ -283,5 +283,4 @@ local ball_steel={
|
|||||||
end,
|
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")
|
meta:set_string("infotext","Canon is ready")
|
||||||
end
|
end
|
||||||
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)
|
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()
|
||||||
|
64
items.lua
64
items.lua
@ -225,33 +225,8 @@ minetest.register_node("canons:canon", {
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_put = canons.allow_metadata_inventory_put,
|
||||||
local meta = minetest.get_meta(pos)
|
allow_metadata_inventory_move = canons.allow_metadata_inventory_move,
|
||||||
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,
|
|
||||||
on_metadata_inventory_put = canons.inventory_modified,
|
on_metadata_inventory_put = canons.inventory_modified,
|
||||||
|
|
||||||
on_metadata_inventory_take = canons.inventory_modified,
|
on_metadata_inventory_take = canons.inventory_modified,
|
||||||
@ -262,7 +237,7 @@ minetest.register_node("canons:canon", {
|
|||||||
|
|
||||||
-- bronze cannon --
|
-- bronze cannon --
|
||||||
minetest.register_node("canons:bronze_canon", {
|
minetest.register_node("canons:bronze_canon", {
|
||||||
description = "Cannon",
|
description = "Cannon (bronze)",
|
||||||
stack_max = 1,
|
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"},
|
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",
|
drawtype = "nodebox",
|
||||||
@ -309,33 +284,10 @@ minetest.register_node("canons:bronze_canon", {
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_put = canons.allow_metadata_inventory_put,
|
||||||
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 = canons.allow_metadata_inventory_move,
|
||||||
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,
|
|
||||||
on_metadata_inventory_put = canons.inventory_modified,
|
on_metadata_inventory_put = canons.inventory_modified,
|
||||||
|
|
||||||
on_metadata_inventory_take = 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", {
|
minetest.register_node("canons:canon_ball_wood", {
|
||||||
description = "Cannon Ball Stone",
|
description = "Cannon Ball Wood",
|
||||||
stack_max = 99,
|
stack_max = 99,
|
||||||
tiles = {"default_wood.png"},
|
tiles = {"default_wood.png"},
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
@ -429,7 +381,7 @@ minetest.register_node("canons:canon_ball_stone", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("canons:canon_ball_steel", {
|
minetest.register_node("canons:canon_ball_steel", {
|
||||||
description = "Cannon Ball Wood",
|
description = "Cannon Ball Steel",
|
||||||
stack_max = 99,
|
stack_max = 99,
|
||||||
tiles = {"cannon_cannon_top.png"},
|
tiles = {"cannon_cannon_top.png"},
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
|
Loading…
Reference in New Issue
Block a user