From 63f51ea4dd84e2073968c1ef2f52926857ac3493 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Mon, 28 May 2018 23:23:39 +0200 Subject: [PATCH] Alloy meridium with tools added --- README.md | 4 +- charcoalpile.lua | 21 ++- coalburner.lua | 34 +++-- depends.txt | 4 +- init.lua | 65 +-------- lighter.lua | 89 ++++++++++++ locale/de.mo | Bin 2119 -> 2319 bytes locale/de.po | 31 ++-- locale/template.pot | 24 +++- meltingpot.lua | 211 +++++++++++++++------------- meridium.lua | 127 +++++++++++++++++ recipes.lua | 25 ++-- textures/ironage_meridium_ingot.png | Bin 0 -> 266 bytes textures/ironage_meridiumaxe.png | Bin 0 -> 248 bytes textures/ironage_meridiumpick.png | Bin 0 -> 261 bytes textures/ironage_meridiumshovel.png | Bin 0 -> 257 bytes textures/ironage_meridiumsword.png | Bin 0 -> 230 bytes tools.lua | 103 ++++++++++++++ 18 files changed, 526 insertions(+), 212 deletions(-) create mode 100644 lighter.lua create mode 100644 meridium.lua create mode 100644 textures/ironage_meridium_ingot.png create mode 100644 textures/ironage_meridiumaxe.png create mode 100644 textures/ironage_meridiumpick.png create mode 100644 textures/ironage_meridiumshovel.png create mode 100644 textures/ironage_meridiumsword.png create mode 100644 tools.lua diff --git a/README.md b/README.md index 14cfeb9..e78c0b0 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ Fantasy Charcoal Pile and Coal Burner for melting ore lumps to ingots (furnace r ## Dependencies -default -fire +default, fire, farming +Optional: intllib, wielded_light, unified_inventory # License Copyright (C) 2018 Joachim Stolberg diff --git a/charcoalpile.lua b/charcoalpile.lua index 4f4c6cc..55d4263 100644 --- a/charcoalpile.lua +++ b/charcoalpile.lua @@ -31,14 +31,6 @@ local function num_dirt(pos) return #nodes end -local function make_dirt_with_ash(pos) - pos.y = pos.y - 1 - if string.find(minetest.get_node(pos).name, "default:dirt") then - minetest.swap_node(pos, {name = "ironage:dirt_with_ash"}) - end - pos.y = pos.y + 1 -end - local function make_dirt_with_dry_grass(pos) local pos1 = {x=pos.x-2, y=pos.y+3, z=pos.z-2} local pos2 = {x=pos.x+2, y=pos.y+3, z=pos.z+2} @@ -47,6 +39,13 @@ local function make_dirt_with_dry_grass(pos) end end +local function make_dirt_with_ash(pos) + local pos1 = {x=pos.x-1, y=pos.y-1, z=pos.z-1} + local pos2 = {x=pos.x+1, y=pos.y-1, z=pos.z+1} + for _,p in ipairs(minetest.find_nodes_in_area(pos1, pos2, "default:dirt")) do + minetest.swap_node(p, {name = "ironage:dirt_with_ash"}) + end +end local function start_smoke(pos) local meta = minetest.get_meta(pos) pos = {x=pos.x, y=pos.y+3.6, z=pos.z} @@ -107,17 +106,14 @@ end function ironage.start_pile(pos) local meta = minetest.get_meta(pos) meta:set_int("ignite", minetest.get_gametime()) - minetest.get_node_timer(pos):start(5) + minetest.get_node_timer(pos):start(20) end function ironage.keep_running_pile(pos) local meta = minetest.get_meta(pos) - --print("running", meta:get_int("running"), "ignite", meta:get_int("ignite"), "gametime", minetest.get_gametime()) if meta:get_int("running") == 0 then if num_wood(pos) == 26 and num_dirt(pos) == 98 then - minetest.get_node_timer(pos):stop() - minetest.get_node_timer(pos):start(22) meta:set_int("running", 1) start_smoke(pos) elseif minetest.get_gametime() > (meta:get_int("ignite") + 10) then @@ -164,7 +160,6 @@ minetest.register_node("ironage:charcoal_burn", { end, on_timer = function(pos) minetest.remove_node(pos) - make_dirt_with_ash(pos) return false end, drop = "", diff --git a/coalburner.lua b/coalburner.lua index f340df6..31ac06b 100644 --- a/coalburner.lua +++ b/coalburner.lua @@ -122,8 +122,13 @@ minetest.register_node("ironage:ash", { sounds = default.node_sound_defaults(), }) -function ironage.start_burner(pos) +function ironage.start_burner(pos, playername) local height = num_coal(pos) + if minetest.is_protected( + {x=pos.x, y=pos.y+height, z=pos.z}, + playername) then + return + end if num_cobble(pos, height) == height * 8 then local meta = minetest.get_meta(pos) meta:set_int("ignite", minetest.get_gametime()) @@ -149,18 +154,21 @@ function ironage.keep_running_burner(pos) minetest.sound_stop(handle) meta:set_int("handle", nil) end - local new_height = num_coal(pos) - if new_height > 0 then - flame(pos, height, new_height) - handle = minetest.sound_play("ironage", { - pos = {x=pos.x, y=pos.y+height, z=pos.z}, - max_hear_distance = 32, - gain = new_height/32.0, - loop = true}) - meta:set_int("handle", handle) - else - minetest.swap_node(pos, {name="ironage:ash"}) - return false + if num_cobble(pos, height) == height * 8 then + local new_height = num_coal(pos) + if new_height > 0 then + flame(pos, height, new_height) + handle = minetest.sound_play("ironage", { + pos = {x=pos.x, y=pos.y+height, z=pos.z}, + max_hear_distance = 32, + gain = new_height/32.0, + loop = true}) + meta:set_int("handle", handle) + else + minetest.swap_node(pos, {name="ironage:ash"}) + return false + end + return true end return true end diff --git a/depends.txt b/depends.txt index ab84969..063a9d1 100644 --- a/depends.txt +++ b/depends.txt @@ -1,4 +1,6 @@ default fire +farming intllib? -unified_inventory +wielded_light? +unified_inventory? diff --git a/init.lua b/init.lua index 646f4e3..a083584 100644 --- a/init.lua +++ b/init.lua @@ -39,65 +39,12 @@ end dofile(MP.."/charcoalpile.lua") dofile(MP.."/coalburner.lua") +dofile(MP.."/lighter.lua") dofile(MP.."/meltingpot.lua") +dofile(MP.."/tools.lua") +if minetest.global_exists("wielded_light") then + dofile(MP.."/meridium.lua") +end + dofile(MP.."/recipes.lua") -minetest.register_node("ironage:lighter_burn", { - tiles = {"ironage_lighter_burn.png"}, - - after_place_node = function(pos) - ironage.start_pile(pos) - end, - - on_timer = function(pos, elapsed) - return ironage.keep_running_pile(pos) - end, - - on_destruct = function(pos) - ironage.stop_pile(pos) - end, - - drop = "", - light_source = 10, - is_ground_content = false, - groups = {cracky = 3}, - sounds = default.node_sound_stone_defaults(), -}) - -minetest.register_node("ironage:coal_lighter_burn", { - tiles = {"ironage_lighter_burn.png"}, - - after_place_node = function(pos) - ironage.start_burner(pos) - end, - - on_timer = function(pos, elapsed) - return ironage.keep_running_burner(pos) - end, - - on_destruct = function(pos) - ironage.stop_burner(pos) - end, - - drop = "", - light_source = 10, - is_ground_content = false, - groups = {cracky = 3}, - sounds = default.node_sound_stone_defaults(), -}) - -minetest.register_node("ironage:lighter", { - description = S("Lighter"), - tiles = {"ironage_lighter.png"}, - on_ignite = function(pos, igniter) - if minetest.find_node_near(pos, 1, "ironage:charcoal") then - minetest.after(1, ironage.swap_node, pos, "ironage:coal_lighter_burn") - else - minetest.after(1, ironage.swap_node, pos, "ironage:lighter_burn") - end - end, - is_ground_content = false, - groups = {cracky = 3,flammable=2}, - sounds = default.node_sound_leaves_defaults(), -}) - diff --git a/lighter.lua b/lighter.lua new file mode 100644 index 0000000..f111286 --- /dev/null +++ b/lighter.lua @@ -0,0 +1,89 @@ +--[[ + + Iron Age + ======== + + Copyright (C) 2018 Joachim Stolberg + + LGPLv2.1+ + See LICENSE.txt for more information + +]]-- + +-- Load support for intllib. +local MP = minetest.get_modpath("ironage") +local S, NS = dofile(MP.."/intllib.lua") + +minetest.register_node("ironage:lighter_burn", { + tiles = {"ironage_lighter_burn.png"}, + + after_place_node = function(pos) + ironage.start_pile(pos) + end, + + on_timer = function(pos, elapsed) + return ironage.keep_running_pile(pos) + end, + + on_destruct = function(pos) + ironage.stop_pile(pos) + end, + + drop = "", + light_source = 10, + is_ground_content = false, + groups = {cracky = 3}, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("ironage:coal_lighter_burn", { + tiles = {"ironage_lighter_burn.png"}, + + after_place_node = function(pos) + local meta = minetest.get_meta(pos) + local playername = meta:get_string("playername") + ironage.start_burner(pos, playername) + end, + + on_timer = function(pos, elapsed) + return ironage.keep_running_burner(pos) + end, + + on_destruct = function(pos) + ironage.stop_burner(pos) + end, + + drop = "", + light_source = 10, + is_ground_content = false, + groups = {cracky = 3}, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("ironage:lighter", { + description = S("Lighter"), + tiles = {"ironage_lighter.png"}, + on_ignite = function(pos, igniter) + if minetest.find_node_near(pos, 1, "ironage:charcoal") then + minetest.after(1, ironage.swap_node, pos, "ironage:coal_lighter_burn") + else + minetest.after(1, ironage.swap_node, pos, "ironage:lighter_burn") + end + end, + after_place_node = function(pos, placer) + local meta = minetest.get_meta(pos) + meta:set_string("playername", placer:get_player_name()) + end, + is_ground_content = false, + groups = {cracky = 3,flammable=2}, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_craft({ + output = 'ironage:lighter 2', + recipe = { + {'group:wood'}, + {'farming:straw'}, + {''}, + } +}) diff --git a/locale/de.mo b/locale/de.mo index 440bc6818ed0e1d2f076f12238bc670a01e3fcd3..e26f792aeb3dd08b3dd176f51aa67d31a69bb327 100644 GIT binary patch delta 620 zcma)&ze_?<6vwZ=XTI#0wNzO65(0w=v!MuFiol^FC>NnYc;I_K_nv$1`QCe5(aVv>+lYCkh+#B=?$9Wj4KNU= z(12&qf*0@yUc)7H5>#q{^&>^XXK2D#7>4hi{1@zF{RhWkfTEaE4HaWDNn#Po!5qUF z%y-rYFoDq#43WQK=!Lg1M*acTVXLQYu)-||+24dxzYC?l2&1qH<)X(hhQB&zA{V%a zargw~;AbcQ4e?eHy5Qsglo;?3Kk)TmD$OPOk-SuTNQjx7ml#43Bp337-ijYoR&yY)Jpc&zH2+RuJ=+i-ir}8cbuyBevNE6y=12s zmgl`ybINMZ)2U{~tQn!KY5P;#iAAGADl`+A&99=4pJzJ5e$f+y&sD?kR!wdA%&^z0v5r> z($Y4KgV;y8^H z?9XEZ*9Q9+J@ATd`W1EEd*~-7S@%#k^oQe^pnHAq98Tc^8nV&9j86nz>jQKZ1n&et z9zlIjKSpms=m&KS^%3b@7`u_!mUmpPscO3$T}-=9S?$*fQc`|B7&1HR(5tA^%(i!; zGOP8fPvx0ejAipqHs>z2pUoL7oaZ~=rXP*3_>ISV|A@K+YuR$0qE~CELi@`~{{t6h BJuUzM diff --git a/locale/de.po b/locale/de.po index 4c04a42..e684bf7 100644 --- a/locale/de.po +++ b/locale/de.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-05-19 18:09+0200\n" -"PO-Revision-Date: 2018-05-19 18:09+0200\n" +"POT-Creation-Date: 2018-05-28 23:19+0200\n" +"PO-Revision-Date: 2018-05-28 23:20+0200\n" "Last-Translator: \n" "Language-Team: \n" "Language: de\n" @@ -29,10 +29,6 @@ msgstr "Holzkohle" msgid "Ash" msgstr "Asche" -#: init.lua -msgid "Lighter" -msgstr "Anzünder" - #: meltingpot.lua msgid "Menu,Recipes,Pile,Burner" msgstr "Menü,Rezepte,Köhler,Brenner" @@ -89,21 +85,40 @@ msgstr "Menü" msgid "Melting Guide" msgstr "Schmelzanleitung" +#: meltingpot.lua +msgid "Heat" +msgstr "Hitze" + +#: meltingpot.lua +msgid "Time" +msgstr "Zeit" + #: meltingpot.lua msgid "Cross-section" msgstr "Schnittbild" #: meltingpot.lua -msgid "Melting Pot: heat=" -msgstr "Schmelztiegel: Hitze=" +msgid "Melting Pot active (heat=" +msgstr "Schmelztiegel aktiv (Hitze=" + +#: meltingpot.lua +msgid "Melting Pot inactive (heat=" +msgstr "Schmelztiegel inaktiv (Hitze=" #: meltingpot.lua msgid "Melting Pot" msgstr "Schmelztiegel" +#: meltingpot.lua +msgid "Melting Pot inactive (heat=0)" +msgstr "Schmelztiegel inaktiv (Hitze=0)" + #: meltingpot.lua msgid "Melting" msgstr "Schmelzen" +#~ msgid "Lighter" +#~ msgstr "Anzünder" + #~ msgid "Inventory" #~ msgstr "Inventory" diff --git a/locale/template.pot b/locale/template.pot index d7113a7..758b649 100644 --- a/locale/template.pot +++ b/locale/template.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-05-19 18:09+0200\n" +"POT-Creation-Date: 2018-05-28 23:19+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -29,10 +29,6 @@ msgstr "" msgid "Ash" msgstr "" -#: init.lua -msgid "Lighter" -msgstr "" - #: meltingpot.lua msgid "Menu,Recipes,Pile,Burner" msgstr "" @@ -71,18 +67,34 @@ msgstr "" msgid "Melting Guide" msgstr "" +#: meltingpot.lua +msgid "Heat" +msgstr "" + +#: meltingpot.lua +msgid "Time" +msgstr "" + #: meltingpot.lua msgid "Cross-section" msgstr "" #: meltingpot.lua -msgid "Melting Pot: heat=" +msgid "Melting Pot active (heat=" +msgstr "" + +#: meltingpot.lua +msgid "Melting Pot inactive (heat=" msgstr "" #: meltingpot.lua msgid "Melting Pot" msgstr "" +#: meltingpot.lua +msgid "Melting Pot inactive (heat=0)" +msgstr "" + #: meltingpot.lua msgid "Melting" msgstr "" diff --git a/meltingpot.lua b/meltingpot.lua index 83658ab..3f9153c 100644 --- a/meltingpot.lua +++ b/meltingpot.lua @@ -96,25 +96,16 @@ local formspec1 = local function formspec2(idx) local key = KeyList[idx] - if not key then print("idx", idx); return "" end local input1 = Recipes[key].input[1] or "" local input2 = Recipes[key].input[2] or "" local input3 = Recipes[key].input[3] or "" local input4 = Recipes[key].input[4] or "" local num = Recipes[key].number - local output1 = Recipes[key].output - local output2 = "" - local output3 = "" - local output4 = "" - if num == 2 then - output2 = output1 - elseif num == 3 then - output2 = output1 - output3 = output1 - elseif num == 4 then - output2 = output1 - output3 = output1 - output4 = output1 + local heat = Recipes[key].heat + local time = Recipes[key].time + local output = Recipes[key].output + if num > 1 then + output = output.." "..num end return "size[8,8]".. default.gui_bg.. @@ -130,13 +121,11 @@ local function formspec2(idx) "item_image_button[1,1;1,1;"..input4..";b4;]".. "item_image[2.6,0;0.8,0.8;ironage:meltingpot]".. "image[2.3,0.6;1.6,1;gui_furnace_arrow_bg.png^[transformR270]".. - "item_image_button[4,0;1,1;"..output1..";b5;]".. - "item_image_button[5,0;1,1;"..output2..";b6;]".. - "item_image_button[4,1;1,1;"..output3..";b7;]".. - "item_image_button[5,1;1,1;"..output4..";b8;]".. - "label[2,2.5;Recipe "..idx.." of "..NumRecipes.."]".. - "button[2,3;1,1;priv;<<]".. - "button[3,3;1,1;next;>>]".. + "item_image_button[4,0.5;1,1;"..output..";b5;]".. + "label[2,2.2;"..S("Heat")..": "..heat.." / "..S("Time")..": "..time.." s]".. + "label[2,4;Recipe "..idx.." of "..NumRecipes.."]".. + "button[2,5.5;1,1;priv;<<]".. + "button[3,5.5;1,1;next;>>]".. "container_end[]" end @@ -166,7 +155,6 @@ local formspec4 = "container_end[]" local function on_receive_fields(pos, formname, fields, sender) - --print("fields", dump(fields)) local meta = minetest.get_meta(pos) local recipe_idx = meta:get_int("recipe_idx") if recipe_idx == 0 then recipe_idx = 1 end @@ -220,27 +208,31 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player return stack:get_count() end -local function get_output(input) - table.sort(input) - local key = table.concat(input, "-") - return Recipes[key] -end - +-- determine recipe based on inventory items local function get_recipe(inv) -- collect items - local items = {} - local input = {} + local stacks = {} + local names = {} + local numbers = {} for _,stack in ipairs(inv:get_list("src")) do if not stack:is_empty() then - table.insert(input, stack:get_name()) - table.insert(items, ItemStack(stack:get_name())) + table.insert(names, stack:get_name()) + table.insert(numbers, 1) + table.insert(stacks, stack) + else + table.insert(numbers, 0) + table.insert(stacks, ItemStack("")) end end -- determine output - local output = get_output(input) + table.sort(names) + local key = table.concat(names, "-") + local output = Recipes[key] + if output then return { - items = items, + numbers = numbers, + stacks = stacks, output = ItemStack(output.output.." "..output.number), heat = output.heat, time = output.time, @@ -249,19 +241,16 @@ local function get_recipe(inv) return nil end --- prepare recipe and store in table for faster access +-- prepare recipe and store in cache table for faster access local function store_recipe_in_cache(pos) local hash = minetest.hash_node_position(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local recipe = get_recipe(inv) - if recipe then - Cache[hash] = recipe - return recipe - end - return false + Cache[hash] = recipe + return recipe end - + -- read value from the node below local function get_heat(pos) local heat = 0 @@ -275,61 +264,67 @@ local function get_heat(pos) return heat end --- Start melting if heat>0 AND source items available +-- Start melting if heat is ok AND source items available function ironage.switch_to_active(pos) local meta = minetest.get_meta(pos) local heat = get_heat(pos) - local inv = meta:get_inventory() + local recipe = store_recipe_in_cache(pos) - if heat > 0 and not inv:is_empty("src") then - if store_recipe_in_cache(pos) then - minetest.swap_node(pos, {name = "ironage:meltingpot_active"}) - minetest.registered_nodes["ironage:meltingpot_active"].on_construct(pos) - meta:set_string("infotext", S("Melting Pot active (heat=")..heat..")") - minetest.get_node_timer(pos):start(2) - return true - end + if recipe and heat >= recipe.heat then + minetest.swap_node(pos, {name = "ironage:meltingpot_active"}) + minetest.registered_nodes["ironage:meltingpot_active"].on_construct(pos) + meta:set_string("infotext", S("Melting Pot active (heat=")..heat..")") + minetest.get_node_timer(pos):start(2) + return true end + meta:set_string("infotext", S("Melting Pot inactive (heat=")..heat..")") return false end --- Stop melting if heat==0 OR no source items available +local function set_inactive(meta, pos, heat) + minetest.get_node_timer(pos):stop() + minetest.swap_node(pos, {name = "ironage:meltingpot"}) + minetest.registered_nodes["ironage:meltingpot"].on_construct(pos) + meta:set_string("infotext", S("Melting Pot inactive (heat=")..heat..")") +end + +-- Stop melting if heat to low OR no source items available local function switch_to_inactive(pos) local meta = minetest.get_meta(pos) local heat = get_heat(pos) - local inv = meta:get_inventory() + local hash = minetest.hash_node_position(pos) + local recipe = Cache[hash] or store_recipe_in_cache(pos) - if heat == 0 or inv:is_empty("src") then - minetest.get_node_timer(pos):stop() - minetest.swap_node(pos, {name = "ironage:meltingpot"}) - minetest.registered_nodes["ironage:meltingpot"].on_construct(pos) - meta:set_string("infotext", S("Melting Pot inactive")) + if not recipe or heat < recipe.heat then + set_inactive(meta, pos, heat) return true end + meta:set_string("infotext", S("Melting Pot active (heat=")..heat..")") return false end - --- check if inventory has all needed items -local function contains_items(inv, listname, items) - for _,item in ipairs(items) do - if not inv:contains_item(listname, item) then - return false - end - end - return true -end - -- move recipe src items to dst output -local function process(inv, recipe) - if contains_items(inv, "src", recipe.items) then - if inv:room_for_item("dst", recipe.output) then - for _,item in ipairs(recipe.items) do - inv:remove_item("src", item) +local function process(inv, recipe, heat) + if heat < recipe.heat then + return false + end + for idx,num in ipairs(recipe.numbers) do + local stack = recipe.stacks[idx] + end + if inv:room_for_item("dst", recipe.output) then + for idx,num in ipairs(recipe.numbers) do + local stack = recipe.stacks[idx] + if num == 1 then + if stack and stack:get_count() > 0 then + stack:take_item(1) + else + return false + end end - inv:add_item("dst", recipe.output) - return true - end + end + inv:add_item("dst", recipe.output) + inv:set_list("src", recipe.stacks) + return true end return false end @@ -339,11 +334,11 @@ local function smelting(pos, recipe, heat, elapsed) local inv = meta:get_inventory() elapsed = elapsed + meta:get_int("leftover") - while heat >= recipe.heat and elapsed >= recipe.time do - print("process", elapsed) - if process(inv, recipe) == false then + while elapsed >= recipe.time do + if process(inv, recipe, heat) == false then meta:set_int("leftover", 0) - return + set_inactive(meta, pos, heat) + return false end elapsed = elapsed - recipe.time end @@ -352,7 +347,6 @@ local function smelting(pos, recipe, heat, elapsed) end local function pot_node_timer(pos, elapsed) - print("pot_node_timer", elapsed) if switch_to_inactive(pos) == false then local hash = minetest.hash_node_position(pos) local heat = get_heat(pos) @@ -411,6 +405,21 @@ minetest.register_node("ironage:meltingpot_active", { on_receive_fields(pos, formname, fields, sender) end, + on_metadata_inventory_move = function(pos) + store_recipe_in_cache(pos) + switch_to_inactive(pos) + end, + + on_metadata_inventory_put = function(pos) + store_recipe_in_cache(pos) + switch_to_inactive(pos) + end, + + on_metadata_inventory_take = function(pos) + store_recipe_in_cache(pos) + switch_to_inactive(pos) + end, + can_dig = can_dig, drop = "ironage:meltingpot", @@ -448,22 +457,25 @@ minetest.register_node("ironage:meltingpot", { on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec", formspec1) - meta:set_string("infotext", S("Melting Pot inactive")) + meta:set_string("infotext", S("Melting Pot inactive (heat=0)")) local inv = meta:get_inventory() inv:set_size('src', 4) inv:set_size('dst', 4) end, on_metadata_inventory_move = function(pos) - if store_recipe_in_cache(pos) then - ironage.switch_to_active(pos) - end + store_recipe_in_cache(pos) + ironage.switch_to_active(pos) end, on_metadata_inventory_put = function(pos) - if store_recipe_in_cache(pos) then - ironage.switch_to_active(pos) - end + store_recipe_in_cache(pos) + ironage.switch_to_active(pos) + end, + + on_metadata_inventory_take = function(pos) + store_recipe_in_cache(pos) + ironage.switch_to_active(pos) end, on_receive_fields = function(pos, formname, fields, sender) @@ -498,21 +510,26 @@ unified_inventory.register_craft_type("melting", { }) function ironage.register_recipe(recipe) - table.sort(recipe.recipe) - local key = table.concat(recipe.recipe, "-") + --table.sort(recipe.recipe) + local names = table.copy(recipe.recipe) + table.sort(names) + local key = table.concat(names, "-") local output = string.split(recipe.output, " ") + local number = tonumber(output[2] or 1) table.insert(KeyList, key) Recipes[key] = { input = recipe.recipe, output = output[1], - number = tonumber(output[2] or 1), - heat = recipe.heat or 3, - time = recipe.time or 2, + number = number, + heat = math.max(recipe.heat or 3, 2), + time = math.max(recipe.time or 2, 2*number), } NumRecipes = NumRecipes + 1 - recipe.items = recipe.recipe - recipe.type = "melting" - unified_inventory.register_craft(recipe) + if minetest.global_exists("unified_inventory") then + recipe.items = recipe.recipe + recipe.type = "melting" + unified_inventory.register_craft(recipe) + end end diff --git a/meridium.lua b/meridium.lua new file mode 100644 index 0000000..b1a1500 --- /dev/null +++ b/meridium.lua @@ -0,0 +1,127 @@ +--[[ + + Iron Age + ======== + + Copyright (C) 2018 Joachim Stolberg + Based on mods/default/tools.lua + + LGPLv2.1+ + See LICENSE.txt for more information + +]]-- + +-- Load support for intllib. +local MP = minetest.get_modpath("ironage") +local S, NS = dofile(MP.."/intllib.lua") + + +minetest.register_craftitem("ironage:meridium_ingot", { + description = "Meridium Ingot", + inventory_image = "ironage_meridium_ingot.png", +}) + + +minetest.register_tool("ironage:pick_meridium", { + description = S("Meridium Pickaxe"), + inventory_image = "ironage_meridiumpick.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=1, + groupcaps={ + cracky = {times={[1]=4.00, [2]=1.60, [3]=0.80}, uses=30, maxlevel=2}, + }, + damage_groups = {fleshy=4}, + }, + sound = {breaks = "default_tool_breaks"}, + light_source = 12, +}) + +minetest.register_tool("ironage:shovel_meridium", { + description = S("Meridium Shovel"), + inventory_image = "ironage_meridiumshovel.png", + wield_image = "ironage_meridiumshovel.png^[transformR90", + tool_capabilities = { + full_punch_interval = 1.1, + max_drop_level=1, + groupcaps={ + crumbly = {times={[1]=1.50, [2]=0.90, [3]=0.40}, uses=40, maxlevel=2}, + }, + damage_groups = {fleshy=3}, + }, + sound = {breaks = "default_tool_breaks"}, + light_source = 12, +}) + +minetest.register_tool("ironage:axe_meridium", { + description = S("Meridium Axe"), + inventory_image = "ironage_meridiumaxe.png", + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=1, + groupcaps={ + choppy={times={[1]=2.50, [2]=1.40, [3]=1.00}, uses=20, maxlevel=2}, + }, + damage_groups = {fleshy=4}, + }, + sound = {breaks = "default_tool_breaks"}, + light_source = 12, +}) + +minetest.register_tool("ironage:sword_meridium", { + description = S("Meridium Sword"), + inventory_image = "ironage_meridiumsword.png", + tool_capabilities = { + full_punch_interval = 0.8, + max_drop_level=1, + groupcaps={ + snappy={times={[1]=2.5, [2]=1.20, [3]=0.35}, uses=30, maxlevel=2}, + }, + damage_groups = {fleshy=6}, + }, + sound = {breaks = "default_tool_breaks"}, + light_source = 12, +}) + +minetest.register_craft({ + output = 'ironage:pick_meridium', + recipe = { + {'ironage:meridium_ingot', 'ironage:meridium_ingot', 'ironage:meridium_ingot'}, + {'', 'group:stick', ''}, + {'', 'group:stick', ''}, + } +}) + +minetest.register_craft({ + output = 'ironage:shovel_meridium', + recipe = { + {'ironage:meridium_ingot'}, + {'group:stick'}, + {'group:stick'}, + } +}) + +minetest.register_craft({ + output = 'ironage:axe_meridium', + recipe = { + {'ironage:meridium_ingot', 'ironage:meridium_ingot'}, + {'ironage:meridium_ingot', 'group:stick'}, + {'', 'group:stick'}, + } +}) + +minetest.register_craft({ + output = 'ironage:sword_meridium', + recipe = { + {'ironage:meridium_ingot'}, + {'ironage:meridium_ingot'}, + {'group:stick'}, + } +}) + +ironage.register_recipe({ + output = "ironage:meridium_ingot", + recipe = {"default:steel_ingot", "default:mese_crystal_fragment"}, + heat = 4, + time = 3, +}) diff --git a/recipes.lua b/recipes.lua index 247a167..8df88ac 100644 --- a/recipes.lua +++ b/recipes.lua @@ -17,25 +17,24 @@ local S, NS = dofile(MP.."/intllib.lua") ironage.register_recipe({ output = "default:obsidian", recipe = {"default:cobble"}, - heat = 4, + heat = 5, + time = 4, }) ironage.register_recipe({ - output = "default:gold_ingot", - recipe = {"default:copper_lump", "default:mese_crystal_fragment"}, - heat = 4 -}) - -ironage.register_recipe({ - output = "default:gold_ingot", - recipe = {"default:gold_lump"}, - heat = 4 + output = "default:bronze_ingot 4", + recipe = {"default:tin_ingot", "default:copper_ingot", "default:copper_ingot", "default:copper_ingot"}, + heat = 2, + time = 8, }) ironage.register_recipe({ output = "default:steel_ingot", - recipe = {"default:iron_lump"}, - heat = 4 + recipe = {"default:coal_lump", "default:iron_lump", "default:iron_lump", "default:iron_lump"}, + heat = 4, + time = 8, }) -minetest.clear_craft({output = "default:steel_ingot"}) + +minetest.clear_craft({output = "default:steel_ingot"}) +minetest.clear_craft({output = "default:bronze_ingot"}) diff --git a/textures/ironage_meridium_ingot.png b/textures/ironage_meridium_ingot.png new file mode 100644 index 0000000000000000000000000000000000000000..7bd3c1e8e908bdd1439074f71d3f1a2f2b80565a GIT binary patch literal 266 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!aez;VtHOm>%NJO#U+%Ddz5C%^ zL8lHXpF9wL^-S`eOPLR^<-U99@Z>?s`zKW&-*tTb)bsoM#J|5LZ?)PG2-MD4666=m z;PC858ivL>4nJa0`PlBg3pY5H=O_D8JJf)*y9^Us|F z3I%w&IEF}Ep4;mv)S$q@;OM(p;m`lsnnS@ZEt!}rf^zrJ?-`_;4c|07PIcE*w*zhDN3 zXE)M7oFs2|7lsa2Sq~tGv%n*=n1O*?7=#%aX3dcR3bL1Y`ns||VwD!uU}hAkoB$NE z^K@|xk+__kaDa7(Mc~gnOm{SD`0VQJL{xKR_SD$uoY8Qy+4IInW7mxxHv)d>ta(wR lruA7eaPPqrCmQ$}81BqtbP5r-cm*_x!PC{xWt~$(698FPQilKl literal 0 HcmV?d00001 diff --git a/textures/ironage_meridiumpick.png b/textures/ironage_meridiumpick.png new file mode 100644 index 0000000000000000000000000000000000000000..de24b64e9d9f474099a55f561c6fcad87b869c65 GIT binary patch literal 261 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFP2=EDUt!H2`QRKH%5wKPjaMl<1 zH{}hql!3p^r=85p>QL70(Y)*K0-AbW|YuPgf_R%ro!kuweq%Yj0Eo-U3d z9M_W*8kpCW)+em_T%NGzZ&tvyRqxpZ*gjXWavUx-bFqz9zFudbe7GU;F5?6T@{@_mGlLsZQpH+Q(=k)1aO>_%)r1c48n{Iv*t(u1=&kHeO=ifu}TYSawT5>Pzn@s z_jGX#k+{6}w6{=$0uS>A5qnXC#^3Y9%0kjhQp@xwGrV88WOsEqZ(j4lg3g&X&klL7 uv#J&I)=K&^&8F&Z?jE^g^=*=N#f-hFOgg7uU0Vw@lEKr}&t;ucLK6UI2UlDG literal 0 HcmV?d00001 diff --git a/textures/ironage_meridiumsword.png b/textures/ironage_meridiumsword.png new file mode 100644 index 0000000000000000000000000000000000000000..621568db81f7fd6c4b068ce2046af2d8deb9c269 GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFv3GfMV1=5!4LjI<_IiA8985xr& zPhPpi>d>CxGsk0JKdt%vw&nlN3EiekmjKlA%&K)~ zY6-kMlRFVdQ&MBb@02yFJ^#A|> literal 0 HcmV?d00001 diff --git a/tools.lua b/tools.lua new file mode 100644 index 0000000..d6e6b82 --- /dev/null +++ b/tools.lua @@ -0,0 +1,103 @@ +--[[ + + Iron Age + ======== + + Copyright (C) 2018 Joachim Stolberg + Based on mods/default/tools.lua + + LGPLv2.1+ + See LICENSE.txt for more information + +]]-- + + + +local function tools() + minetest.override_item("default:pick_bronze", { + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=1, + groupcaps={ + cracky = {times={[1]=4.00, [2]=1.60, [3]=0.80}, uses=20, maxlevel=2}, + }, + damage_groups = {fleshy=4}, + }, + }) + minetest.override_item("default:pick_steel", { + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=1, + groupcaps={ + cracky = {times={[1]=4.00, [2]=1.60, [3]=0.80}, uses=30, maxlevel=2}, + }, + damage_groups = {fleshy=4}, + }, + }) + + minetest.override_item("default:shovel_bronze", { + tool_capabilities = { + full_punch_interval = 1.1, + max_drop_level=1, + groupcaps={ + crumbly = {times={[1]=1.50, [2]=0.90, [3]=0.40}, uses=30, maxlevel=2}, + }, + damage_groups = {fleshy=3}, + }, + }) + minetest.override_item("default:shovel_steel", { + tool_capabilities = { + full_punch_interval = 1.1, + max_drop_level=1, + groupcaps={ + crumbly = {times={[1]=1.50, [2]=0.90, [3]=0.40}, uses=40, maxlevel=2}, + }, + damage_groups = {fleshy=3}, + }, + }) + + minetest.override_item("default:axe_bronze", { + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=1, + groupcaps={ + choppy={times={[1]=2.50, [2]=1.40, [3]=1.00}, uses=20, maxlevel=2}, + }, + damage_groups = {fleshy=4}, + }, + }) + minetest.override_item("default:axe_steel", { + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=1, + groupcaps={ + choppy={times={[1]=2.50, [2]=1.40, [3]=1.00}, uses=30, maxlevel=2}, + }, + damage_groups = {fleshy=4}, + }, + }) + + minetest.override_item("default:sword_bronze", { + tool_capabilities = { + full_punch_interval = 0.8, + max_drop_level=1, + groupcaps={ + snappy={times={[1]=2.5, [2]=1.20, [3]=0.35}, uses=30, maxlevel=2}, + }, + damage_groups = {fleshy=6}, + }, + }) + minetest.override_item("default:sword_steel", { + tool_capabilities = { + full_punch_interval = 0.8, + max_drop_level=1, + groupcaps={ + snappy={times={[1]=2.5, [2]=1.20, [3]=0.35}, uses=40, maxlevel=2}, + }, + damage_groups = {fleshy=6}, + }, + }) +end + +minetest.after(1, tools) +