diff --git a/mods/default/functions.lua b/mods/default/functions.lua index f4d9216..342d8be 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -87,45 +87,24 @@ end -- Legacy -- -function default.spawn_falling_node(p, nodename) - spawn_falling_node(p, nodename) -end - --- Horrible crap to support old code --- Don't use this and never do what this does, it's completely wrong! --- (More specifically, the client and the C++ code doesn't get the group) -function default.register_falling_node(nodename, texture) - minetest.log("error", debug.traceback()) - minetest.log('error', "WARNING: default.register_falling_node is deprecated") - if minetest.registered_nodes[nodename] then - minetest.registered_nodes[nodename].groups.falling_node = 1 +function default.drop_node_inventory() + return function(pos, oldnode, oldmetadata, digger) + local meta = minetest.get_meta(pos) + meta:from_table(oldmetadata) + local inv = meta:get_inventory() + for i = 1, inv:get_size("main") do + local stack = inv:get_stack("main", i) + if not stack:is_empty() then + local p = { x = pos.x + math.random(0, 5)/5 - 0.5, + y = pos.y, + z = pos.z + math.random(0, 5)/5 - 0.5 + } + minetest.add_item(p, stack) + end + end end end --- --- Global callbacks --- - --- Global environment step function -function on_step(dtime) - -- print("on_step") -end -minetest.register_globalstep(on_step) - -function on_placenode(p, node) - --print("on_placenode") -end -minetest.register_on_placenode(on_placenode) - -function on_dignode(p, node) - --print("on_dignode") -end -minetest.register_on_dignode(on_dignode) - -function on_punchnode(p, node) -end -minetest.register_on_punchnode(on_punchnode) - -- -- Grow trees -- diff --git a/mods/ruins/init.lua b/mods/ruins/init.lua index 5319460..a85e063 100644 --- a/mods/ruins/init.lua +++ b/mods/ruins/init.lua @@ -9,23 +9,40 @@ local chest_stuff = { } -local frm = default.chest_formspec +minetest.register_node("ruins:chest", { + description = "Old Chest", + tiles = {"ruins_chest_top.png", "ruins_chest_top.png", "ruins_chest_side.png", + "ruins_chest_side.png", "ruins_chest_side.png", "ruins_chest_front.png"}, + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2}, + legacy_facedir_simple = true, + sounds = default.node_sound_wood_defaults({ + dug = {name = "ruins_chest_break", gain = 0.6}, + }), + drop = "default:stick 2", + on_construct = function(pos) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + inv:set_size("main", 8*4) + end, + after_dig_node = default.drop_node_inventory(), +}) + +--[[local frm = default.chest_formspec if not default.chest_formspec then frm = "size[8,9]".. "list[current_name;main;0,0;8,4;]".. "list[current_player;main;0,5;8,4;]" -end +end]] local function fill_chest(pos) - minetest.set_node(pos, {name="default:chest", metadata=""}) + minetest.set_node(pos, {name="ruins:chest", metadata=""}) minetest.after(2, function() local n = minetest.get_node(pos) local cnt = 0 if n ~= nil then - if n.name == "default:chest" then + if n.name == "ruins:chest" then local meta = minetest.get_meta(pos) - meta:set_string("formspec",frm) - meta:set_string("infotext", "Chest") local inv = meta:get_inventory() inv:set_size("main", 8*4) while cnt < 2 do diff --git a/mods/ruins/sounds/ruins_chest_break.1.ogg b/mods/ruins/sounds/ruins_chest_break.1.ogg new file mode 100644 index 0000000..0648b88 Binary files /dev/null and b/mods/ruins/sounds/ruins_chest_break.1.ogg differ diff --git a/mods/ruins/sounds/ruins_chest_break_alternative_sound.ogg b/mods/ruins/sounds/ruins_chest_break_alternative_sound.ogg new file mode 100644 index 0000000..4301a36 Binary files /dev/null and b/mods/ruins/sounds/ruins_chest_break_alternative_sound.ogg differ diff --git a/mods/ruins/textures/ruins_chest_front.png b/mods/ruins/textures/ruins_chest_front.png new file mode 100644 index 0000000..a71f3b2 Binary files /dev/null and b/mods/ruins/textures/ruins_chest_front.png differ diff --git a/mods/ruins/textures/ruins_chest_front.png.ne b/mods/ruins/textures/ruins_chest_front.png.ne new file mode 100644 index 0000000..ec3fc43 Binary files /dev/null and b/mods/ruins/textures/ruins_chest_front.png.ne differ diff --git a/mods/ruins/textures/ruins_chest_side.png b/mods/ruins/textures/ruins_chest_side.png new file mode 100644 index 0000000..ebb0289 Binary files /dev/null and b/mods/ruins/textures/ruins_chest_side.png differ diff --git a/mods/ruins/textures/ruins_chest_top.png b/mods/ruins/textures/ruins_chest_top.png new file mode 100644 index 0000000..a8fee49 Binary files /dev/null and b/mods/ruins/textures/ruins_chest_top.png differ