Alloy meridium with tools added
parent
dfe945089d
commit
63f51ea4dd
|
@ -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
|
||||
|
|
|
@ -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 = "",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
default
|
||||
fire
|
||||
farming
|
||||
intllib?
|
||||
unified_inventory
|
||||
wielded_light?
|
||||
unified_inventory?
|
||||
|
|
65
init.lua
65
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(),
|
||||
})
|
||||
|
||||
|
|
|
@ -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'},
|
||||
{''},
|
||||
}
|
||||
})
|
BIN
locale/de.mo
BIN
locale/de.mo
Binary file not shown.
31
locale/de.po
31
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"
|
||||
|
|
|
@ -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 <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\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 ""
|
||||
|
|
211
meltingpot.lua
211
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
|
||||
|
||||
|
|
|
@ -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,
|
||||
})
|
25
recipes.lua
25
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"})
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 266 B |
Binary file not shown.
After Width: | Height: | Size: 248 B |
Binary file not shown.
After Width: | Height: | Size: 261 B |
Binary file not shown.
After Width: | Height: | Size: 257 B |
Binary file not shown.
After Width: | Height: | Size: 230 B |
|
@ -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)
|
||||
|
Loading…
Reference in New Issue