From 8b05506e32a5e8dcc9284eb05b7a4d9f6027b991 Mon Sep 17 00:00:00 2001 From: Kotolegokot Date: Sat, 20 Apr 2013 21:42:33 +0600 Subject: [PATCH] Added joiner_table --- mods/instruments/init.lua | 2 +- mods/joiner_table/depends.txt | 2 + mods/joiner_table/init.lua | 137 ++++++++++++++++++ .../textures/joiner_table_arrow.png | Bin 0 -> 708 bytes .../textures/joiner_table_face.png | Bin 0 -> 228 bytes .../textures/joiner_table_side.png | Bin 0 -> 828 bytes .../textures/joiner_table_top.png | Bin 0 -> 505 bytes mods/scribing_table/init.lua | 2 +- 8 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 mods/joiner_table/depends.txt create mode 100644 mods/joiner_table/init.lua create mode 100644 mods/joiner_table/textures/joiner_table_arrow.png create mode 100644 mods/joiner_table/textures/joiner_table_face.png create mode 100644 mods/joiner_table/textures/joiner_table_side.png create mode 100644 mods/joiner_table/textures/joiner_table_top.png diff --git a/mods/instruments/init.lua b/mods/instruments/init.lua index 5fdb43a..0c3f908 100644 --- a/mods/instruments/init.lua +++ b/mods/instruments/init.lua @@ -180,7 +180,7 @@ for i, material in ipairs(instruments.materials) do end --Instruments (without chisels and spears) for j, instrument in ipairs({"pick", "axe", "shovel", "hammer", "sword", "saw"}) do - --Stone swords are not exist + --Stone swords and saws are not exist if not (material == "stone" and (instrument == "sword" or instrument == "saw")) then minetest.register_tool("instruments:"..instrument.."_"..material, { description = instruments.desc_list[i].." "..instrument:capitalize(), diff --git a/mods/joiner_table/depends.txt b/mods/joiner_table/depends.txt new file mode 100644 index 0000000..25576a2 --- /dev/null +++ b/mods/joiner_table/depends.txt @@ -0,0 +1,2 @@ +default +trees diff --git a/mods/joiner_table/init.lua b/mods/joiner_table/init.lua new file mode 100644 index 0000000..c287756 --- /dev/null +++ b/mods/joiner_table/init.lua @@ -0,0 +1,137 @@ +joiner_table = {} +realtest.registered_joiner_table_recipes = {} + +function realtest.register_joiner_table_recipe(RecipeDef) + local recipe = { + item1 = RecipeDef.item1 or "", + item2 = RecipeDef.item2 or "", + rmitem1 = RecipeDef.rmitem1, + rmitem2 = RecipeDef.rmitem2, + output = RecipeDef.output or "", + instrument = RecipeDef.instrument or "saw", + } + if recipe.rmitem1 == nil then + recipe.rmitem1 = true + end + if recipe.rmitem2 == nil then + recipe.rmitem2 = true + end + if recipe.output ~= "" and recipe.item1 ~= "" then + table.insert(realtest.registered_joiner_table_recipes, recipe) + end +end + +for _, tree in pairs(realtest.registered_trees_list) do + realtest.register_joiner_table_recipe({ + item1 = tree.."_log", + output = tree.."_plank 4" + }) + realtest.register_joiner_table_recipe({ + item1 = tree.."_plank", + output = tree.."_stick 4" + }) +end + +realtest.register_joiner_table_recipe({ + item1 = "default:stone", + output = "default:stone_flat", + instrument = "chisel" +}) + +realtest.register_joiner_table_recipe({ + item1 = "default:desert_stone", + output = "default:desert_stone_flat", + instrument = "chisel" +}) + +for _, tree in pairs(realtest.registered_trees) do + local planks = tree.textures.planks + minetest.register_node("joiner_table:joiner_table_"..tree.name:remove_modname_prefix(), + { + description = tree.description .. " Joiner Table", + tiles = {planks.."^joiner_table_top.png", planks, planks.."^joiner_table_side.png", + planks.."^joiner_table_side.png", planks.."^joiner_table_side.png", planks.."^joiner_table_face.png"}, + groups = {oddly_breakable_by_hand=3, dig_immediate=2}, + sounds = default.node_sound_wood_defaults(), + paramtype = "light", + paramtype2 = "facedir", + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + meta:set_string("formspec", "size[8,8]".. + "button[0.5,0.25;1.35,1;buttonCraft;Craft]".. + "button[1.6,0.25;0.9,1;buttonCraft10;x10]".. + "list[current_name;src1;3.9,0.75;1,1;]".. + "image[4.69,0.72;0.54,1.5;anvil_arrow.png]".. + "list[current_name;src2;5.1,0.75;1,1;]".. + "list[current_name;instruments;0.5,1.5;2,2;]".. + "list[current_name;output;4.5,2;1,1;]".. + "list[current_player;main;0,4;8,4;]") + meta:set_string("infotext", "Joiner Table") + local inv = meta:get_inventory() + inv:set_size("src1", 1) + inv:set_size("src2", 1) + inv:set_size("instruments", 4) + inv:set_size("output", 1) + end, + on_receive_fields = function(pos, formname, fields, sender) + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + + local src1, src2 = inv:get_stack("src1", 1), inv:get_stack("src2", 1) + local output = inv:get_stack("output", 1) + + local find_instrument = function(instrument) + for i = 1, 4 do + local istack = inv:get_stack("instruments", i) + if minetest.get_node_group(istack:get_name(), instrument) == 1 then + return i + end + end + return nil + end + + local craft = function() + for _, recipe in ipairs(realtest.registered_joiner_table_recipes) do + local instr = find_instrument(recipe.instrument) + local instr_stack = nil + if instr then + instr_stack = inv:get_stack("instruments", instr) + end + if instr_stack and recipe.item1 == src1:get_name() and recipe.item2 == src2:get_name() then + minetest.chat_send_all("sdf") + if inv:room_for_item("output", recipe.output) then + if recipe.rmitem1 then + src1:take_item() + inv:set_stack("src1", 1, src1) + end + if recipe.item2 ~= "" and recipe.rmitem2 then + src2:take_item() + inv:set_stack("src2", 1, src2) + end + output:add_item(recipe.output) + inv:set_stack("output", 1, output) + instr_stack:add_wear(65535/minetest.get_item_group(instr_stack:get_name(), "durability")) + inv:set_stack("instruments", instr, instr_stack) + end + return + end + end + end + + if fields["buttonCraft"] then + craft() + elseif fields["buttonCraft10"] then + for i = 0, 9 do + craft() + end + end + end, + }) + minetest.register_craft({ + output = "joiner_table:joiner_table_"..tree.name:remove_modname_prefix(), + recipe = { + {tree.name.."_planks", tree.name.."_planks"}, + {tree.name.."_planks", tree.name.."_planks"} + } + }) +end diff --git a/mods/joiner_table/textures/joiner_table_arrow.png b/mods/joiner_table/textures/joiner_table_arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..3522669a46bedc7db2a5d7ff948a820fe9f687b4 GIT binary patch literal 708 zcmV;#0z3VQP)gGHICks|NK67d ziZA0hPP)6gy4)G6Dz+GcjmB zYYGKh~HjqK<4wn-vdSz7Jk#$@uIe$(o2 zoM;a+Z3wXtVgl0lUZ1F1O{t~;g|WJsP_g1JsHMRQUM4}8Pu5HiV~Sq9Vq}m_}U3^Y9PbLC+rrVd=``#vU7e> zerkWjyKXq!mPNsBO$9oA>a6?u!^J?_RwBDpbE1WL<3EFwSeCCaB)xar%KEI^1iHh` z@dyq_48u{_KI6#F|0ttvtQL70(Y)*K0-AbW|YuPggq7GZupExsK!>OdjM64!_l=ltB< z)VvY~=c3falGGH1^30M91$R&1fbd2>aiAi5PZ!4!i_^&|2?-G=926HEX=v36IL2zk zyMx2{KtqhULEx);F`J?n_ly*-GA!ETYO3FJjEQxl!H32Z9+_oq439#1vYq`-0^P&F N;OXk;vd$@?2>{+#LRSC) literal 0 HcmV?d00001 diff --git a/mods/joiner_table/textures/joiner_table_side.png b/mods/joiner_table/textures/joiner_table_side.png new file mode 100644 index 0000000000000000000000000000000000000000..5729bc7db4e294da469c8699c2afaf8402a4d30f GIT binary patch literal 828 zcmV-C1H=4@P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i*h{ z4=n`wLn12x000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0007)Nkl^ktwD@DoV8o!CJH^Q_6fbGd7OnT<`tv*CvNCXi=TrIfwH*k3WY1^x!}3p8##G z?F67l`aQ9$+)ee>Zu(Qc4Y_AA~A02M*K%Hve- zXo_I5gmHQ7J%(mPFFR(2M?8ESp|hpwFrbD+>jja%W3; zHqtdD0APD%%|L!2zggEE;`ZH}n#bv~J37t)05$<$PAspqH3pV_Zl*@MhRlt4Q7~A2 z`N}0ZSX?Zd>+80j@0T1-M+$(P0fYh?t*r5ac+v_M8n%6*tvvW{R-ON}sM5mR{QK+I zx(k@1@JEmDtAhiBVl}zy0>CqXuZxB#$deMfDkZ`>IkKx&1YPim4@McQ}yB_4CPFV`IbK z@$q5bCcw6!SBoZb?n_kJIulikmksq|Wq79o09$lBCduGJAeC67NcP<%0Ejd+kT1V< zUUmAenzGk#lGo*M`Ok-n@;(B<^NDDT$s%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