Reduce dependencies of technic_chests
authorZefram <zefram@fysh.org>
Sat, 26 Jul 2014 18:33:48 +0000 (19:33 +0100)
committerZefram <zefram@fysh.org>
Sat, 26 Jul 2014 18:45:31 +0000 (19:45 +0100)
technic_chests was depending on the technic mod, for the top-level
"technic" table and the technic.swap_node function.  Resolve that by
sharing the top-level table and inlining the one use of the function.
It was also depending on technic_worldgen, for the definitions of
cast iron and wrought iron.  Make the use of cast iron conditional on
technic_worldgen, falling back to default "steel".  Change the use of
wrought iron to directly use default "steel", to which it is aliased
anyway.

technic_chests/copper_chest.lua
technic_chests/depends.txt
technic_chests/gold_chest.lua
technic_chests/init.lua
technic_chests/iron_chest.lua
technic_chests/mithril_chest.lua
technic_chests/register.lua
technic_chests/silver_chest.lua

index 2d58379b1f80065a026f8de65b4a3cd73b556efe..d40284b4f86faee111063b1a6e22276b69925708 100644 (file)
@@ -19,7 +19,7 @@ minetest.register_craft({
 minetest.register_craft({
        output = 'technic:copper_locked_chest 1',
        recipe = {
-               {'technic:wrought_iron_ingot'},
+               {'default:steel_ingot'},
                {'technic:copper_chest'},
        }
 })
index 2e151fa8ef6b710893c53786219b37bc67816551..4d04e9ddd1a360dacf0fbd2ecc18610b973b9e76 100644 (file)
@@ -1,6 +1,3 @@
 default
-technic
-technic_worldgen
 pipeworks
 intllib?
-
index 386d1c7486d7f50954b12d481bb039427711428e..161d8fefc359c55af47f3d200cb1c71cb8ed6c3e 100644 (file)
@@ -20,7 +20,7 @@ minetest.register_craft({
 minetest.register_craft({
        output = 'technic:gold_locked_chest',
        recipe = {
-               {'technic:wrought_iron_ingot'},
+               {'default:steel_ingot'},
                {'technic:gold_chest'},
        }
 })
index 99af8ad525fcf395d9e062ae5fc3a0e06de90617..5fa96ff7b8c2e23a81d24ae0f821c5311c54f46f 100644 (file)
@@ -4,6 +4,7 @@
 
 modpath = minetest.get_modpath("technic_chests")
 
+technic = technic or {}
 technic.chests = {}
 
 dofile(modpath.."/common.lua")
index aa025338e8266a6d6bff85dd17dbb11414397318..90434bb042bb7a4ea1d5d2815bf4dfa64a310e5a 100644 (file)
@@ -1,26 +1,32 @@
+local cast_iron_ingot
+if minetest.get_modpath("technic_worldgen") then
+       cast_iron_ingot = "technic:cast_iron_ingot"
+else
+       cast_iron_ingot = "default:steel_ingot"
+end
 
 minetest.register_craft({
        output = 'technic:iron_chest 1',
        recipe = {
-               {'technic:cast_iron_ingot','technic:cast_iron_ingot','technic:cast_iron_ingot'},
-               {'technic:cast_iron_ingot','default:chest','technic:cast_iron_ingot'},
-               {'technic:cast_iron_ingot','technic:cast_iron_ingot','technic:cast_iron_ingot'},
+               {cast_iron_ingot,cast_iron_ingot,cast_iron_ingot},
+               {cast_iron_ingot,'default:chest',cast_iron_ingot},
+               {cast_iron_ingot,cast_iron_ingot,cast_iron_ingot},
        }
 })
 
 minetest.register_craft({
        output = 'technic:iron_locked_chest 1',
        recipe = {
-               {'technic:cast_iron_ingot','technic:cast_iron_ingot','technic:cast_iron_ingot'},
-               {'technic:cast_iron_ingot','default:chest_locked','technic:cast_iron_ingot'},
-               {'technic:cast_iron_ingot','technic:cast_iron_ingot','technic:cast_iron_ingot'},
+               {cast_iron_ingot,cast_iron_ingot,cast_iron_ingot},
+               {cast_iron_ingot,'default:chest_locked',cast_iron_ingot},
+               {cast_iron_ingot,cast_iron_ingot,cast_iron_ingot},
        }
 })
 
 minetest.register_craft({
        output = 'technic:iron_locked_chest 1',
        recipe = {
-               {'technic:wrought_iron_ingot'},
+               {'default:steel_ingot'},
                {'technic:iron_chest'},
        }
 })
index 69e7f17227eaa44cbe6ec6caaaf38c1d773f3ae3..bd2b981a67efd101bedef9860553bdf12d0181ad 100644 (file)
@@ -19,7 +19,7 @@ minetest.register_craft({
 minetest.register_craft({
        output = 'technic:mithril_locked_chest 1',
        recipe = {
-               {'technic:wrought_iron_ingot'},
+               {'default:steel_ingot'},
                {'technic:mithril_chest'},
        }
 })
index 17b1a0e54486349e5f0c9af28ccf3cdfe687e346..0344c2cd3f5718d47df1d91fb5edffa636a90985 100644 (file)
@@ -49,7 +49,9 @@ end
 local function check_color_buttons(pos, meta, chest_name, fields)
        for i = 1, 16 do
                if fields["color_button"..i] then
-                       technic.swap_node(pos, chest_name..colorid_to_postfix(i))
+                       local node = minetest.get_node(pos)
+                       node.name = chest_name..colorid_to_postfix(i)
+                       minetest.swap_node(pos, node)
                        meta:set_string("color", i)
                        return
                end
index 0370488961d1f16c47371f95049093dd530df36e..505156a8936c40b1b3858d2a225730e568ce3910 100644 (file)
@@ -19,7 +19,7 @@ minetest.register_craft({
 minetest.register_craft({
        output = 'technic:silver_locked_chest',
        recipe = {
-               {'technic:wrought_iron_ingot'},
+               {'default:steel_ingot'},
                {'technic:silver_chest'},
        }
 })