support new craftguide api

This commit is contained in:
Evert Prants 2018-12-17 12:46:13 +02:00
parent 347e5f67d1
commit 339043bbac
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
14 changed files with 328 additions and 15 deletions

View File

@ -1,4 +1,5 @@
local have_ui = minetest.get_modpath("unified_inventory")
local have_cg = minetest.get_modpath("craftguide") and craftguide and craftguide.register_craft
elepm.craft = {}
elepm.craft.types = {}
@ -11,6 +12,11 @@ function elepm.register_craft_type(name, def)
gui_name = def.gui_name,
}
elepm.craft[name] = {}
-- Don't register cooking or fuel types externally.
if name == "cooking" or name == "fuel" then return end
if have_ui and unified_inventory.register_craft_type then
unified_inventory.register_craft_type(name, {
description = def.description or name,
@ -19,7 +25,13 @@ function elepm.register_craft_type(name, def)
})
end
elepm.craft[name] = {}
if have_cg then
craftguide.register_craft_type(name, {
description = def.description,
icon = def.icon or "elepower_alloy_furnace.png",
width = def.inputs or 2,
})
end
end
function elepm.register_craft(craftdef)
@ -63,32 +75,65 @@ function elepm.register_craft(craftdef)
time = time
}
if have_ui then
if have_ui or have_cg then
local spec = {}
for item, count in pairs(recipe.recipe) do
spec[#spec+1] = ItemStack(item .. " " .. count)
end
local items = {}
for itm,q in pairs(recipe.recipe) do
local itmn = itm
if q > 1 then itmn = itmn .. " " .. q end
items[#items+1] = itmn
end
if type(recipe.output) == "table" then
for _,itm in pairs(recipe.output) do
local itmst = ItemStack(itm)
unified_inventory.register_craft({
type = craftdef.type,
output = itmst,
items = spec,
width = 0,
})
if have_ui then
unified_inventory.register_craft({
type = craftdef.type,
output = itmst,
items = spec,
width = 0,
})
end
if have_cg then
local iname = itm
if type(iname) == "userdata" then iname = iname:get_name() end
craftguide.register_craft({
type = craftdef.type,
output = iname,
items = items,
})
end
end
return
end
unified_inventory.register_craft({
type = craftdef.type,
output = recipe.output,
items = spec,
width = 0,
})
if have_ui then
unified_inventory.register_craft({
type = craftdef.type,
output = recipe.output,
items = spec,
width = 0,
})
end
if have_cg then
local iname = recipe.output
if type(iname) == "userdata" then iname = iname:get_name() end
craftguide.register_craft({
type = craftdef.type,
output = iname,
items = items,
})
end
end
table.insert(elepm.craft[ctype], recipe)

View File

@ -1,2 +1,3 @@
elepower_dynamics
unified_inventory?
craftguide?

View File

@ -1,6 +1,7 @@
elepm.register_craft_type("can", {
description = "Canning",
icon = "elepower_canning_machine.png",
inputs = 2,
})

View File

@ -1,6 +1,7 @@
elepm.register_craft_type("compress", {
description = "Compressing",
icon = "elepower_compressor.png",
inputs = 1,
})

View File

@ -31,3 +31,4 @@ dofile(mp .. "electrolyzer.lua")
dofile(mp .. "accumulator.lua")
dofile(mp .. "lava_cooler.lua")
dofile(mp .. "bucketer.lua")
dofile(mp .. "pump.lua")

View File

@ -1,6 +1,7 @@
elepm.register_craft_type("grind", {
description = "Grinding",
icon = "elepower_grinder.png",
inputs = 1,
})

View File

@ -0,0 +1,31 @@
ele.register_machine("elepower_machines:pump", {
description = "Pump",
tiles = {
"elepower_machine_top.png^elepower_power_port.png", "elepower_pump_base.png", "elepower_pump_side.png",
"elepower_pump_side.png", "elepower_pump_side.png", "elepower_pump_side.png",
},
groups = {
ele_machine = 1,
ele_user = 1,
fluid_container = 1,
oddly_breakable_by_hand = 1,
},
ele_no_automatic_ports = true,
fluid_buffers = {
pump = {
capacity = 16000,
drainable = true,
},
},
})
minetest.register_entity("elepower_machines:pump_tube", {
initial_properties = {
hp_max = 1,
visual = "mesh",
mesh = "elepower_pump_tube.obj",
physical = true,
textures = {"elepower_pump_tube.png"}
}
})

View File

@ -3,6 +3,7 @@ elepm.register_craft_type("saw", {
description = "Sawmilling",
inputs = 1,
gui_name = "elepower_saw",
icon = "elepower_sawmill.png",
})
elepm.register_crafter("elepower_machines:sawmill", {

View File

@ -2,6 +2,7 @@
elepm.register_craft_type("solder", {
description = "Soldering",
inputs = 3,
icon = "elepower_solderer.png",
})
elepm.register_crafter("elepower_machines:solderer", {

View File

@ -1,4 +1,4 @@
name = elepower_machines
description = Elepower machinery!
depends = elepower_dynamics
optional_depends = unified_inventory
optional_depends = unified_inventory,craftguide

View File

@ -0,0 +1,230 @@
# Blender v2.79 (sub 0) OBJ File: ''
# www.blender.org
o Cube
v 1.555200 -5.062500 1.555200
v 1.555200 5.062500 1.555200
v 1.555200 5.062500 2.592000
v 1.555200 -5.062500 2.592000
v -1.555200 -5.062500 -1.555200
v -1.555200 5.062500 -1.555200
v -1.555200 5.062500 -2.592000
v -1.555200 -5.062500 -2.592000
v -2.592000 -5.062500 -1.555200
v -2.592000 5.062500 -1.555200
v 2.592000 -5.062500 1.555200
v 2.592000 5.062500 1.555200
v -1.555200 5.062500 1.555200
v -1.555200 5.062500 2.592000
v -0.518400 5.062500 2.592000
v 0.518400 5.062500 2.592000
v 2.592000 5.062500 0.518400
v 2.592000 5.062500 -0.518400
v 2.592000 5.062500 -1.555200
v 1.555200 5.062500 -1.555200
v 1.555200 5.062500 -2.592000
v 0.518400 5.062500 -2.592000
v -0.518400 5.062500 -2.592000
v -2.592000 5.062500 -0.518400
v -2.592000 5.062500 0.518400
v -2.592000 5.062500 1.555200
v -2.592000 -5.062500 -0.518400
v -2.592000 -5.062500 0.518400
v -2.592000 -5.062500 1.555200
v -1.555200 -5.062500 1.555200
v -1.555200 -5.062500 2.592000
v 2.592000 -5.062500 0.518400
v 2.592000 -5.062500 -0.518400
v 2.592000 -5.062500 -1.555200
v 1.555200 -5.062500 -2.592000
v 0.518400 -5.062500 -2.592000
v -0.518400 -5.062500 -2.592000
v -0.518400 -5.062500 2.592000
v 0.518400 -5.062500 2.592000
v 1.555200 -5.062500 -1.555200
vt 0.937500 0.000000
vt 1.000000 0.500000
vt 0.937500 0.500000
vt 0.500000 0.000000
vt 0.562500 0.500000
vt 0.500000 0.500000
vt 0.687500 0.000000
vt 0.625000 0.500000
vt 0.625000 0.000000
vt 0.750000 0.500000
vt 0.812500 0.000000
vt 0.812500 0.500000
vt 0.125000 0.640000
vt 0.062500 0.640000
vt 0.062500 0.576000
vt 0.375000 0.000000
vt 0.437500 0.000000
vt 0.375000 0.500000
vt 0.875000 0.500000
vt 0.937500 0.000000
vt 0.937500 0.500000
vt 0.437500 0.500000
vt 0.375000 0.500000
vt 0.437500 0.000000
vt 0.750000 0.000000
vt 0.812500 0.000000
vt 0.812500 0.500000
vt 0.562500 0.000000
vt 0.625000 0.000000
vt 0.625000 0.500000
vt 0.250000 0.064000
vt 0.250000 0.256000
vt 0.062500 0.256000
vt 0.562500 0.000000
vt 0.625000 0.500000
vt 0.562500 0.500000
vt 0.687500 0.000000
vt 0.750000 0.500000
vt 0.687500 0.500000
vt 1.000000 0.000000
vt 0.937500 0.500000
vt 0.937500 0.000000
vt 1.000000 0.000000
vt 0.562500 0.000000
vt 0.687500 0.500000
vt 0.750000 0.000000
vt 0.250000 0.384000
vt 0.312500 0.384000
vt 0.312500 0.448000
vt 0.312500 0.512000
vt 0.312500 0.576000
vt 0.250000 0.576000
vt 0.187500 0.320000
vt 0.250000 0.320000
vt 0.062500 0.320000
vt 0.125000 0.320000
vt 0.062500 0.384000
vt 0.000000 0.448000
vt 0.000000 0.384000
vt 0.250000 0.640000
vt 0.187500 0.640000
vt 0.000000 0.512000
vt 0.000000 0.576000
vt 0.500000 0.000000
vt 0.500000 0.500000
vt 0.437500 0.500000
vt 0.312500 0.500000
vt 0.312500 0.000000
vt 0.875000 0.000000
vt 0.312500 0.500000
vt 0.312500 0.000000
vt 0.375000 0.000000
vt 0.500000 0.000000
vt 0.500000 0.500000
vt 0.875000 0.000000
vt 0.875000 0.500000
vt 0.750000 0.500000
vt 0.687500 0.500000
vt 0.687500 0.000000
vt 0.687500 0.000000
vt 0.687500 0.500000
vt 0.562500 0.500000
vt 0.500000 0.500000
vt 0.500000 0.000000
vt 0.125000 0.320000
vt 0.062500 0.320000
vt 0.000000 0.256000
vt 0.000000 0.192000
vt 0.000000 0.128000
vt 0.000000 0.064000
vt 0.062500 0.064000
vt 0.187500 0.320000
vt 0.250000 0.320000
vt 0.312500 0.192000
vt 0.312500 0.256000
vt 0.312500 0.064000
vt 0.312500 0.128000
vt 0.062500 0.000000
vt 0.125000 0.000000
vt 0.187500 0.000000
vt 0.250000 0.000000
vt 0.625000 0.000000
vt 0.750000 0.000000
vt 1.000000 0.500000
vn 1.0000 0.0000 0.0000
vn -1.0000 -0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 -0.0000 1.0000
vn 0.0000 1.0000 0.0000
vn 0.0000 -1.0000 0.0000
s 1
f 2/1/1 4/2/1 1/3/1
f 6/4/2 8/5/2 5/6/2
f 9/7/3 6/8/3 5/9/3
f 11/10/4 2/11/4 1/12/4
f 18/13/5 19/14/5 20/15/5
f 25/16/2 24/17/2 28/18/2
f 31/19/2 13/20/2 30/21/2
f 18/22/1 17/23/1 33/24/1
f 23/25/3 22/26/3 36/27/3
f 16/28/4 15/29/4 38/30/4
f 1/31/6 30/32/6 5/33/6
f 20/34/3 34/35/3 40/36/3
f 13/37/4 29/38/4 30/39/4
f 35/40/1 20/41/1 40/42/1
f 2/1/1 3/43/1 4/2/1
f 6/4/2 7/44/2 8/5/2
f 9/7/3 10/45/3 6/8/3
f 11/10/4 12/46/4 2/11/4
f 13/47/5 14/48/5 15/49/5
f 16/50/5 3/51/5 2/52/5
f 13/47/5 15/49/5 16/50/5
f 25/53/5 26/54/5 13/47/5
f 10/55/5 24/56/5 6/57/5
f 24/56/5 25/53/5 6/57/5
f 23/58/5 7/59/5 6/57/5
f 25/53/5 13/47/5 6/57/5
f 13/47/5 16/50/5 2/52/5
f 2/52/5 12/60/5 17/61/5
f 13/47/5 2/52/5 20/15/5
f 23/58/5 6/57/5 22/62/5
f 22/62/5 6/57/5 20/15/5
f 20/15/5 21/63/5 22/62/5
f 20/15/5 6/57/5 13/47/5
f 2/52/5 17/61/5 20/15/5
f 17/61/5 18/13/5 20/15/5
f 24/17/2 10/64/2 9/65/2
f 9/65/2 27/66/2 24/17/2
f 27/66/2 28/18/2 24/17/2
f 28/18/2 29/67/2 26/68/2
f 26/68/2 25/16/2 28/18/2
f 31/19/2 14/69/2 13/20/2
f 17/23/1 12/70/1 11/71/1
f 11/71/1 32/72/1 17/23/1
f 32/72/1 33/24/1 17/23/1
f 33/24/1 34/73/1 19/74/1
f 19/74/1 18/22/1 33/24/1
f 22/26/3 21/75/3 35/76/3
f 36/27/3 37/77/3 23/25/3
f 37/77/3 8/78/3 23/25/3
f 22/26/3 35/76/3 36/27/3
f 8/78/3 7/79/3 23/25/3
f 15/29/4 14/80/4 31/81/4
f 38/30/4 39/82/4 16/28/4
f 39/82/4 4/83/4 16/28/4
f 15/29/4 31/81/4 38/30/4
f 4/83/4 3/84/4 16/28/4
f 27/85/6 9/86/6 5/33/6
f 5/33/6 8/87/6 37/88/6
f 36/89/6 35/90/6 40/91/6
f 5/33/6 37/88/6 40/91/6
f 37/88/6 36/89/6 40/91/6
f 28/92/6 27/85/6 5/33/6
f 30/32/6 29/93/6 28/92/6
f 38/94/6 31/95/6 30/32/6
f 1/31/6 4/96/6 39/97/6
f 39/97/6 38/94/6 30/32/6
f 30/32/6 28/92/6 5/33/6
f 40/91/6 34/98/6 33/99/6
f 33/99/6 32/100/6 1/31/6
f 32/100/6 11/101/6 1/31/6
f 1/31/6 39/97/6 30/32/6
f 5/33/6 40/91/6 1/31/6
f 40/91/6 33/99/6 1/31/6
f 20/34/3 19/102/3 34/35/3
f 13/37/4 26/103/4 29/38/4
f 35/40/1 21/104/1 20/41/1

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB