SMELTER is now used for alloy recipes
parent
1c6dac3461
commit
7437bab301
|
@ -0,0 +1,80 @@
|
|||
=== Crafter MOD for MINETEST-C55 ===
|
||||
by Master Gollum
|
||||
|
||||
Introduction:
|
||||
|
||||
This is an utility MOD, itself does nothing. Clones the crafting
|
||||
definition system to allow new MOD developers to create their
|
||||
own craft systems. For example a pottery wheel to do items with
|
||||
clay, a mill to produce flour from cereals, etc.
|
||||
|
||||
How it works?
|
||||
It give you 2 functions crafter.register_craft(craft) and
|
||||
crafter.get_craft_result(data). The main difference with the
|
||||
default ones is that they are not restricted for the method
|
||||
name, you can use whatever name you want and create a new
|
||||
family of crafts. They are used exactly as the default ones
|
||||
are used, with the exception that register_craft requires
|
||||
the method property.
|
||||
|
||||
Example:
|
||||
|
||||
-- In the list of definitions
|
||||
crafter.register_craft({
|
||||
type = 'pottery',
|
||||
output = 'potter:awasome_jar',
|
||||
recipe = {
|
||||
{'default:clay_lump','default:clay_lump'},
|
||||
{'default:clay_lump','default:clay_lump'},
|
||||
}
|
||||
})
|
||||
|
||||
-- Inside your the abm of your crafter node
|
||||
local shape = inv:get_list("shape")
|
||||
crafter.get_craft_result({method = "pottery", width = 4, items = shape})
|
||||
|
||||
|
||||
Release Notes
|
||||
|
||||
Version 0.1
|
||||
Initial version
|
||||
|
||||
PS: This document has been structured as the README.txt of PilzAdam in
|
||||
his Bed MOD.
|
||||
|
||||
How to install:
|
||||
Unzip the archive an place it in minetest-base-directory/mods/minetest/
|
||||
if you have a windows client or a linux run-in-place client. If you
|
||||
have a linux system-wide instalation place it in
|
||||
~/.minetest/mods/minetest/.
|
||||
If you want to install this mod only in one world create the folder
|
||||
worldmods/ in your worlddirectory.
|
||||
For further information or help see:
|
||||
http://wiki.minetest.com/wiki/Installing_Mods
|
||||
|
||||
|
||||
License:
|
||||
Sourcecode: WTFPL (see below)
|
||||
Graphics: WTFPL (see below)
|
||||
|
||||
See also:
|
||||
http://minetest.net/
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
crafter={
|
||||
debug=false,
|
||||
crafts={},
|
||||
empty={item=ItemStack(nil),time=0}
|
||||
}
|
||||
|
||||
function crafter.register_craft(craft)
|
||||
assert(craft.type ~= nil and craft.recipe ~= nil and craft.output ~= nil,
|
||||
"Invalid craft definition, it must have type, recipe and output")
|
||||
assert(type(craft.recipe)=="table" and type(craft.recipe[1])=="table","'recipe' must be a bidimensional table")
|
||||
minetest.log("verbose","registerCraft ("..craft.type..", output="..craft.output.." recipe="..dump(craft.recipe))
|
||||
craft._h=#craft.recipe
|
||||
craft._w=#craft.recipe[1]
|
||||
-- TODO check that all the arrays have the same length...
|
||||
crafter.crafts[#crafter.crafts+1]=craft
|
||||
end
|
||||
|
||||
function crafter.get_craft_result(data)
|
||||
assert(data.method ~= nil and data.items ~= nil, "Invalid call, method and items must be provided")
|
||||
local w = 1
|
||||
if data.width ~= nil and data.width>0 then
|
||||
w=data.width
|
||||
end
|
||||
local r=nil
|
||||
for zz,craft in ipairs(crafter.crafts) do
|
||||
r=crafter._check_craft(data,w,craft)
|
||||
if r ~= nil then
|
||||
if crafter.debug then
|
||||
print("Craft found, returning "..dump(r.item))
|
||||
end
|
||||
return r
|
||||
end
|
||||
end
|
||||
return crafter.empty
|
||||
end
|
||||
|
||||
function crafter._check_craft(data,w,c)
|
||||
if c.type == data.method then
|
||||
-- Here we go..
|
||||
for i=1,w-c._h+1 do
|
||||
for j=1,w-c._w+1 do
|
||||
local p=(i-1)*w+j
|
||||
if crafter.debug then
|
||||
print("Checking data.items["..dump(i).."]["..dump(j).."]("..dump(p)..")="..dump(data.items[p]:get_name()).." vs craft.recipe[1][1]="..dump(c.recipe[1][1]))
|
||||
end
|
||||
if data.items[p]:get_name() == c.recipe[1][1] then
|
||||
for m=1,c._h do
|
||||
for n=1,c._w do
|
||||
local q=(i+m-1-1)*w+j+n-1
|
||||
if crafter.debug then
|
||||
print(" Checking data.items["..dump(i+m-1).."]["..dump(j+n-1).."]("..dump(q)..")="..dump(data.items[q]:get_name())..
|
||||
" vs craft.recipe["..dump(m).."]["..dump(n).."]="..dump(c.recipe[m][n]))
|
||||
end
|
||||
if c.recipe[m][n] ~= data.items[q]:get_name() then
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
-- found! we still must check that is not any other stuff outside the limits of the recipe sizes...
|
||||
-- Checking at right of the matching square
|
||||
for m=i-c._h+1+1,w do
|
||||
for n=j+c._w,w do
|
||||
local q=(m-1)*w+n
|
||||
if crafter.debug then
|
||||
print(" Checking right data.items["..dump(m).."]["..dump(n).."]("..dump(q)..")="..dump(data.items[q]:get_name()))
|
||||
end
|
||||
if data.items[q]:get_name() ~= "" then
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Checking at left of the matching square (the first row has been already scanned)
|
||||
for m=i-c._h+1+1+1,w do
|
||||
for n=1,j-1 do
|
||||
local q=(m-1)*w+n
|
||||
if crafter.debug then
|
||||
print(" Checking left data.items["..dump(m).."]["..dump(n).."]("..dump(q)..")="..dump(data.items[q]:get_name()))
|
||||
end
|
||||
if data.items[q]:get_name() ~= "" then
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Checking at bottom of the matching square
|
||||
for m=i+c._h,w do
|
||||
for n=j,j+c._w do
|
||||
local q=(m-1)*w+n
|
||||
if crafter.debug then
|
||||
print(" Checking bottom data.items["..dump(m).."]["..dump(n).."]("..dump(q)..")="..dump(data.items[q]:get_name()))
|
||||
end
|
||||
if data.items[q]:get_name() ~= "" then
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
if crafter.debug then
|
||||
print("Craft found! "..c.output)
|
||||
end
|
||||
return {item=ItemStack(c.output),time=1}
|
||||
elseif data.items[p] ~= nil and data.items[p]:get_name() ~= "" then
|
||||
if crafter.debug then
|
||||
print("Invalid data item "..dump(data.items[p]:get_name()))
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -280,7 +280,7 @@ for i=1, #metals.list do
|
|||
inventory_image = "metals_"..metals.list[i].."_block.png^doors_grey.png",
|
||||
groups = {snappy=1,cracky=2},
|
||||
tiles_bottom = {"metals_"..metals.list[i].."_block.png"},
|
||||
tiles_top = {"hatches_"..metals.list[i].."_hatch.png"},
|
||||
tiles_top = {"metals_"..metals.list[i].."_block.png"},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "doors:door_"..metals.list[i],
|
||||
|
|
|
@ -331,88 +331,125 @@ for i, mineral in ipairs(minerals.list) do
|
|||
end
|
||||
|
||||
--
|
||||
-- Alloys
|
||||
-- Alloys (needs smelter)
|
||||
--
|
||||
|
||||
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "metals:oroide_unshaped 4",
|
||||
recipe = {"metals:copper_unshaped", "metals:copper_unshaped", "metals:tin_unshaped", "metals:zinc_unshaped"},
|
||||
recipe = {
|
||||
{"metals:copper_unshaped","metals:copper_unshaped"},
|
||||
{"metals:tin_unshaped","metals:zinc_unshaped"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "metals:tumbaga_unshaped 4",
|
||||
recipe = {"metals:copper_unshaped", "metals:copper_unshaped", "metals:gold_unshaped", "metals:gold_unshaped"},
|
||||
recipe = {
|
||||
{"metals:copper_unshaped","metals:copper_unshaped"},
|
||||
{"metals:gold_unshaped","metals:gold_unshaped"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "metals:monel_unshaped 4",
|
||||
recipe = {"metals:nickel_unshaped", "metals:nickel_unshaped", "metals:nickel_unshaped", "metals:copper_unshaped"},
|
||||
recipe = {
|
||||
{"metals:nickel_unshaped","metals:nickel_unshaped"},
|
||||
{"metals:nickel_unshaped","metals:copper_unshaped"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "metals:german_silver_unshaped 4",
|
||||
recipe = {"metals:copper_unshaped", "metals:copper_unshaped", "metals:copper_unshaped", "metals:nickel_unshaped"},
|
||||
recipe = {
|
||||
{"metals:copper_unshaped","metals:copper_unshaped"},
|
||||
{"metals:copper_unshaped","metals:nickel_unshaped"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "metals:albata_unshaped 4",
|
||||
recipe = {"metals:copper_unshaped", "metals:nickel_unshaped", "metals:zinc_unshaped", "metals:zinc_unshaped"},
|
||||
recipe = {
|
||||
{"metals:copper_unshaped","metals:nickel_unshaped"},
|
||||
{"metals:zinc_unshaped","metals:zinc_unshaped"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "metals:steel_unshaped 4",
|
||||
recipe = {"metals:wrought_iron_unshaped", "metals:wrought_iron_unshaped", "metals:wrought_iron_unshaped", "metals:pig_iron_unshaped"},
|
||||
recipe = {
|
||||
{"metals:wrought_iron_unshaped","metals:wrought_iron_unshaped"},
|
||||
{"metals:wrought_iron_unshaped","metals:pig_iron_unshaped"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "metals:brass_unshaped 4",
|
||||
recipe = {"metals:copper_unshaped", "metals:copper_unshaped", "metals:copper_unshaped", "metals:zinc_unshaped"},
|
||||
recipe = {
|
||||
{"metals:copper_unshaped","metals:copper_unshaped"},
|
||||
{"metals:copper_unshaped","metals:zinc_unshaped"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "metals:sterling_silver_unshaped 4",
|
||||
recipe = {"metals:silver_unshaped", "metals:silver_unshaped", "metals:silver_unshaped", "metals:copper_unshaped"},
|
||||
recipe = {
|
||||
{"metals:silver_unshaped","metals:silver_unshaped"},
|
||||
{"metals:silver_unshaped","metals:copper_unshaped"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "metals:rose_gold_unshaped 4",
|
||||
recipe = {"metals:gold_unshaped", "metals:gold_unshaped", "metals:gold_unshaped", "metals:brass_unshaped"},
|
||||
recipe = {
|
||||
{"metals:gold_unshaped","metals:gold_unshaped"},
|
||||
{"metals:gold_unshaped","metals:brass_unshaped"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "metals:black_bronze_unshaped 4",
|
||||
recipe = {"metals:copper_unshaped", "metals:copper_unshaped", "metals:gold_unshaped", "metals:silver_unshaped"},
|
||||
recipe = {
|
||||
{"metals:copper_unshaped","metals:copper_unshaped"},
|
||||
{"metals:gold_unshaped","metals:silver_unshaped"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "metals:bismuth_bronze_unshaped 4",
|
||||
recipe = {"metals:copper_unshaped", "metals:copper_unshaped", "metals:bismuth_unshaped", "metals:tin_unshaped"}
|
||||
recipe = {
|
||||
{"metals:copper_unshaped","metals:copper_unshaped"},
|
||||
{"metals:bismuth_unshaped","metals:tin_unshaped"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "metals:bronze_unshaped 4",
|
||||
recipe = {"metals:copper_unshaped", "metals:copper_unshaped", "metals:copper_unshaped", "metals:tin_unshaped"}
|
||||
recipe = {
|
||||
{"metals:copper_unshaped","metals:copper_unshaped"},
|
||||
{"metals:copper_unshaped","metals:tin_unshaped"}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "metals:black_steel_unshaped 4",
|
||||
recipe = {"metals:steel_unshaped", "metals:steel_unshaped", "metals:nickel_unshaped", "metals:black_bronze_unshaped"}
|
||||
recipe = {
|
||||
{"metals:steel_unshaped","metals:steel_unshaped"},
|
||||
{"metals:nickel_unshaped","metals:black_bronze_unshaped"}
|
||||
}
|
||||
})
|
||||
|
||||
--
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
=== Crafter MOD for MINETEST-C55 ===
|
||||
by Master Gollum
|
||||
|
||||
Introduction:
|
||||
|
||||
This MOD introduces a new kind of Furnace called Smelter.
|
||||
It is intended for provide a mean for smelt materials, for
|
||||
example to create alloys in a more realistic way.
|
||||
This MOD adds also a new kind of crafts (smelting) with a
|
||||
2x2 grid.
|
||||
|
||||
|
||||
The first release transform iron_ore in iron_ingot also
|
||||
iron_ingot + coal_lump in steel_ingot as example of
|
||||
uses.
|
||||
|
||||
CRAFT for a Smelter
|
||||
[cobble] [cobble] [cobble]
|
||||
[cobble] [furnace] [cobble]
|
||||
[cobble] [cobble] [cobble]
|
||||
|
||||
For developers:
|
||||
|
||||
Anyone that intends to define a new smelting they MUST
|
||||
be registered with the crafter MOD.
|
||||
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "smelter:iron_ingot",
|
||||
recipe = {
|
||||
{"default:iron_lump"}
|
||||
}
|
||||
})
|
||||
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "default:steel_ingot",
|
||||
recipe = {
|
||||
{"smelter:iron_ingot"},
|
||||
{"default:coal_lump"}
|
||||
}
|
||||
})
|
||||
|
||||
Depends
|
||||
default
|
||||
crafter
|
||||
|
||||
|
||||
Release Notes
|
||||
|
||||
Version 0.1
|
||||
Initial version
|
||||
|
||||
PS: This document has been structured as the README.txt of PilzAdam in
|
||||
his Bed MOD.
|
||||
|
||||
How to install:
|
||||
Unzip the archive an place it in minetest-base-directory/mods/minetest/
|
||||
if you have a windows client or a linux run-in-place client. If you
|
||||
have a linux system-wide instalation place it in
|
||||
~/.minetest/mods/minetest/.
|
||||
If you want to install this mod only in one world create the folder
|
||||
worldmods/ in your worlddirectory.
|
||||
For further information or help see:
|
||||
http://wiki.minetest.com/wiki/Installing_Mods
|
||||
|
||||
|
||||
License:
|
||||
Sourcecode: WTFPL (see below)
|
||||
Graphics: WTFPL (see below)
|
||||
|
||||
See also:
|
||||
http://minetest.net/
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
default
|
||||
crafter
|
||||
metals
|
|
@ -0,0 +1,205 @@
|
|||
smelter={}
|
||||
|
||||
|
||||
smelter.smelter_formspec =
|
||||
"size[8,7]"..
|
||||
"image[4,1;1,1;default_furnace_fire_bg.png]"..
|
||||
"list[current_name;fuel;3,1;1,1;]"..
|
||||
"list[current_name;src;0,0;2,2;]"..
|
||||
"list[current_name;dst;6,0;2,2;]"..
|
||||
"list[current_player;main;0,3;8,4;]"
|
||||
|
||||
minetest.register_node("smelter:smelter", {
|
||||
description = "Smelter",
|
||||
tiles = {"smelter_smelter_top.png", "smelter_smelter_base.png", "smelter_smelter_side.png",
|
||||
"smelter_smelter_side.png", "smelter_smelter_side.png", "smelter_smelter_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec", smelter.smelter_formspec)
|
||||
meta:set_string("infotext", "Smelter")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("fuel", 1)
|
||||
inv:set_size("src", 4)
|
||||
inv:set_size("dst", 4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("fuel") then
|
||||
return false
|
||||
elseif not inv:is_empty("dst") then
|
||||
return false
|
||||
elseif not inv:is_empty("src") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("smelter:smelter_active", {
|
||||
description = "Smelter",
|
||||
tiles = {"smelter_smelter_top.png", "smelter_smelter_base.png", "smelter_smelter_side.png",
|
||||
"smelter_smelter_side.png", "smelter_smelter_side.png", "smelter_smelter_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
light_source = 8,
|
||||
drop = "smelter:smelter",
|
||||
groups = {cracky=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec", smelter.smelter_formspec)
|
||||
meta:set_string("infotext", "Smelter");
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("fuel", 1)
|
||||
inv:set_size("src", 4)
|
||||
inv:set_size("dst", 4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("fuel") then
|
||||
return false
|
||||
elseif not inv:is_empty("dst") then
|
||||
return false
|
||||
elseif not inv:is_empty("src") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"smelter:smelter","smelter:smelter_active"},
|
||||
interval = 2.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
-- Init the values
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
for i, name in ipairs({
|
||||
"fuel_totaltime",
|
||||
"fuel_time",
|
||||
"src_totaltime",
|
||||
"src_time"
|
||||
}) do
|
||||
if meta:get_string(name) == "" then
|
||||
meta:set_float(name, 0.0)
|
||||
end
|
||||
end
|
||||
|
||||
-- Get the source materials
|
||||
local inv = meta:get_inventory()
|
||||
local srclist = inv:get_list("src")
|
||||
local cooked = nil
|
||||
if srclist then
|
||||
cooked = crafter.get_craft_result({method = "smelting", width = 2, items = srclist})
|
||||
--cooked = default.get_craft_result({method = "cooking", width = 1, items = srclist})
|
||||
end
|
||||
|
||||
local was_active = false
|
||||
local consume = false
|
||||
print("Fuel time: "..dump(meta:get_float("fuel_time")))
|
||||
print("Fuel totaltime: "..dump(meta:get_float("fuel_totaltime")))
|
||||
|
||||
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
||||
was_active = true
|
||||
meta:set_float("fuel_time", meta:get_float("fuel_time") + 1)
|
||||
meta:set_float("src_time", meta:get_float("src_time") + 1)
|
||||
if cooked and cooked.item and not cooked.item:is_empty() and meta:get_float("src_time") >= cooked.time then
|
||||
-- check if there's room for output in "dst" list
|
||||
if inv:room_for_item("dst",cooked.item) then
|
||||
consume = true
|
||||
-- Put result in "dst" list
|
||||
inv:add_item("dst", cooked.item)
|
||||
-- take stuff from "src" list
|
||||
for i=1,4 do
|
||||
srcstack = inv:get_stack("src", i)
|
||||
if not srcstack:is_empty() then
|
||||
print("Removing "..srcstack:get_name())
|
||||
srcstack:take_item(1)
|
||||
inv:set_stack("src", i, srcstack)
|
||||
end
|
||||
end
|
||||
else
|
||||
print("Could not insert '"..cooked.item:to_string().."'")
|
||||
end
|
||||
meta:set_string("src_time", 0)
|
||||
end
|
||||
end
|
||||
|
||||
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
||||
local percent = math.floor(meta:get_float("fuel_time") /
|
||||
meta:get_float("fuel_totaltime") * 100)
|
||||
meta:set_string("infotext","Smelter active: "..percent.."%")
|
||||
hacky_swap_node(pos,"smelter:smelter_active")
|
||||
meta:set_string("formspec",
|
||||
"size[8,7]"..
|
||||
"image[4,1;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
||||
(100-percent)..":default_furnace_fire_fg.png]"..
|
||||
"list[current_name;fuel;3,1;1,1;]"..
|
||||
"list[current_name;src;0,0;2,2;]"..
|
||||
"list[current_name;dst;6,0;2,2;]"..
|
||||
"list[current_player;main;0,3;8,4;]")
|
||||
return
|
||||
end
|
||||
|
||||
local fuel = nil
|
||||
local cooked = nil
|
||||
local fuellist = inv:get_list("fuel")
|
||||
local srclist = inv:get_list("src")
|
||||
|
||||
if srclist then
|
||||
cooked = crafter.get_craft_result({method = "smelting", width = 2, items = srclist})
|
||||
end
|
||||
if fuellist then
|
||||
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
|
||||
end
|
||||
|
||||
if fuel.time <= 0 then
|
||||
meta:set_string("infotext","Smelter out of fuel")
|
||||
hacky_swap_node(pos,"smelter:smelter")
|
||||
meta:set_string("formspec", smelter.smelter_formspec)
|
||||
return
|
||||
end
|
||||
|
||||
if cooked.item:is_empty() then
|
||||
if was_active then
|
||||
meta:set_string("infotext","Smelter is empty")
|
||||
hacky_swap_node(pos,"smelter:smelter")
|
||||
meta:set_string("formspec", smelter.smelter_formspec)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
meta:set_string("fuel_totaltime", fuel.time)
|
||||
meta:set_string("fuel_time", 0)
|
||||
if consume then
|
||||
local stack = inv:get_stack("fuel", 1)
|
||||
stack:take_item()
|
||||
inv:set_stack("fuel", 1, stack)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'smelter:smelter',
|
||||
recipe = {
|
||||
{'default:brick', 'default:brick', 'default:brick'},
|
||||
{'default:brick', '', 'default:brick'},
|
||||
{'default:stone_slab', 'default:stone_slab', 'default:stone_slab'},
|
||||
}
|
||||
})
|
||||
|
||||
crafter.register_craft({
|
||||
type = "smelting",
|
||||
output = "default:bronze_ingot",
|
||||
recipe = {
|
||||
{"default:copper_ingot"},
|
||||
{"default:steel_ingot"}
|
||||
}
|
||||
})
|
Binary file not shown.
After Width: | Height: | Size: 835 B |
Binary file not shown.
After Width: | Height: | Size: 817 B |
Binary file not shown.
After Width: | Height: | Size: 894 B |
Binary file not shown.
After Width: | Height: | Size: 798 B |
Binary file not shown.
After Width: | Height: | Size: 663 B |
Loading…
Reference in New Issue