]> git.lizzy.rs Git - xdecor.git/commitdiff
Rename workbench to worktable
authorkilbith <jeanpatrick.guerrero@gmail.com>
Sat, 13 Jun 2015 17:08:35 +0000 (19:08 +0200)
committerkilbith <jeanpatrick.guerrero@gmail.com>
Sat, 13 Jun 2015 17:08:35 +0000 (19:08 +0200)
crafts.lua
init.lua
textures/xdecor_workbench_front.png [deleted file]
textures/xdecor_workbench_sides.png [deleted file]
textures/xdecor_workbench_top.png [deleted file]
textures/xdecor_worktable_front.png [new file with mode: 0644]
textures/xdecor_worktable_sides.png [new file with mode: 0644]
textures/xdecor_worktable_top.png [new file with mode: 0644]
workbench.lua [deleted file]
worktable.lua [new file with mode: 0644]

index ce9c58ce78f7bae2b394bd3e2be3fc7c9831f82f..30ec843fdde3c94338667eb75562fa03b569999d 100644 (file)
@@ -119,7 +119,7 @@ minetest.register_craft({ output = "xdecor:tv", recipe = {
        {"default:steel_ingot", "default:glass", "default:steel_ingot"},
        {"default:steel_ingot", "default:copper_ingot", "default:steel_ingot"} } })
 
-minetest.register_craft({ output = "xdecor:workbench", recipe = {
+minetest.register_craft({ output = "xdecor:worktable", recipe = {
        {"group:wood", "group:wood", "group:wood"},
        {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
        {"group:wood", "group:wood", "group:wood"} } })
index 4c6eb5f5b6fca16ab14a9468f867bfc777d1f153..268cfd96cd609cb85bbff491872fa5bc512d856a 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -6,4 +6,4 @@ dofile(modpath.."/handlers/registration.lua")
 dofile(modpath.."/crafts.lua")
 dofile(modpath.."/itemframes.lua")
 dofile(modpath.."/nodes.lua")
-dofile(modpath.."/workbench.lua")
+dofile(modpath.."/worktable.lua")
diff --git a/textures/xdecor_workbench_front.png b/textures/xdecor_workbench_front.png
deleted file mode 100644 (file)
index a7b04df..0000000
Binary files a/textures/xdecor_workbench_front.png and /dev/null differ
diff --git a/textures/xdecor_workbench_sides.png b/textures/xdecor_workbench_sides.png
deleted file mode 100644 (file)
index 4367739..0000000
Binary files a/textures/xdecor_workbench_sides.png and /dev/null differ
diff --git a/textures/xdecor_workbench_top.png b/textures/xdecor_workbench_top.png
deleted file mode 100644 (file)
index 2e3a7d1..0000000
Binary files a/textures/xdecor_workbench_top.png and /dev/null differ
diff --git a/textures/xdecor_worktable_front.png b/textures/xdecor_worktable_front.png
new file mode 100644 (file)
index 0000000..a7b04df
Binary files /dev/null and b/textures/xdecor_worktable_front.png differ
diff --git a/textures/xdecor_worktable_sides.png b/textures/xdecor_worktable_sides.png
new file mode 100644 (file)
index 0000000..4367739
Binary files /dev/null and b/textures/xdecor_worktable_sides.png differ
diff --git a/textures/xdecor_worktable_top.png b/textures/xdecor_worktable_top.png
new file mode 100644 (file)
index 0000000..2e3a7d1
Binary files /dev/null and b/textures/xdecor_worktable_top.png differ
diff --git a/workbench.lua b/workbench.lua
deleted file mode 100644 (file)
index f66daa0..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-local material = {
-       "cloud", -- only used for the formspec display
-       "wood", "junglewood", "pinewood", "tree", "pinetree",
-       "stone", "sandstone", "desert_stone", "obsidian",
-       "stonebrick", "sandstonebrick", "desert_stonebrick", "obsidianbrick",
-       "copperblock", "bronzeblock", "goldblock", "steelblock", "diamondblock",
-       "meselamp", "glass", "obsidian_glass" }
-
-local def = {
-       {"nanoslab", "32", {-0.5, -0.5, -0.5, 0, -0.4375, 0}},
-       {"microslab_half", "16", {-0.5, -0.5, -0.5, 0.5, -0.4375, 0}},
-       {"microslab", "8", {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}},
-       {"panel", "4", {-0.5, -0.5, -0.5, 0.5, 0, 0}},
-       {"slab", "2", {-0.5, -0.5, -0.5, 0.5, 0, 0.5}},
-       {"outerstair", "2", {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, 0, 0, 0, 0.5, 0.5}}},
-       {"stair", "2", {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, 0, 0, 0.5, 0.5, 0.5}}},
-       {"innerstair", "2", {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, 0, 0, 0.5, 0.5, 0.5}, {-0.5, 0, -0.5, 0, 0.5, 0}}}
-}
-
-function xdecor.on_construct(pos)
-       local meta = minetest.get_meta(pos)
-       local nodespec = ""
-
-       for j=1, #def do
-               nodespec = nodespec..
-               "item_image_button["..(j-1)..",0.5;1,1;xdecor:"..def[j][1].."_cloud;"..def[j][1]..";]"
-       end
-       meta:set_string("formspec", "size[8,7;]"..fancy_gui..
-               "label[0,0;Cut your material into...]"..
-               nodespec..
-               "label[0,1.5;Input]"..
-               "list[current_name;input;0,2;1,1;]"..
-               "image[1,2;1,1;xdecor_saw.png]"..
-               "label[2,1.5;Output]"..
-               "list[current_name;output;2,2;1,1;]"..
-               "label[4.5,1.5;Damaged tool]"..
-               "list[current_name;src;5,2;1,1;]"..
-               "image[6,2;1,1;xdecor_hammer.png]"..
-               "label[6.8,1.5;Hammer]]"..
-               "list[current_name;fuel;7,2;1,1;]"..
-               "list[current_player;main;0,3.25;8,4;]")
-       meta:set_string("infotext", "Work Bench")
-       local inv = meta:get_inventory()
-       inv:set_size("output", 1)
-       inv:set_size("input", 1)
-       inv:set_size("src", 1)
-       inv:set_size("fuel", 1)
-end
-
-function xdecor.on_receive_fields(pos, formname, fields, sender)
-       local meta = minetest.get_meta(pos)
-       local inv = meta:get_inventory()
-       local inputstack = inv:get_stack("input", 1)
-       local outputstack = inv:get_stack("output", 1)
-       local shape = {}
-       local give = {}
-       local anz = 0
-
-       for _, m in ipairs(material) do
-       for _, n in ipairs(def) do
-               if (inputstack:get_name() == "default:"..m) and (outputstack:get_count() < 99) then
-                       if fields[n[1]] then
-                               anz = n[2]
-                               shape = "xdecor:"..n[1].."_"..m
-                               for i=0, anz-1 do
-                                       give[i+1] = inv:add_item("output", shape)
-                               end
-                               inputstack:take_item()
-                               inv:set_stack("input", 1, inputstack)
-                       end
-               end
-       end
-       end
-end
-
-function xdecor.can_dig(pos, player)
-       local meta = minetest.get_meta(pos)
-       local inv = meta:get_inventory()
-       if not inv:is_empty("input") or not inv:is_empty("output")
-               or not inv:is_empty("fuel") or not inv:is_empty("src") then
-                       return false end
-       return true
-end
-
-xdecor.register("workbench", {
-       description = "Work Bench", infotext = "Work Bench",
-       sounds = default.node_sound_wood_defaults(), groups = {snappy=3},
-       tiles = {"xdecor_workbench_top.png", "xdecor_workbench_top.png",
-               "xdecor_workbench_sides.png", "xdecor_workbench_sides.png",
-               "xdecor_workbench_front.png", "xdecor_workbench_front.png"},
-       on_construct = xdecor.on_construct,
-       on_receive_fields = xdecor.on_receive_fields,
-       can_dig = xdecor.can_dig })
-
-local function lightlvl(material)
-       if (material == "meselamp") then return 12 else return 0 end
-end
-
-local function stype(material)
-       if string.find(material, "glass") or string.find(material, "lamp") then
-               return default.node_sound_glass_defaults()
-       elseif string.find(material, "wood") or string.find(material, "tree") then
-               return default.node_sound_wood_defaults()
-       else
-               return default.node_sound_stone_defaults()
-       end
-end
-
-local function tnaming(material)
-       if string.find(material, "block") then
-               local newname = string.gsub(material, "(block)", "_%1")
-               return "default_"..newname..".png"
-       elseif string.find(material, "brick") then
-               local newname = string.gsub(material, "(brick)", "_%1")
-               return "default_"..newname..".png"
-       else return "default_"..material..".png" end
-end
-
-for _, m in ipairs(material) do
-       local light = lightlvl(m)
-       local sound = stype(m)
-       local tile = tnaming(m)
-
-       for _, n in ipairs(def) do
-       xdecor.register(n[1].."_"..m, {
-               description = n[1], light_source = light, sounds = sound,
-               tiles = {tile}, groups = {snappy=3, not_in_creative_inventory=1},
-               on_place = minetest.rotate_node, node_box = {type = "fixed", fixed = n[3]} })
-       end
-end
-
--- Repair Tool's code by Krock, modified by kilbith
-
-minetest.register_abm({
-       nodenames = {"xdecor:workbench"},
-       interval = 5, chance = 1,
-       action = function(pos, node, active_object_count, active_object_count_wider)
-               local meta = minetest.get_meta(pos)
-               local inv = meta:get_inventory()
-               local src = inv:get_stack("src", 1)
-               local wear = src:get_wear()
-               local repair = -1400
-
-               if (src:is_empty() or wear == 0 or wear == 65535) then return end
-               local fuel = inv:get_stack("fuel", 1)
-               if (fuel:is_empty() or fuel:get_name() ~= "xdecor:hammer") then return end
-
-               if (wear + repair < 0) then src:add_wear(repair + wear)
-               else src:add_wear(repair) end
-
-               inv:set_stack("src", 1, src)
-               inv:remove_item("fuel", "xdecor:hammer 1")
-       end
-})
diff --git a/worktable.lua b/worktable.lua
new file mode 100644 (file)
index 0000000..d244ef6
--- /dev/null
@@ -0,0 +1,154 @@
+local material = {
+       "cloud", -- only used for the formspec display
+       "wood", "junglewood", "pinewood", "tree", "pinetree",
+       "stone", "sandstone", "desert_stone", "obsidian",
+       "stonebrick", "sandstonebrick", "desert_stonebrick", "obsidianbrick",
+       "copperblock", "bronzeblock", "goldblock", "steelblock", "diamondblock",
+       "meselamp", "glass", "obsidian_glass" }
+
+local def = {
+       {"nanoslab", "32", {-0.5, -0.5, -0.5, 0, -0.4375, 0}},
+       {"microslab_half", "16", {-0.5, -0.5, -0.5, 0.5, -0.4375, 0}},
+       {"microslab", "8", {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}},
+       {"panel", "4", {-0.5, -0.5, -0.5, 0.5, 0, 0}},
+       {"slab", "2", {-0.5, -0.5, -0.5, 0.5, 0, 0.5}},
+       {"outerstair", "2", {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, 0, 0, 0, 0.5, 0.5}}},
+       {"stair", "2", {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, 0, 0, 0.5, 0.5, 0.5}}},
+       {"innerstair", "2", {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, 0, 0, 0.5, 0.5, 0.5}, {-0.5, 0, -0.5, 0, 0.5, 0}}}
+}
+
+function xdecor.on_construct(pos)
+       local meta = minetest.get_meta(pos)
+       local nodespec = ""
+
+       for j=1, #def do
+               nodespec = nodespec..
+               "item_image_button["..(j-1)..",0.5;1,1;xdecor:"..def[j][1].."_cloud;"..def[j][1]..";]"
+       end
+       meta:set_string("formspec", "size[8,7;]"..fancy_gui..
+               "label[0,0;Cut your material into...]"..
+               nodespec..
+               "label[0,1.5;Input]"..
+               "list[current_name;input;0,2;1,1;]"..
+               "image[1,2;1,1;xdecor_saw.png]"..
+               "label[2,1.5;Output]"..
+               "list[current_name;output;2,2;1,1;]"..
+               "label[4.5,1.5;Damaged tool]"..
+               "list[current_name;src;5,2;1,1;]"..
+               "image[6,2;1,1;xdecor_hammer.png]"..
+               "label[6.8,1.5;Hammer]]"..
+               "list[current_name;fuel;7,2;1,1;]"..
+               "list[current_player;main;0,3.25;8,4;]")
+       meta:set_string("infotext", "Work Bench")
+       local inv = meta:get_inventory()
+       inv:set_size("output", 1)
+       inv:set_size("input", 1)
+       inv:set_size("src", 1)
+       inv:set_size("fuel", 1)
+end
+
+function xdecor.on_receive_fields(pos, formname, fields, sender)
+       local meta = minetest.get_meta(pos)
+       local inv = meta:get_inventory()
+       local inputstack = inv:get_stack("input", 1)
+       local outputstack = inv:get_stack("output", 1)
+       local shape = {}
+       local give = {}
+       local anz = 0
+
+       for _, m in ipairs(material) do
+       for _, n in ipairs(def) do
+               if (inputstack:get_name() == "default:"..m) and (outputstack:get_count() < 99) then
+                       if fields[n[1]] then
+                               anz = n[2]
+                               shape = "xdecor:"..n[1].."_"..m
+                               for i=0, anz-1 do
+                                       give[i+1] = inv:add_item("output", shape)
+                               end
+                               inputstack:take_item()
+                               inv:set_stack("input", 1, inputstack)
+                       end
+               end
+       end
+       end
+end
+
+function xdecor.can_dig(pos, player)
+       local meta = minetest.get_meta(pos)
+       local inv = meta:get_inventory()
+       if not inv:is_empty("input") or not inv:is_empty("output")
+               or not inv:is_empty("fuel") or not inv:is_empty("src") then
+                       return false end
+       return true
+end
+
+xdecor.register("worktable", {
+       description = "Work Table", infotext = "Work Table",
+       sounds = default.node_sound_wood_defaults(), groups = {snappy=3},
+       tiles = {"xdecor_worktable_top.png", "xdecor_worktable_top.png",
+               "xdecor_worktable_sides.png", "xdecor_worktable_sides.png",
+               "xdecor_worktable_front.png", "xdecor_worktable_front.png"},
+       on_construct = xdecor.on_construct,
+       on_receive_fields = xdecor.on_receive_fields,
+       can_dig = xdecor.can_dig })
+
+local function lightlvl(material)
+       if (material == "meselamp") then return 12 else return 0 end
+end
+
+local function stype(material)
+       if string.find(material, "glass") or string.find(material, "lamp") then
+               return default.node_sound_glass_defaults()
+       elseif string.find(material, "wood") or string.find(material, "tree") then
+               return default.node_sound_wood_defaults()
+       else
+               return default.node_sound_stone_defaults()
+       end
+end
+
+local function tnaming(material)
+       if string.find(material, "block") then
+               local newname = string.gsub(material, "(block)", "_%1")
+               return "default_"..newname..".png"
+       elseif string.find(material, "brick") then
+               local newname = string.gsub(material, "(brick)", "_%1")
+               return "default_"..newname..".png"
+       else return "default_"..material..".png" end
+end
+
+for _, m in ipairs(material) do
+       local light = lightlvl(m)
+       local sound = stype(m)
+       local tile = tnaming(m)
+
+       for _, n in ipairs(def) do
+       xdecor.register(n[1].."_"..m, {
+               description = n[1], light_source = light, sounds = sound,
+               tiles = {tile}, groups = {snappy=3, not_in_creative_inventory=1},
+               on_place = minetest.rotate_node, node_box = {type = "fixed", fixed = n[3]} })
+       end
+end
+
+-- Repair Tool's code by Krock, modified by kilbith
+
+minetest.register_abm({
+       nodenames = {"xdecor:worktable"},
+       interval = 5, chance = 1,
+       action = function(pos, node, active_object_count, active_object_count_wider)
+               local meta = minetest.get_meta(pos)
+               local inv = meta:get_inventory()
+               local src = inv:get_stack("src", 1)
+               local wear = src:get_wear()
+               local repair = -1400
+
+               if (src:is_empty() or wear == 0 or wear == 65535) then return end
+               local fuel = inv:get_stack("fuel", 1)
+               if (fuel:is_empty() or fuel:get_name() ~= "xdecor:hammer") then return end
+
+               if (wear + repair < 0) then src:add_wear(repair + wear)
+               else src:add_wear(repair) end
+
+               inv:set_stack("src", 1, src)
+               inv:remove_item("fuel", "xdecor:hammer 1")
+       end
+})