From 0bf30f0f5cb9650bc0b3d67ed022fc13aeee2cbe Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Sun, 14 Feb 2016 16:20:18 +0100 Subject: [PATCH] Work Table -> Work Bench --- init.lua | 2 +- nodes.lua | 1 + recipes.lua | 2 +- textures/xdecor_workbench_front.png | Bin 0 -> 295 bytes textures/xdecor_workbench_sides.png | Bin 0 -> 300 bytes textures/xdecor_workbench_top.png | Bin 0 -> 264 bytes worktable.lua => workbench.lua | 86 ++++++++++++++-------------- 7 files changed, 47 insertions(+), 44 deletions(-) create mode 100644 textures/xdecor_workbench_front.png create mode 100644 textures/xdecor_workbench_sides.png create mode 100644 textures/xdecor_workbench_top.png rename worktable.lua => workbench.lua (77%) diff --git a/init.lua b/init.lua index df420f1..f5f29c9 100644 --- a/init.lua +++ b/init.lua @@ -20,7 +20,7 @@ dofile(modpath.."/mailbox.lua") dofile(modpath.."/nodes.lua") dofile(modpath.."/recipes.lua") dofile(modpath.."/rope.lua") -dofile(modpath.."/worktable.lua") +dofile(modpath.."/workbench.lua") dofile(modpath.."/xwall.lua") --print(string.format("[xdecor] loaded in %.2f ms", (os.clock()-t)*1000)) diff --git a/nodes.lua b/nodes.lua index b9b93f0..308877d 100644 --- a/nodes.lua +++ b/nodes.lua @@ -224,6 +224,7 @@ local function door_access(door) return door:find("prison") end for _, d in pairs({"japanese", "prison", "rusty_prison", "screen", "slide", "woodglass"}) do + if not doors.register then return end doors.register(d.."_door", { tiles = {{name = "xdecor_"..d.."_door.png", backface_culling=true}}, description = string.gsub(" "..d, "%W%l", string.upper):sub(2):gsub("_", " ").." Door", diff --git a/recipes.lua b/recipes.lua index 706e1b6..c013e99 100644 --- a/recipes.lua +++ b/recipes.lua @@ -360,7 +360,7 @@ minetest.register_craft({ }) minetest.register_craft({ - output = "xdecor:worktable", + output = "xdecor:workbench", recipe = { {"group:wood", "group:wood"}, {"group:wood", "group:wood"} diff --git a/textures/xdecor_workbench_front.png b/textures/xdecor_workbench_front.png new file mode 100644 index 0000000000000000000000000000000000000000..a7b04dfc2f8602a7ddae41aa6f832c7098d80de4 GIT binary patch literal 295 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!cYsfb>+(X^wWXd_?&?i`I{8kD z+Zsax424h4%04tXd1rU@+yv7&bJ;!pv1wLP7Zw+8tnyxxX}ciBVtTaE!W^fLU|mlQ zfxc+-SOal81>Wp9i4>r*(>+}rLnJP{_HqjyR^V_E7ikVmp7pH!|70;w>)Jy-n{~LC zrOuQS`@O2kz$;g3O{>H3zk;P$4ELv15 z%cOYOix=+N$HsfKmF1~edEUe4A1*8J5Z~7GxuGg8^wWh26Sh}w&I&1GJFX&nJL|~2 r8?v#{J&K?1@e5msFm^hu(S6Kpa-A(_l})xB(1{G5u6{1-oD!M<pA7PkKiuu69a-PcBd~6Vaq|T{RkTLL<7lxul|?b5AA7nrgz3W4?%6fmSm~C=k`E zdD^glZEbBwM@OM-LOeV?j$1cAAPvxE@<#vw0GUZdK~xyiMUPt!g&+(>r=>szRDA3H zH+rGw#sgo|lSu|~TjMy!mo=`~W+o;O_t!o~o|zejo#Mna2^lj_BZ5BO``a6jDh9U@ z4lyWr*8{101x^5A=s}=z6_Heubi+9nEtNUv47DIYasia#B_5cN9 yr9N~6kSbywLm#Ab64dvcj>H-e*#xKrw zT9jtBuOnhtbI6g2$=jO4=Omh+n3Xv#)?{VAeP_5~jgQvp1=%^R%nm^96FglULnJQC z`ZEe0R^VX@N>18c`oI2dz@tninYam4b)TNe{Ly%CiHY=*75NQ?%%660DCM8IGSBlA z!C)swrJ69k8$+LsOfs5ad5-q&Vn~w-{(x%FJD$> zP$~0!y`b9KiW_e%{>9Eyx*2+bt^V8xySze&y}f#+8+Tvzy7rg-b{BJP{H(3tfo@~) MboFyt=akR{0F^Cj7ytkO literal 0 HcmV?d00001 diff --git a/worktable.lua b/workbench.lua similarity index 77% rename from worktable.lua rename to workbench.lua index ca83236..53d4da5 100644 --- a/worktable.lua +++ b/workbench.lua @@ -1,9 +1,9 @@ -local worktable = {} +local workbench = {} screwdriver = screwdriver or {} -- Nodes allowed to be cut. -- Only the regular, solid blocks without formspec or explosivity can be cut. -function worktable:nodes(def) +function workbench:nodes(def) return (def.drawtype == "normal" or def.drawtype:find("glass")) and (def.groups.cracky or def.groups.choppy) and not def.on_construct and not def.after_place_node and not @@ -15,7 +15,7 @@ function worktable:nodes(def) end -- Nodeboxes definitions. -worktable.defs = { +workbench.defs = { -- Name Yield X Y Z W H L {"nanoslab", 16, { 0, 0, 0, 8, 1, 8 }}, {"micropanel", 16, { 0, 0, 0, 16, 1, 8 }}, @@ -38,11 +38,11 @@ worktable.defs = { } -- Tools allowed to be repaired. -worktable.repairable_tools = [[ +workbench.repairable_tools = [[ pick, axe, shovel, sword, hoe, armor, shield ]] -function worktable:get_output(inv, input, name) +function workbench:get_output(inv, input, name) if inv:is_empty("input") then inv:set_list("forms", {}) return end @@ -57,7 +57,7 @@ function worktable:get_output(inv, input, name) inv:set_list("forms", output) end -function worktable.formspecs(meta, id) +function workbench:formspecs(meta, id) local formspecs = { -- Main formspec. [[ label[0.9,1.23;Cut] @@ -92,7 +92,7 @@ function worktable.formspecs(meta, id) formspecs[id]..xbg..default.get_hotbar_bg(0,3.25)) end -function worktable.construct(pos) +function workbench.construct(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -102,24 +102,24 @@ function worktable.construct(pos) inv:set_size("forms", 4*3) inv:set_size("storage", 8*2) - meta:set_string("infotext", "Work Table") - worktable.formspecs(meta, 1) + meta:set_string("infotext", "Work Bench") + workbench:formspecs(meta, 1) end -function worktable.fields(pos, _, fields) +function workbench.fields(pos, _, fields) local meta = minetest.get_meta(pos) - if fields.back then worktable.formspecs(meta, 1) - elseif fields.craft then worktable.formspecs(meta, 2) - elseif fields.storage then worktable.formspecs(meta, 3) end + if fields.back then workbench:formspecs(meta, 1) + elseif fields.craft then workbench:formspecs(meta, 2) + elseif fields.storage then workbench:formspecs(meta, 3) end end -function worktable.dig(pos) +function workbench.dig(pos) local inv = minetest.get_meta(pos):get_inventory() return inv:is_empty("input") and inv:is_empty("hammer") and inv:is_empty("tool") and inv:is_empty("storage") end -function worktable.timer(pos) +function workbench.timer(pos) local timer = minetest.get_node_timer(pos) local inv = minetest.get_meta(pos):get_inventory() local tool = inv:get_stack("tool", 1) @@ -139,10 +139,10 @@ function worktable.timer(pos) return true end -function worktable.put(_, listname, _, stack) +function workbench.put(_, listname, _, stack) local stackname = stack:get_name() if (listname == "tool" and stack:get_wear() > 0 and - worktable.repairable_tools:find(stackname:match(":(%w+)"))) or + workbench.repairable_tools:find(stackname:match(":(%w+)"))) or (listname == "input" and minetest.registered_nodes[stackname.."_cube"]) or (listname == "hammer" and stackname == "xdecor:hammer") or listname == "storage" then @@ -151,7 +151,7 @@ function worktable.put(_, listname, _, stack) return 0 end -function worktable.take(_, listname, _, stack, player) +function workbench.take(_, listname, _, stack, player) if listname == "forms" then local inv = player:get_inventory() if inv:room_for_item("main", stack:get_name()) then return -1 end @@ -160,62 +160,62 @@ function worktable.take(_, listname, _, stack, player) return stack:get_count() end -function worktable.move(_, _, _, to_list, _, count) +function workbench.move(_, _, _, to_list, _, count) if to_list == "storage" then return count end return 0 end -function worktable.on_put(pos, listname, _, stack) +function workbench.on_put(pos, listname, _, stack) local inv = minetest.get_meta(pos):get_inventory() if listname == "input" then local input = inv:get_stack("input", 1) - worktable:get_output(inv, input, stack:get_name()) + workbench:get_output(inv, input, stack:get_name()) elseif listname == "tool" or listname == "hammer" then local timer = minetest.get_node_timer(pos) timer:start(3.0) end end -function worktable.on_take(pos, listname, index, stack) +function workbench.on_take(pos, listname, index, stack) local inv = minetest.get_meta(pos):get_inventory() local input = inv:get_stack("input", 1) if listname == "input" then if stack:get_name() == input:get_name() then - worktable:get_output(inv, input, stack:get_name()) + workbench:get_output(inv, input, stack:get_name()) else inv:set_list("forms", {}) end elseif listname == "forms" then - input:take_item(math.ceil(stack:get_count() / worktable.defs[index][2])) + input:take_item(math.ceil(stack:get_count() / workbench.defs[index][2])) inv:set_stack("input", 1, input) - worktable:get_output(inv, input, input:get_name()) + workbench:get_output(inv, input, input:get_name()) end end -xdecor.register("worktable", { - description = "Work Table", +xdecor.register("workbench", { + description = "Work Bench", groups = {cracky=2, choppy=2, oddly_breakable_by_hand=1}, sounds = default.node_sound_wood_defaults(), 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" + "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_rotate = screwdriver.rotate_simple, - can_dig = worktable.dig, - on_timer = worktable.timer, - on_construct = worktable.construct, - on_receive_fields = worktable.fields, - on_metadata_inventory_put = worktable.on_put, - on_metadata_inventory_take = worktable.on_take, - allow_metadata_inventory_put = worktable.put, - allow_metadata_inventory_take = worktable.take, - allow_metadata_inventory_move = worktable.move + can_dig = workbench.dig, + on_timer = workbench.timer, + on_construct = workbench.construct, + on_receive_fields = workbench.fields, + on_metadata_inventory_put = workbench.on_put, + on_metadata_inventory_take = workbench.on_take, + allow_metadata_inventory_put = workbench.put, + allow_metadata_inventory_take = workbench.take, + allow_metadata_inventory_move = workbench.move }) -for _, d in pairs(worktable.defs) do +for _, d in pairs(workbench.defs) do for node in pairs(minetest.registered_nodes) do local def = minetest.registered_nodes[node] - if worktable:nodes(def) and d[3] then + if workbench:nodes(def) and d[3] then local groups, tiles = {}, {} groups.not_in_creative_inventory = 1 @@ -255,9 +255,11 @@ for node in pairs(minetest.registered_nodes) do if node:match(":mese") then if d[3] then minetest.register_alias(node.."_"..d[1], "default:glass_"..d[1]) else minetest.register_alias("stairs:"..d[1].."_"..node:match(":(.*)"), "stairs:"..d[1].."_glass") end - elseif worktable:nodes(def) and not d[3] then + elseif workbench:nodes(def) and not d[3] then minetest.register_alias(node.."_"..d[1], "stairs:"..d[1].."_"..node:match(":(.*)")) end end end +minetest.register_alias("xdecor:worktable", "xdecor:workbench") +