mirror of
https://github.com/D00Med/scifi_nodes.git
synced 2024-12-22 08:00:18 +01:00
add recipe for scifi_nodes:crate
and refactor chest registration
This commit is contained in:
parent
5b9e18f278
commit
f9bfaf0988
112
chest.lua
112
chest.lua
@ -1,6 +1,5 @@
|
||||
|
||||
--chest code from default(Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>)
|
||||
|
||||
local chest_formspec =
|
||||
"size[8,9]" ..
|
||||
default.gui_bg ..
|
||||
@ -13,10 +12,7 @@ local chest_formspec =
|
||||
"listring[current_player;main]" ..
|
||||
default.get_hotbar_bg(0,4.85)
|
||||
|
||||
|
||||
|
||||
-- Helper functions
|
||||
|
||||
local function drop_chest_stuff()
|
||||
return function(pos, oldnode, oldmetadata, digger)
|
||||
local meta = minetest.get_meta(pos)
|
||||
@ -35,40 +31,57 @@ local function drop_chest_stuff()
|
||||
end
|
||||
end
|
||||
|
||||
--chest code Copyright (C) 2011-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
minetest.register_node("scifi_nodes:crate", {
|
||||
local function register_chest(name, custom_def)
|
||||
assert(custom_def.description)
|
||||
assert(custom_def.tiles)
|
||||
|
||||
local def = {
|
||||
paramtype2 = "facedir",
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = scifi_nodes.node_sound_wood_defaults(),
|
||||
after_dig_node = drop_chest_stuff(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", chest_formspec)
|
||||
meta:set_string("infotext", custom_def.description)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8 * 4)
|
||||
end,
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index,
|
||||
to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name() ..
|
||||
" moves stuff in chest at " .. minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name() ..
|
||||
" moves stuff to chest at " .. minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name() ..
|
||||
" takes stuff from chest at " .. minetest.pos_to_string(pos))
|
||||
end
|
||||
}
|
||||
|
||||
for k, v in pairs(custom_def) do
|
||||
def[k] = v
|
||||
end
|
||||
|
||||
minetest.register_node(name, def)
|
||||
end
|
||||
|
||||
|
||||
register_chest("scifi_nodes:crate", {
|
||||
description = "Crate",
|
||||
tiles = {"scifi_nodes_crate.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky = 1, oddly_breakable_by_hand = 2, fuel = 8},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = scifi_nodes.node_sound_wood_defaults(),
|
||||
|
||||
after_dig_node = drop_chest_stuff(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", chest_formspec)
|
||||
meta:set_string("infotext", "Crate")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8 * 4)
|
||||
end,
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index,
|
||||
to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name() ..
|
||||
" moves stuff in chest at " .. minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name() ..
|
||||
" moves stuff to chest at " .. minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name() ..
|
||||
" takes stuff from chest at " .. minetest.pos_to_string(pos))
|
||||
end,
|
||||
groups = {
|
||||
cracky = 1,
|
||||
oddly_breakable_by_hand = 2,
|
||||
fuel = 8
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("scifi_nodes:box", {
|
||||
register_chest("scifi_nodes:box", {
|
||||
description = "Storage box",
|
||||
tiles = {
|
||||
"scifi_nodes_box_top.png",
|
||||
@ -78,32 +91,7 @@ minetest.register_node("scifi_nodes:box", {
|
||||
"scifi_nodes_box.png",
|
||||
"scifi_nodes_box.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky = 1},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
sounds = scifi_nodes.node_sound_metal_defaults(),
|
||||
|
||||
after_dig_node = drop_chest_stuff(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", chest_formspec)
|
||||
meta:set_string("infotext", "Box")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8 * 4)
|
||||
end,
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index,
|
||||
to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name() ..
|
||||
" moves stuff in chest at " .. minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name() ..
|
||||
" moves stuff to chest at " .. minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name() ..
|
||||
" takes stuff from chest at " .. minetest.pos_to_string(pos))
|
||||
end,
|
||||
groups = {
|
||||
cracky = 1
|
||||
}
|
||||
})
|
||||
--end of chest code
|
@ -475,6 +475,15 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "scifi_nodes:crate",
|
||||
recipe = {
|
||||
{"scifi_nodes:grey", "scifi_nodes:grey", "scifi_nodes:grey"},
|
||||
{"scifi_nodes:grey", "", "scifi_nodes:grey"},
|
||||
{"scifi_nodes:grey", "scifi_nodes:grey", "scifi_nodes:grey"}
|
||||
}
|
||||
})
|
||||
|
||||
-- 6 blue metal from 6 plastic, 2 blue dye, 1 dented metal block
|
||||
minetest.register_craft({
|
||||
output = "scifi_nodes:bluemetal 6",
|
||||
|
Loading…
Reference in New Issue
Block a user