New mod: multifurnace, in progress

This commit is contained in:
Evert Prants 2019-03-09 13:49:50 +02:00
parent 613c80d7e2
commit 488f94a970
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
19 changed files with 394 additions and 67 deletions

View File

@ -1,5 +1,5 @@
-- Fluidity for Minetest 5.0.0+
-- Copyright (c) 2018 Evert "Diamond" Prants <evert@lunasqu.ee>
-- Copyright (c) 2019 Evert "Diamond" Prants <evert@lunasqu.ee>
fluidity = rawget(_G, "fluidity") or {}
@ -13,6 +13,9 @@ end
-- Molten metals
dofile(mpath.."/molten.lua")
-- Meltable metals list
dofile(mpath.."/meltable.lua")
-- Florbs
dofile(mpath.."/florbs.lua")

53
fluidity/meltable.lua Normal file
View File

@ -0,0 +1,53 @@
fluidity.melts = {}
-- fluidity.molten_metals - metals
function fluidity.register_melt(item, metal, type)
if not fluidity.melts[metal] then
fluidity.melts[metal] = {}
end
if not fluidity.melts[metal][type] then
fluidity.melts[metal][type] = {}
end
table.insert(fluidity.melts[metal][type], item)
end
-- Autofind meltable
local autofind = {"ingot", "lump", "crystal", "ore", "block"}
local modfind = {"default", "technic", "moreores", "elepower_dynamics"}
function fluidity.auto_detect_metal_forms(metal, mod)
if mod then
local modfind = { [0] = mod }
end
for i, v in pairs(modfind) do
for j, k in pairs(autofind) do
local name = v .. ":" .. metal .. "_" .. k
if minetest.registered_items[name] then
fluidity.register_melt(name, metal, k)
end
end
end
end
-- Manually register default blocks, for now
fluidity.register_melt("default:mese", "mese", "block")
fluidity.register_melt("default:obsidian", "obsidian", "block")
fluidity.register_melt("default:goldblock", "gold", "block")
fluidity.register_melt("default:steelblock", "steel", "block")
fluidity.register_melt("default:copperblock", "copper", "block")
fluidity.register_melt("default:tinblock", "tin", "block")
-- Special snowflake
fluidity.register_melt("default:iron_lump", "steel", "lump")
-- Register melts after all mods have loaded
minetest.register_on_mods_loaded(function ()
for metal,_ in pairs(fluidity.molten_metals) do
fluidity.auto_detect_metal_forms(metal)
end
end)

View File

@ -1,3 +1,4 @@
name = fluidity
description = Adds Molten versions of commonly occuring metals. Supports default, technic, elepower and moreores.
depends = default,fluid_lib,bucket
depends = fluid_lib,bucket
optional_depends = default

View File

@ -154,7 +154,7 @@ local function get_cast_for(item)
local cast = nil
local typename = nil
for metal, types in pairs(metal_melter.melts) do
for metal, types in pairs(fluidity.melts) do
if typename ~= nil then break end
for t, items in pairs(types) do
if in_table(items, item) then
@ -179,7 +179,7 @@ local function find_castable(metal_name, cast_name)
local cast = metal_caster.casts[cast_name]
if not cast then return nil end
local types = metal_melter.melts[metal_name]
local types = fluidity.melts[metal_name]
if not types then return nil end
@ -444,7 +444,7 @@ function metal_caster.register_cast(name, data)
metal_caster.casts[name] = data
end
metal_melter.register_melt(castname, "gold", "cast")
fluidity.register_melt(castname, "gold", "cast")
end
local function on_receive_fields(pos, formname, fields, sender)

View File

@ -1,12 +1,9 @@
-- Metal Melter for Minetest 0.5.0+
-- Copyright (c) 2018 Evert "Diamond" Prants <evert@lunasqu.ee>
-- Metal Melter for Minetest 5.0.0+
-- Copyright (c) 2019 Evert "Diamond" Prants <evert@lunasqu.ee>
local modpath = minetest.get_modpath("metal_melter")
metal_melter = {}
-- Melting database
dofile(modpath.."/meltable.lua")
-- Crafting components
dofile(modpath.."/components.lua")

View File

@ -1,53 +0,0 @@
metal_melter.melts = {}
-- fluidity.molten_metals - metals
function metal_melter.register_melt(item, metal, type)
if not metal_melter.melts[metal] then
metal_melter.melts[metal] = {}
end
if not metal_melter.melts[metal][type] then
metal_melter.melts[metal][type] = {}
end
table.insert(metal_melter.melts[metal][type], item)
end
-- Autofind meltable
local autofind = {"ingot", "lump", "crystal", "ore", "block"}
local modfind = {"default", "technic", "moreores", "elepower_dynamics"}
function metal_melter.auto_detect_metal_forms(metal, mod)
if mod then
local modfind = { [0] = mod }
end
for i, v in pairs(modfind) do
for j, k in pairs(autofind) do
local name = v .. ":" .. metal .. "_" .. k
if minetest.registered_items[name] then
metal_melter.register_melt(name, metal, k)
end
end
end
end
-- Manually register default blocks, for now
metal_melter.register_melt("default:mese", "mese", "block")
metal_melter.register_melt("default:obsidian", "obsidian", "block")
metal_melter.register_melt("default:goldblock", "gold", "block")
metal_melter.register_melt("default:steelblock", "steel", "block")
metal_melter.register_melt("default:copperblock", "copper", "block")
metal_melter.register_melt("default:tinblock", "tin", "block")
-- Special snowflake
metal_melter.register_melt("default:iron_lump", "steel", "lump")
-- Register melts after all mods have loaded
minetest.register_on_mods_loaded(function ()
for metal,_ in pairs(fluidity.molten_metals) do
metal_melter.auto_detect_metal_forms(metal)
end
end)

View File

@ -35,7 +35,7 @@ function metal_melter.get_metal_from_stack(stack)
local metal = nil
local metal_type = nil
for mt, types in pairs(metal_melter.melts) do
for mt, types in pairs(fluidity.melts) do
if metal then break end
for tp,items in pairs(types) do
if in_table(items, stack) then

2
modpack.conf Normal file
View File

@ -0,0 +1,2 @@
name = melterns
description = Melting metals and creating tools

0
multifurnace/furnace.lua Normal file
View File

11
multifurnace/init.lua Normal file
View File

@ -0,0 +1,11 @@
-- Multifurnace for Minetest 5.0.0+
-- Copyright (c) 2019 Evert "Diamond" Prants <evert@lunasqu.ee>
multifurnace = rawget(_G, "multifurnace") or {}
local modpath = minetest.get_modpath(minetest.get_current_modname())
multifurnace.modpath = modpath
dofile(modpath .. "/furnace.lua")
dofile(modpath .. "/nodes.lua")
dofile(modpath .. "/crafting.lua")

3
multifurnace/mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = multifurnace
description = An advanced multi-node furnace used for melting, casting and alloying
depends = fluidity,metal_melter

View File

@ -0,0 +1,86 @@
# Blender v2.79 (sub 6) OBJ File: ''
# www.blender.org
o Cube.001
v -0.240000 -0.240000 -0.210000
v -0.240000 0.040000 -0.210000
v -0.240000 -0.240000 -1.000000
v -0.240000 0.040000 -1.000000
v 0.240000 -0.240000 -0.210000
v 0.240000 0.040000 -0.210000
v 0.240000 -0.240000 -1.000000
v 0.240000 0.040000 -1.000000
v -0.240000 -0.240000 0.090000
v -0.240000 0.040000 0.090000
v 0.240000 0.040000 0.090000
v 0.240000 -0.240000 0.090000
v -0.240000 -1.000000 -0.210000
v 0.240000 -1.000000 -0.210000
v -0.240000 -1.000000 0.090000
v 0.240000 -1.000000 0.090000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 0.000000 1.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 1.000000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 0.0000 1.0000
s off
f 1/1/1 2/2/1 4/3/1 3/4/1
f 3/5/2 4/6/2 8/7/2 7/8/2
f 7/9/3 8/10/3 6/11/3 5/12/3
f 6/13/4 2/2/4 10/14/4 11/15/4
f 3/5/5 7/16/5 5/17/5 1/18/5
f 8/19/4 4/6/4 2/20/4 6/21/4
f 12/22/6 11/23/6 10/14/6 9/24/6
f 5/25/3 6/26/3 11/27/3 12/28/3
f 2/29/1 1/30/1 9/31/1 10/32/1
f 5/25/3 12/33/3 16/34/3 14/35/3
f 13/36/5 14/37/5 16/34/5 15/38/5
f 12/22/6 9/39/6 15/40/6 16/41/6
f 1/1/2 5/42/2 14/43/2 13/44/2
f 9/45/1 1/30/1 13/46/1 15/38/1

224
multifurnace/nodes.lua Normal file
View File

@ -0,0 +1,224 @@
local FAUCET_PER_SECOND = 122
-- Node funtions
local function update_timer (pos)
local t = minetest.get_node_timer(pos)
if not t:is_started() then
t:start(1.0)
end
end
local function controller_timer (pos, elapsed)
local refresh = false
local meta = minetest.get_meta(pos)
return refresh
end
local function faucet_flow (pos, meta)
local angled = minetest.get_node(pos)
local back = vector.add(pos, minetest.facedir_to_dir(angled.param2))
local backnode = minetest.get_node(back)
local backreg = minetest.registered_nodes[backnode.name]
if not backreg.node_io_can_take_liquid or not backreg.node_io_can_take_liquid(back, backnode, "front")
or not backreg.node_io_take_liquid then
return false
end
local stack
if backreg.node_io_get_liquid_stack then
stack = backreg.node_io_get_liquid_stack(back, backnode, "front", 1)
end
if not stack or stack:is_empty() then
return false
end
return stack:get_name(), stack:get_count(), back
end
local function faucet_activate (pos)
local meta = minetest.get_meta(pos)
local source, amount, bhind = faucet_flow(pos, meta)
if meta:get_string("flowing") ~= "" then return false end
if not source or amount == 0 then return end
local e = minetest.add_entity(pos, "multifurnace:faucet_flow")
e:get_luaentity():set_faucet(pos)
e:get_luaentity():set_source(source)
meta:set_string("flowing", source)
meta:set_int("flowing_capacity", amount)
update_timer(pos)
end
local function faucet_timer (pos, elapsed)
local refresh = false
local meta = minetest.get_meta(pos)
local liquid = meta:get_string("flowing")
local source, amount, bhind = faucet_flow(pos, meta)
while true do
if liquid == "" then break end
if source ~= liquid or amount <= 0 then
liquid = ""
break
end
local bhindnode = minetest.get_node(bhind)
local bhindreg = minetest.registered_nodes[bhindnode.name]
local target = vector.subtract(pos, {x=0,y=1,z=0})
local tnode = minetest.get_node(target)
local treg = minetest.registered_nodes[tnode.name]
if not treg.node_io_can_put_liquid or not treg.node_io_can_put_liquid(target, tnode, "top")
or not treg.node_io_room_for_liquid then
liquid = ""
break
end
local flowcap = amount
if flowcap > FAUCET_PER_SECOND then
flowcap = FAUCET_PER_SECOND
end
local room = treg.node_io_room_for_liquid(target, tnode, "top", liquid, flowcap)
if room > 0 and treg.node_io_put_liquid then
local over = treg.node_io_put_liquid(target, tnode, "top", nil, liquid, room)
if treg.on_timer then
update_timer(target)
end
else
liquid = ""
break
end
bhindreg.node_io_take_liquid(bhind, bhindnode, "front", nil, source, room)
if bhindreg.on_timer then
update_timer(bhind)
end
refresh = true
break
end
meta:set_string("flowing", liquid)
return refresh
end
-- Node definitions
minetest.override_item("metal_melter:heated_bricks", {
groups = {cracky = 3, multifurnace = 1},
})
minetest.register_node("multifurnace:controller", {
description = "Multifurnace Controller",
tiles = {
"metal_melter_heatbrick.png", "metal_melter_heatbrick.png", "metal_melter_heatbrick.png",
"metal_melter_heatbrick.png", "metal_melter_heatbrick.png", "metal_melter_heatbrick.png^multifurnace_controller_face.png",
},
groups = {cracky = 3, multifurnace = 1},
paramtype2 = "facedir",
is_ground_content = false,
on_timer = controller_timer,
})
minetest.register_node("multifurnace:port", {
description = "Multifurnace Port",
tiles = {
"metal_melter_heatbrick.png", "metal_melter_heatbrick.png", "metal_melter_heatbrick.png",
"metal_melter_heatbrick.png", "metal_melter_heatbrick.png^multifurnace_intake_back.png",
"metal_melter_heatbrick.png^multifurnace_intake_face.png",
},
groups = {cracky = 3, multifurnace = 1},
paramtype2 = "facedir",
is_ground_content = false,
})
minetest.register_node("multifurnace:faucet", {
description = "Multifurnace Faucet",
tiles = {"metal_melter_heatbrick.png"},
groups = {cracky = 3, multifurnace_accessory = 1},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.1875, -0.1875, 0.1250, 0.1875, -0.1250, 0.5000},
{-0.1875, -0.1250, 0.1250, -0.1250, 0.06250, 0.5000},
{0.1250, -0.1250, 0.1250, 0.1875, 0.06250, 0.5000}
}
},
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
on_rightclick = faucet_activate,
on_timer = faucet_timer,
})
-- Entity definitions
minetest.register_entity("multifurnace:faucet_flow", {
initial_properties = {
physical = false,
collide_with_objects = false,
visual = "mesh",
mesh = "multifurnace_faucet_flow.obj",
visual_size = {x = 5, y = 5},
textures = {},
backface_culling = true,
pointable = false,
static_save = false,
},
faucet = nil,
source = "",
timer = 0,
set_faucet = function (self, faucet)
self.faucet = faucet
-- Set correct orientation in regards to the faucet
local node = minetest.get_node(faucet)
local orient = minetest.facedir_to_dir(node.param2)
orient = vector.multiply(orient, -1)
local angle = minetest.dir_to_yaw(orient)
self.object:set_yaw(angle)
end,
set_source = function (self, source)
self.source = source
-- Set appropriate fluid texture
local tiles = minetest.registered_nodes[source]
if not tiles.liquid_alternative_flowing then return end
local flowing = minetest.registered_nodes[tiles.liquid_alternative_flowing]
if not flowing.tiles or type(flowing.tiles[1]) ~= "string" then return end
self.object:set_properties({textures = {
flowing.tiles[1]
}})
end,
on_step = function (self, dt)
self.timer = self.timer + 1
-- Remove self when the faucet is destroyed or is no longer marked as flowing
if self.timer >= 10 then
local node = minetest.get_node(self.faucet)
if not node or node.name ~= "multifurnace:faucet" then
self.object:remove()
return
end
local meta = minetest.get_meta(self.faucet)
if meta:get_string("flowing") ~= self.source then
self.object:remove()
return
end
self.timer = 0
end
end
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

View File

@ -1,5 +1,5 @@
-- Tinkering for Minetest 0.5.0+
-- Copyright (c) 2018 Evert "Diamond" Prants <evert@lunasqu.ee>
-- Tinkering for Minetest 5.0.0+
-- Copyright (c) 2019 Evert "Diamond" Prants <evert@lunasqu.ee>
-- This mod is currently stuck behind https://github.com/minetest/minetest/issues/5686
-- Once this gets implemented, the full abilities of this mod will be available.

View File

@ -422,6 +422,6 @@ function tinkering.register_component(name, data)
})
-- Make all components meltable
metal_melter.register_melt(mod..":"..component, m, name)
fluidity.register_melt(mod..":"..component, m, name)
end
end