Attempt to begin to implement chests and furnace in Lua (with problems)
authorPerttu Ahola <celeron55@gmail.com>
Fri, 1 Jun 2012 15:07:22 +0000 (18:07 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Sun, 3 Jun 2012 19:31:00 +0000 (22:31 +0300)
builtin/item.lua
doc/lua_api.txt
games/minimal/mods/default/init.lua

index 440236fbe0c7ffded791c6385480f2c91456303f..129a12cf87e034358973caa49a7a6dc30bd991e4 100644 (file)
@@ -237,15 +237,6 @@ function minetest.node_dig(pos, node, digger)
                return
        end
 
-       local meta = minetest.env:get_meta(pos)
-       if meta ~= nil and not meta:get_allow_removal() then
-               minetest.debug("dig prevented by metadata")
-               minetest.log("info", digger:get_player_name() .. " tried to dig "
-                       .. node.name .. ", but removal is disabled by metadata "
-                       .. minetest.pos_to_string(pos))
-               return
-       end
-
        minetest.log('action', digger:get_player_name() .. " digs "
                .. node.name .. " at " .. minetest.pos_to_string(pos))
 
index c984d44d32136a0837a271ede5adcb84d4d029b3..734171d07683fdc2c3c241926b0710618d5c9d61 100644 (file)
@@ -768,13 +768,6 @@ Deprecated:
 
 NodeMetaRef (this stuff is subject to change in a future version)
 methods:
-- get_type()
-- allows_text_input()
-- set_text(text) -- eg. set the text of a sign
-- get_text()
-- get_owner()
-- set_owner(string)
-Generic node metadata specific:
 - set_string(name, value)
 - get_string(name)
 - set_int(name, value)
index 952c114db9917d1d0bbea7dad2b7beeae5877239..516968f384e0b072a6cf055eead5f41f567c6398 100644 (file)
@@ -1119,10 +1119,18 @@ minetest.register_node("default:chest", {
        tile_images = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
                "default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
        paramtype2 = "facedir",
-       metadata_name = "chest",
        groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
        legacy_facedir_simple = true,
        sounds = default.node_sound_wood_defaults(),
+       on_construct = function(pos)
+               --local n = minetest.env:get_node(pos)
+               local meta = minetest.env:get_meta(pos)
+               meta:set_string("formspec",
+                               "invsize[8,9;]"..
+                               "list[current_name;0;0,0;8,4;]"..
+                               "list[current_player;main;0,5;8,4;]")
+               meta:set_string("infotext", "Chest");
+       end,
 })
 
 minetest.register_node("default:chest_locked", {
@@ -1130,10 +1138,18 @@ minetest.register_node("default:chest_locked", {
        tile_images = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
                "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"},
        paramtype2 = "facedir",
-       metadata_name = "locked_chest",
        groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
        legacy_facedir_simple = true,
        sounds = default.node_sound_wood_defaults(),
+       on_construct = function(pos)
+               --local n = minetest.env:get_node(pos)
+               local meta = minetest.env:get_meta(pos)
+               meta:set_string("formspec",
+                               "invsize[8,9;]"..
+                               "list[current_name;0;0,0;8,4;]"..
+                               "list[current_player;main;0,5;8,4;]")
+               meta:set_string("infotext", "Locked Chest");
+       end,
 })
 
 minetest.register_node("default:furnace", {
@@ -1141,10 +1157,19 @@ minetest.register_node("default:furnace", {
        tile_images = {"default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png",
                "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"},
        paramtype2 = "facedir",
-       metadata_name = "furnace",
        groups = {cracky=2},
        legacy_facedir_simple = true,
        sounds = default.node_sound_stone_defaults(),
+       on_construct = function(pos)
+               local meta = minetest.env:get_meta(pos)
+               meta:set_string("formspec",
+                       "invsize[8,9;]"..
+                       "list[current_name;fuel;2,3;1,1;]"..
+                       "list[current_name;src;2,1;1,1;]"..
+                       "list[current_name;dst;5,1;2,2;]"..
+                       "list[current_player;main;0,5;8,4;]")
+               meta:set_string("infotext", "Furnace");
+       end,
 })
 
 minetest.register_node("default:cobble", {