Documentation and Icons initial
Adds some Icons and tooltips to machines Adds elepower tome - user guide
@ -12,6 +12,7 @@ function elepm.register_craft_type(name, def)
|
|||||||
elepm.craft.types[name] = {
|
elepm.craft.types[name] = {
|
||||||
inputs = def.inputs or 2,
|
inputs = def.inputs or 2,
|
||||||
description = def.description or name,
|
description = def.description or name,
|
||||||
|
overview = def.overview or name,
|
||||||
time = def.time or 0,
|
time = def.time or 0,
|
||||||
gui_name = def.gui_name,
|
gui_name = def.gui_name,
|
||||||
}
|
}
|
||||||
@ -215,5 +216,8 @@ end
|
|||||||
-- Cooking craft type built-in.
|
-- Cooking craft type built-in.
|
||||||
elepm.register_craft_type("cooking", {
|
elepm.register_craft_type("cooking", {
|
||||||
description = "Cooking",
|
description = "Cooking",
|
||||||
inputs = 1,
|
overview = "Cooking is more than just the prepartion of food "..
|
||||||
|
"it provides access to the prepartion of ores to metals "..
|
||||||
|
"and the creation of glass and glass objects.",
|
||||||
|
inputs = 1,
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
|
||||||
elepm.register_craft_type("alloy", {
|
elepm.register_craft_type("alloy", {
|
||||||
description = "Alloying",
|
description = "Alloying",
|
||||||
|
overview = "Alloys are created materials which are stronger than "..
|
||||||
|
"there base material components. These can be obtained "..
|
||||||
|
"by combining differing materials in the Alloying Furnace."..
|
||||||
|
"\nElepower provides a number of alloying recipes.",
|
||||||
inputs = 2,
|
inputs = 2,
|
||||||
icon = "elepower_machine_side.png^elepower_alloy_furnace.png",
|
icon = "elepower_machine_side.png^elepower_alloy_furnace.png",
|
||||||
})
|
})
|
||||||
@ -19,5 +23,7 @@ elepm.register_crafter("elepower_machines:alloy_furnace", {
|
|||||||
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_machine_side.png^elepower_alloy_furnace_active.png",
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_machine_side.png^elepower_alloy_furnace_active.png",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
ele_icon_material_1 ="default_copper_ingot.png",
|
||||||
|
ele_icon_material_2 ="default_tin_ingot.png",
|
||||||
groups = {oddly_breakable_by_hand = 1}
|
groups = {oddly_breakable_by_hand = 1}
|
||||||
})
|
})
|
||||||
|
@ -2,9 +2,90 @@
|
|||||||
-- It accepts a recipe type registered beforehand.
|
-- It accepts a recipe type registered beforehand.
|
||||||
|
|
||||||
-- Specialized formspec for crafters
|
-- Specialized formspec for crafters
|
||||||
function ele.formspec.get_crafter_formspec(craft_type, power, percent, pos, state)
|
function ele.formspec.get_crafter_formspec(craft_type, power, percent, pos, machine_name, state)
|
||||||
local craftstats = elepm.craft.types[craft_type]
|
local craftstats = elepm.craft.types[craft_type]
|
||||||
|
local craft_reg_path = elepm.craft[craft_type]
|
||||||
local input_size = craftstats.inputs
|
local input_size = craftstats.inputs
|
||||||
|
local material_inputs = {}
|
||||||
|
local mat_inputs = "|"
|
||||||
|
local formspec_inout_icon_tooltip
|
||||||
|
local icon_def_slot_1 = minetest.registered_nodes[machine_name].ele_icon_material_1 or "elepower_gui_icon_crafter_genmat_1.png"
|
||||||
|
local icon_def_slot_2 = minetest.registered_nodes[machine_name].ele_icon_material_2 or "elepower_gui_icon_crafter_genmat_2.png"
|
||||||
|
local icon_def_slot_3 = minetest.registered_nodes[machine_name].ele_icon_material_3 or "elepower_gui_icon_crafter_genmat_3.png"
|
||||||
|
|
||||||
|
-- Start add icons and tooltips for input slots
|
||||||
|
-- setting material name values to keys helps remove duplicates
|
||||||
|
-- for cooking we have to retrieve from MT engine
|
||||||
|
if craft_type == "cooking" then
|
||||||
|
local sort_output = {}
|
||||||
|
for name,def in pairs(minetest.registered_items) do
|
||||||
|
local recipe = minetest.get_all_craft_recipes(name)
|
||||||
|
|
||||||
|
if recipe ~= nil then
|
||||||
|
for k,v in pairs(recipe) do
|
||||||
|
if v.method == "cooking" and v.output ~= "" then
|
||||||
|
local reg_name = v.items[1]
|
||||||
|
|
||||||
|
if string.find(reg_name, "group") ~= nil then
|
||||||
|
description = string.gsub(reg_name, "group:","All ")
|
||||||
|
else
|
||||||
|
description = minetest.registered_items[reg_name].description
|
||||||
|
end
|
||||||
|
material_inputs[description] = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for k,v in pairs(craft_reg_path) do
|
||||||
|
for k2,v2 in pairs(v.recipe)do
|
||||||
|
-- have to check all registered items
|
||||||
|
if minetest.registered_items[k2] then
|
||||||
|
local description = minetest.registered_items[k2].description
|
||||||
|
|
||||||
|
-- remove any text on 2nd/3rd line
|
||||||
|
if string.find(description,"\n") then
|
||||||
|
description = string.split(description,"\n")
|
||||||
|
description = description[1]
|
||||||
|
end
|
||||||
|
material_inputs[description] = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- reverse table so we can sort
|
||||||
|
local material_in_sort = {}
|
||||||
|
for k,v in pairs(material_inputs)do
|
||||||
|
table.insert(material_in_sort,k)
|
||||||
|
end
|
||||||
|
table.sort(material_in_sort)
|
||||||
|
|
||||||
|
for k,mat_desc in pairs(material_in_sort) do
|
||||||
|
mat_inputs = mat_inputs.."\n"..mat_desc
|
||||||
|
end
|
||||||
|
mat_inputs = string.gsub(mat_inputs, "|\n","")
|
||||||
|
|
||||||
|
--adjust tooltip and layout depending on if we have 1/2/3 input slots
|
||||||
|
if input_size == 1 then
|
||||||
|
formspec_inout_icon_tooltip = "image[1.7,2.45;0.5,0.5;"..icon_def_slot_1.."]"..
|
||||||
|
"tooltip[1.5,2.0;1,1;"..mat_inputs..";#30434c;#0399c6]"--"tooltip[1.5,2.0;1,1;"..minetest.colorize("#0399c6",mat_inputs).."]"
|
||||||
|
|
||||||
|
elseif input_size == 2 then
|
||||||
|
formspec_inout_icon_tooltip = "image[1.2,2.45;0.5,0.5;"..icon_def_slot_1.."]"..
|
||||||
|
"tooltip[1.0,2.0;1,1;"..mat_inputs..";#30434c;#0399c6]"..
|
||||||
|
"image[2.2,2.45;0.5,0.5;"..icon_def_slot_2.."]"..
|
||||||
|
"tooltip[2.0,2.0;1,1;"..mat_inputs..";#30434c;#0399c6]"
|
||||||
|
|
||||||
|
else
|
||||||
|
formspec_inout_icon_tooltip = "image[1.2,2.45;0.5,0.5;"..icon_def_slot_1.."]"..
|
||||||
|
"tooltip[1.0,2.0;1,1;"..mat_inputs..";#30434c;#0399c6]"..
|
||||||
|
"image[2.2,2.45;0.5,0.5;"..icon_def_slot_2.."]"..
|
||||||
|
"tooltip[2.0,2.0;1,1;"..mat_inputs..";#30434c;#0399c6]"..
|
||||||
|
"image[3.2,2.45;0.5,0.5;"..icon_def_slot_3.."]"..
|
||||||
|
"tooltip[3.0,2.0;1,1;"..mat_inputs..";#30434c;#0399c6]"
|
||||||
|
end
|
||||||
|
-- End add icons tooltips for in slots
|
||||||
|
|
||||||
local gui_name = "gui_furnace_arrow"
|
local gui_name = "gui_furnace_arrow"
|
||||||
if craftstats.gui_name then
|
if craftstats.gui_name then
|
||||||
@ -30,6 +111,7 @@ function ele.formspec.get_crafter_formspec(craft_type, power, percent, pos, stat
|
|||||||
|
|
||||||
local y = 1.5
|
local y = 1.5
|
||||||
local x = 1.5
|
local x = 1.5
|
||||||
|
|
||||||
if in_height == 2 then
|
if in_height == 2 then
|
||||||
y = 1
|
y = 1
|
||||||
elseif in_height >= 3 then
|
elseif in_height >= 3 then
|
||||||
@ -48,6 +130,7 @@ function ele.formspec.get_crafter_formspec(craft_type, power, percent, pos, stat
|
|||||||
ele.formspec.state_switcher(7, 0, state)..
|
ele.formspec.state_switcher(7, 0, state)..
|
||||||
"list[context;src;"..x..","..y..";"..in_width..","..in_height..";]"..
|
"list[context;src;"..x..","..y..";"..in_width..","..in_height..";]"..
|
||||||
bar..
|
bar..
|
||||||
|
formspec_inout_icon_tooltip..
|
||||||
"list[context;dst;5,1;2,2;]"..
|
"list[context;dst;5,1;2,2;]"..
|
||||||
"list[current_player;main;0,4.25;8,1;]"..
|
"list[current_player;main;0,4.25;8,1;]"..
|
||||||
"list[current_player;main;0,5.5;8,3;8]"..
|
"list[current_player;main;0,5.5;8,3;8]"..
|
||||||
@ -59,6 +142,7 @@ function ele.formspec.get_crafter_formspec(craft_type, power, percent, pos, stat
|
|||||||
default.get_hotbar_bg(0, 4.25)
|
default.get_hotbar_bg(0, 4.25)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Don't duplicate function for every single crafter node
|
-- Don't duplicate function for every single crafter node
|
||||||
function crafter_timer (pos, elapsed)
|
function crafter_timer (pos, elapsed)
|
||||||
local refresh = false
|
local refresh = false
|
||||||
@ -180,7 +264,7 @@ function crafter_timer (pos, elapsed)
|
|||||||
pct = math.floor((time / ele.helpers.round(res_time * 10)) * 100)
|
pct = math.floor((time / ele.helpers.round(res_time * 10)) * 100)
|
||||||
end
|
end
|
||||||
|
|
||||||
meta:set_string("formspec", get_formspec(machine_def.craft_type, pow_buffer, pct, pos, state))
|
meta:set_string("formspec", get_formspec(machine_def.craft_type, pow_buffer, pct, pos ,minetest.get_node(pos).name,state))
|
||||||
meta:set_string("infotext", ("%s %s"):format(machine_def.description, status) ..
|
meta:set_string("infotext", ("%s %s"):format(machine_def.description, status) ..
|
||||||
"\n" .. ele.capacity_text(capacity, storage))
|
"\n" .. ele.capacity_text(capacity, storage))
|
||||||
|
|
||||||
@ -223,7 +307,7 @@ function elepm.register_crafter(nodename, nodedef)
|
|||||||
local storage = ele.helpers.get_node_property(meta, pos, "storage")
|
local storage = ele.helpers.get_node_property(meta, pos, "storage")
|
||||||
local capacity = ele.helpers.get_node_property(meta, pos, "capacity")
|
local capacity = ele.helpers.get_node_property(meta, pos, "capacity")
|
||||||
local pow_buffer = {capacity = capacity, storage = storage, usage = 0}
|
local pow_buffer = {capacity = capacity, storage = storage, usage = 0}
|
||||||
meta:set_string("formspec", get_formspec(craft_type, pow_buffer, nil, pos))
|
meta:set_string("formspec", get_formspec(craft_type, pow_buffer, nil, pos,nodename))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Upgradable
|
-- Upgradable
|
||||||
|
@ -7,8 +7,8 @@ local function get_formspec_default(power, percent, state)
|
|||||||
ele.formspec.power_meter(power)..
|
ele.formspec.power_meter(power)..
|
||||||
ele.formspec.state_switcher(7, 0, state)..
|
ele.formspec.state_switcher(7, 0, state)..
|
||||||
"list[context;src;3,1.5;1,1;]"..
|
"list[context;src;3,1.5;1,1;]"..
|
||||||
"image[4,1.5;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
"image[4,1.5;1,1;elepower_gui_icon_elepower_bg.png^[lowpart:"..
|
||||||
percent..":default_furnace_fire_fg.png]"..
|
percent..":elepower_gui_icon_elepower.png]"..
|
||||||
"list[current_player;main;0,4.25;8,1;]"..
|
"list[current_player;main;0,4.25;8,1;]"..
|
||||||
"list[current_player;main;0,5.5;8,3;8]"..
|
"list[current_player;main;0,5.5;8,3;8]"..
|
||||||
"listring[current_player;main]"..
|
"listring[current_player;main]"..
|
||||||
|
@ -192,6 +192,7 @@ end
|
|||||||
|
|
||||||
ele.register_base_device("elepower_machines:coal_alloy_furnace", {
|
ele.register_base_device("elepower_machines:coal_alloy_furnace", {
|
||||||
description = "Coal-fired Alloy Furnace",
|
description = "Coal-fired Alloy Furnace",
|
||||||
|
craft_type = "alloy",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
ele_active_node = true,
|
ele_active_node = true,
|
||||||
ele_active_nodedef = {
|
ele_active_nodedef = {
|
||||||
|
@ -40,10 +40,16 @@ local function get_formspec(time, power, input, out1, out2, state)
|
|||||||
default.gui_slots..
|
default.gui_slots..
|
||||||
ele.formspec.power_meter(power)..
|
ele.formspec.power_meter(power)..
|
||||||
ele.formspec.fluid_bar(1, 0, input)..
|
ele.formspec.fluid_bar(1, 0, input)..
|
||||||
|
"image[1.2,2.45;0.5,0.5;elepower_gui_icon_fluid_electrolyzer_in.png]"..
|
||||||
|
"tooltip[1.0,2.0;1,1;"..minetest.colorize("#0399c6"," Water\nHeavy Water\n BioFuel").."]"..
|
||||||
ele.formspec.state_switcher(3.5, 0, state)..
|
ele.formspec.state_switcher(3.5, 0, state)..
|
||||||
bar..
|
bar..
|
||||||
ele.formspec.fluid_bar(6, 0, out1)..
|
ele.formspec.fluid_bar(6, 0, out1)..
|
||||||
|
"image[6.2,2.45;0.5,0.5;elepower_gui_icon_fluid_electrolyzer_out1.png]"..
|
||||||
|
"tooltip[6.0,2.0;1,1;"..minetest.colorize("#0399c6"," Hydrogen\nDeuterium\n Nitrogen").."]"..
|
||||||
ele.formspec.fluid_bar(7, 0, out2)..
|
ele.formspec.fluid_bar(7, 0, out2)..
|
||||||
|
"image[7.2,2.45;0.5,0.5;elepower_gui_icon_fluid_electrolyzer_out2.png]"..
|
||||||
|
"tooltip[7.0,2.0;1,1;"..minetest.colorize("#0399c6"," Oxygen").."]"..
|
||||||
"list[current_player;main;0,4.25;8,1;]"..
|
"list[current_player;main;0,4.25;8,1;]"..
|
||||||
"list[current_player;main;0,5.5;8,3;8]"..
|
"list[current_player;main;0,5.5;8,3;8]"..
|
||||||
"listring[current_player;main]"..
|
"listring[current_player;main]"..
|
||||||
@ -153,7 +159,7 @@ local function electrolyzer_timer(pos)
|
|||||||
|
|
||||||
meta:set_string("infotext", ("Electrolyzer %s\n%s"):format(status, ele.capacity_text(pow_buffer.capacity, pow_buffer.storage)))
|
meta:set_string("infotext", ("Electrolyzer %s\n%s"):format(status, ele.capacity_text(pow_buffer.capacity, pow_buffer.storage)))
|
||||||
meta:set_string("formspec", get_formspec(time_percent, pow_buffer, input, out1, out2, state))
|
meta:set_string("formspec", get_formspec(time_percent, pow_buffer, input, out1, out2, state))
|
||||||
|
minetest.debug(dump(pow_buffer))
|
||||||
return refresh
|
return refresh
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -188,5 +194,6 @@ ele.register_machine("elepower_machines:electrolyzer", {
|
|||||||
on_construct = function (pos)
|
on_construct = function (pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", get_formspec())
|
meta:set_string("formspec", get_formspec())
|
||||||
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
|
||||||
elepm.register_craft_type("grind", {
|
elepm.register_craft_type("grind", {
|
||||||
description = "Grinding",
|
description = "Grinding",
|
||||||
|
overview = "Grinding of solid materials occurs through mechanical"..
|
||||||
|
"forces that break up the structure of the material."..
|
||||||
|
"After grinding the state of the material is changed;"..
|
||||||
|
"the grain size and the grain shape will be smaller and finer.",
|
||||||
icon = "elepower_machine_side.png^elepower_grinder.png",
|
icon = "elepower_machine_side.png^elepower_grinder.png",
|
||||||
inputs = 1,
|
inputs = 1,
|
||||||
})
|
})
|
||||||
|
@ -118,7 +118,7 @@ function ele.register_wind_generator(nodename, nodedef)
|
|||||||
end
|
end
|
||||||
|
|
||||||
ele.register_wind_generator("elepower_machines:wind_turbine", {
|
ele.register_wind_generator("elepower_machines:wind_turbine", {
|
||||||
description = "Wind Turbine\nRequires Wind Turbine Blades",
|
description = "Wind Turbine\n(Requires Wind Turbine Blades)",
|
||||||
tiles = {
|
tiles = {
|
||||||
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
"elepower_machine_top.png", "elepower_machine_base.png", "elepower_machine_side.png",
|
||||||
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_machine_side.png^elepower_wind_turbine_face.png",
|
"elepower_machine_side.png", "elepower_machine_side.png", "elepower_machine_side.png^elepower_wind_turbine_face.png",
|
||||||
|
@ -13,17 +13,17 @@ minetest.register_craftitem("elepower_nuclear:uranium_lump", {
|
|||||||
-- Dusts
|
-- Dusts
|
||||||
|
|
||||||
minetest.register_craftitem("elepower_nuclear:uranium_dust", {
|
minetest.register_craftitem("elepower_nuclear:uranium_dust", {
|
||||||
description = "Enriched Uranium Dust\nReady to be used as fuel",
|
description = "Enriched Uranium Dust\n(Ready to be used as fuel)",
|
||||||
inventory_image = "elenuclear_uranium_dust.png"
|
inventory_image = "elenuclear_uranium_dust.png"
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("elepower_nuclear:depleted_uranium_dust", {
|
minetest.register_craftitem("elepower_nuclear:depleted_uranium_dust", {
|
||||||
description = "Depleted Uranium Dust\nRequires enrichment",
|
description = "Depleted Uranium Dust\n(Requires enrichment)",
|
||||||
inventory_image = "elenuclear_depleted_uranium_dust.png"
|
inventory_image = "elenuclear_depleted_uranium_dust.png"
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("elepower_nuclear:nuclear_waste", {
|
minetest.register_craftitem("elepower_nuclear:nuclear_waste", {
|
||||||
description = "Nuclear Waste\nMostly unusable for nuclear fission",
|
description = "Nuclear Waste\n(Mostly unusable for nuclear fission)",
|
||||||
inventory_image = "elenuclear_uranium_waste.png"
|
inventory_image = "elenuclear_uranium_waste.png"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -53,7 +53,8 @@ function ele.formspec.power_meter(capacitor)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return ele.formspec.create_bar(0, 0, pw_percent, "#00a1ff") ..
|
return ele.formspec.create_bar(0, 0, pw_percent, "#00a1ff") ..
|
||||||
"tooltip[0,0;1,2.5;"..
|
"image[0.2,2.45;0.5,0.5;elepower_gui_icon_power_stored.png]"..
|
||||||
|
"tooltip[0,0;1,2.9;"..
|
||||||
minetest.colorize("#c60303", "Energy Storage\n")..
|
minetest.colorize("#c60303", "Energy Storage\n")..
|
||||||
minetest.colorize("#0399c6", ele.capacity_text(capacitor.capacity, capacitor.storage))..
|
minetest.colorize("#0399c6", ele.capacity_text(capacitor.capacity, capacitor.storage))..
|
||||||
minetest.colorize("#565656", "\nPower Used / Generated: " .. usage .. " " .. ele.unit) .. "]"
|
minetest.colorize("#565656", "\nPower Used / Generated: " .. usage .. " " .. ele.unit) .. "]"
|
||||||
@ -81,5 +82,6 @@ function ele.formspec.fluid_bar(x, y, fluid_buffer)
|
|||||||
return "image["..x..","..y..";1,2.8;elepower_gui_barbg.png"..
|
return "image["..x..","..y..";1,2.8;elepower_gui_barbg.png"..
|
||||||
"\\^[lowpart\\:"..metric.."\\:"..texture.."\\\\^[resize\\\\:64x128]"..
|
"\\^[lowpart\\:"..metric.."\\:"..texture.."\\\\^[resize\\\\:64x128]"..
|
||||||
"image["..x..","..y..";1,2.8;elepower_gui_gauge.png]"..
|
"image["..x..","..y..";1,2.8;elepower_gui_gauge.png]"..
|
||||||
|
"image[0.2,2.45;0.5,0.5;elepower_gui_icon_power_stored.png]"..
|
||||||
tooltip
|
tooltip
|
||||||
end
|
end
|
||||||
|
BIN
elepower_papi/textures/elepower_gui_icon_crafter_genmat_1.png
Normal file
After Width: | Height: | Size: 726 B |
BIN
elepower_papi/textures/elepower_gui_icon_crafter_genmat_2.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
elepower_papi/textures/elepower_gui_icon_crafter_genmat_3.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
elepower_papi/textures/elepower_gui_icon_elepower.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
elepower_papi/textures/elepower_gui_icon_elepower_32.png
Normal file
After Width: | Height: | Size: 7.0 KiB |
BIN
elepower_papi/textures/elepower_gui_icon_elepower_bg.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
elepower_papi/textures/elepower_gui_icon_elepower_bg_32.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 6.2 KiB |
After Width: | Height: | Size: 851 B |
After Width: | Height: | Size: 716 B |
BIN
elepower_papi/textures/elepower_gui_icon_fluid_water.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
elepower_papi/textures/elepower_gui_icon_power_stored.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
@ -7,8 +7,8 @@ local function get_formspec_default(power, percent, state)
|
|||||||
default.gui_slots..
|
default.gui_slots..
|
||||||
ele.formspec.power_meter(power)..
|
ele.formspec.power_meter(power)..
|
||||||
ele.formspec.state_switcher(7, 0, state)..
|
ele.formspec.state_switcher(7, 0, state)..
|
||||||
"image[3.5,1.5;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
"image[3.5,1.5;1,1;elepower_gui_icon_elepower_bg.png^[lowpart:"..
|
||||||
(percent)..":default_furnace_fire_fg.png]"..
|
(percent)..":elepower_gui_icon_elepower.png]"..
|
||||||
"list[current_player;main;0,4.25;8,1;]"..
|
"list[current_player;main;0,4.25;8,1;]"..
|
||||||
"list[current_player;main;0,5.5;8,3;8]"..
|
"list[current_player;main;0,5.5;8,3;8]"..
|
||||||
default.get_hotbar_bg(0, 4.25)
|
default.get_hotbar_bg(0, 4.25)
|
||||||
|
478
elepower_tome/init.lua
Normal file
@ -0,0 +1,478 @@
|
|||||||
|
---------------------------------------------------
|
||||||
|
-- ___ _ --
|
||||||
|
-- | __| |___ _ __ _____ __ _____ _ _ --
|
||||||
|
-- | _|| / -_) '_ \/ _ \ V V / -_) '_| --
|
||||||
|
-- |___|_\___| .__/\___/\_/\_/\___|_| --
|
||||||
|
-- |_| --
|
||||||
|
-- _____ --
|
||||||
|
-- |_ _|__ _ __ ___ --
|
||||||
|
-- | |/ _ \ ' \/ -_) --
|
||||||
|
-- |_|\___/_|_|_\___| --
|
||||||
|
---------------------------------------------------
|
||||||
|
-- --
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
-- Global variable for mod
|
||||||
|
eletome = rawget(_G, "eletome") or {}
|
||||||
|
|
||||||
|
-- register our Tome item
|
||||||
|
minetest.register_craftitem("elepower_tome:tome", {
|
||||||
|
description = "Elepower Tome",
|
||||||
|
inventory_image = "elepower_tome.png",
|
||||||
|
groups = {book = 1, flammable = 3},
|
||||||
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
|
local eletome_bg = eletome.tome_bg
|
||||||
|
local eletome_contents = eletome.contents_page()
|
||||||
|
minetest.show_formspec(user:get_player_name(), "elepower_tome:tome", eletome_bg..eletome_contents)
|
||||||
|
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Give player elepower tome on initaial logon
|
||||||
|
minetest.register_on_newplayer(function(player)
|
||||||
|
player:get_inventory():add_item("main", "elepower_tome:tome")
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- register our recieve field callback
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
if formname ~= "elepower_tome:tome" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Clicked contents button any page.
|
||||||
|
if fields.content then
|
||||||
|
local eletome_bg = eletome.tome_bg
|
||||||
|
local eletome_contents = eletome.contents_page()
|
||||||
|
minetest.show_formspec(player:get_player_name(), "elepower_tome:tome", eletome_bg..eletome_contents)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Clicked a craft link on contents
|
||||||
|
if fields.content_rp_cl_craft_txt or fields.content_rp_cr_craft_txt then
|
||||||
|
|
||||||
|
local craft_value = fields.content_rp_cl_craft_txt or fields.content_rp_cr_craft_txt
|
||||||
|
local eletome_bg = eletome.tome_bg
|
||||||
|
local eletome_craft = eletome.craft_page(craft_value)
|
||||||
|
|
||||||
|
minetest.show_formspec(player:get_player_name(), "elepower_tome:tome", eletome_bg..eletome_craft)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Clicked fwd/bwd button on craft sub-page
|
||||||
|
if fields.craft_page_fwd or fields.craft_page_bwd then
|
||||||
|
|
||||||
|
-- eletome.craft_page() expects description in format "something:craft_description"
|
||||||
|
|
||||||
|
local craft_page_fwd = fields.craft_page_fwd or ""
|
||||||
|
local craft_page_bwd = fields.craft_page_bwd or ""
|
||||||
|
|
||||||
|
local page_num = string.match(craft_page_fwd, "%s(%w)%s")
|
||||||
|
|
||||||
|
if not page_num then
|
||||||
|
local page_num = string.match(craft_page_bwd, "%s(%w)%s")
|
||||||
|
end
|
||||||
|
|
||||||
|
local craft_value = "cd:"..fields.craft_description
|
||||||
|
local eletome_bg = eletome.tome_bg
|
||||||
|
local eletome_craft = eletome.craft_page(craft_value,page_num)
|
||||||
|
|
||||||
|
minetest.show_formspec(player:get_player_name(), "elepower_tome:tome", eletome_bg..eletome_craft)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--minetest.debug(dump(fields))
|
||||||
|
end)
|
||||||
|
----------------
|
||||||
|
-- Tome Pages --
|
||||||
|
----------------
|
||||||
|
|
||||||
|
eletome.tome_bg = "formspec_version[4]size[18,11]"..
|
||||||
|
"bgcolor[#003782;true]".. -- fails (my understanding limitation)
|
||||||
|
"box[0.0,0.0;18,11;#003782]".. -- workaround the above
|
||||||
|
"box[0.5,0.5;8.5,10;#d1caaeFF]"..
|
||||||
|
"box[9.0,0.5;8.5,10;#d1caaeFF]"..
|
||||||
|
"button_exit[17.5,0;0.5,0.5;X;X]"..
|
||||||
|
--"label[3.5,10.75;Elepower Tome]"..
|
||||||
|
--"label[11.5,10.75;Elepower Tome]"..
|
||||||
|
"button[0,0;2,0.5;content;Content]"
|
||||||
|
|
||||||
|
-- Common style components - some end duplicates but kept for ease of reading/updating later
|
||||||
|
-- s = start ie pre text
|
||||||
|
-- e = end ie post text
|
||||||
|
eletome.font_color = "#1f1f1fFF"
|
||||||
|
eletome.y_space_line = 0.4
|
||||||
|
eletome.char_per_line = 60
|
||||||
|
|
||||||
|
-- Used for hypertext
|
||||||
|
eletome.common_styles = {
|
||||||
|
style_h0s = "<style color="..eletome.font_color.." size=26><b><center>",
|
||||||
|
style_h0e = "</center></b></style>",
|
||||||
|
style_h1s = "<style color="..eletome.font_color.." size=20><b><center>",
|
||||||
|
style_h1e = "</center></b></style>",
|
||||||
|
style_h2s = "<style color="..eletome.font_color.." size=18><center>",
|
||||||
|
style_h2e = "</center></style>",
|
||||||
|
style_h3s = "<style color="..eletome.font_color.." size=16><center>",
|
||||||
|
style_h3e = "</center></style>", -- approximate default "label" size
|
||||||
|
style_h4s = "<style color="..eletome.font_color.." size=12><center>",
|
||||||
|
style_h4e = "</center></style>"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function eletome.contents_page()
|
||||||
|
-- Contents page structured as 2 pages ie an open book
|
||||||
|
-- a single column on left page and 2 columns on right page
|
||||||
|
|
||||||
|
-- Assign Common styles to local vars
|
||||||
|
local sty_h0s = eletome.common_styles.style_h0s
|
||||||
|
local sty_h0e = eletome.common_styles.style_h0e
|
||||||
|
local sty_h1s = eletome.common_styles.style_h1s
|
||||||
|
local sty_h1e = eletome.common_styles.style_h1e
|
||||||
|
local sty_h2s = eletome.common_styles.style_h2s
|
||||||
|
local sty_h2e = eletome.common_styles.style_h2e
|
||||||
|
local sty_h3s = eletome.common_styles.style_h3s
|
||||||
|
local sty_h3e = eletome.common_styles.style_h3e
|
||||||
|
local sty_h4s = eletome.common_styles.style_h4s
|
||||||
|
local sty_h4e = eletome.common_styles.style_h4e
|
||||||
|
|
||||||
|
-- Contents page left page Content
|
||||||
|
|
||||||
|
local content_lp_txt = "Elepower adds power to a game, Power is referred to in units and these units are referred to as EpU (Elepower Unit).\nNew crafts are added to the game as well as machines to enable these new crafts and make use of EpU/s.\n\nA big thank you to IcyDiamond the orginal creator of this mod."
|
||||||
|
|
||||||
|
local heading_lp = "hypertext[0.50,1.0;8.5,10;content_lp_h_tome;"..sty_h0s.."Elepower\nTome"..sty_h0e.."]"
|
||||||
|
local content_lp = "hypertext[0.75,2.5;8.0,8;content_lp_c_text;"..sty_h3s..content_lp_txt..sty_h3s.."]"
|
||||||
|
|
||||||
|
|
||||||
|
-- Contents page right page Content
|
||||||
|
local heading_rp = "hypertext[9.0,1.0;8.5,9.0;content_rp_h_cont;"..sty_h1s.."Contents"..sty_h1e.."]"
|
||||||
|
local heading_rp_craft = "hypertext[9.0,1.5;8.5,7.5;content_rp_sh_crafts;"..sty_h2s.."Crafts"..sty_h2e.."]"
|
||||||
|
|
||||||
|
local raw_all_crafts = table.copy(elepm.craft.types)
|
||||||
|
local all_crafts = {}
|
||||||
|
-- Gets the Human readable craft name
|
||||||
|
-- and sorts them alphabetically
|
||||||
|
for k,def in pairs(raw_all_crafts) do
|
||||||
|
table.insert(all_crafts,def.description)
|
||||||
|
end
|
||||||
|
table.sort(all_crafts)
|
||||||
|
|
||||||
|
-- Generate the craft_content section
|
||||||
|
-- 2 columns of h2 headings down the page
|
||||||
|
local left_col = ""
|
||||||
|
local rght_col = ""
|
||||||
|
for k,craft_name in pairs(all_crafts) do
|
||||||
|
if (k % 2 == 0) then -- even key - backwards fix this left should be odd....
|
||||||
|
left_col = left_col.."<action name="..craft_name..">"..craft_name.."</action>".."\n"
|
||||||
|
else -- odd key
|
||||||
|
rght_col = rght_col.."<action name="..craft_name..">"..craft_name.."</action>".."\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local craft_rp_txt = "hypertext[09.0,2.0;4.5,7.0;content_rp_cl_craft_txt;"..sty_h3s..left_col..sty_h3e.."]"..
|
||||||
|
"hypertext[13.5,2.0;4.5,7.0;content_rp_cr_craft_txt;"..sty_h3s..rght_col..sty_h3e.."]"
|
||||||
|
local heading_rp_mach = "hypertext[09.0,4.5;8.5,6.5;content_rp_sh_mach;"..sty_h2s.."Machines"..sty_h2e.."]"
|
||||||
|
|
||||||
|
local subhead_mach_gen = "hypertext[09.0,4.8;8.5,6.5;content_rp_sh_gen;"..sty_h3s.."Generators"..sty_h3e.."]"
|
||||||
|
|
||||||
|
-- remove all "active" version of providers and 2nd half any descriptions with "\n"
|
||||||
|
local i = 1
|
||||||
|
local lft_col = ""
|
||||||
|
local rht_col = ""
|
||||||
|
local mach_sort = {}
|
||||||
|
local mach_key = {}
|
||||||
|
for name, def in pairs(minetest.registered_nodes) do
|
||||||
|
if def.groups["ele_provider"] then
|
||||||
|
if not string.find(name, "active") then
|
||||||
|
local description = def.description
|
||||||
|
|
||||||
|
if string.find(description,"\n") then
|
||||||
|
description = string.match(description,"(.+)\n")
|
||||||
|
end
|
||||||
|
table.insert(mach_sort,description)
|
||||||
|
mach_key[description] = name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(mach_sort)
|
||||||
|
|
||||||
|
for k,des in pairs(mach_sort) do
|
||||||
|
if (k % 2 == 0) then -- even key
|
||||||
|
rht_col = rht_col.."<action name="..mach_key[des]..">"..des.."</action>".."\n"
|
||||||
|
else -- odd key
|
||||||
|
lft_col = lft_col.."<action name="..mach_key[des]..">"..des.."</action>".."\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local mach_rp_gen_txt = "hypertext[09.0,5.2;4.5,7.0;content_rp_cl_mach_txt;"..sty_h4s..lft_col..sty_h4e.."]"..
|
||||||
|
"hypertext[13.5,5.2;4.5,7.0;content_rp_cr_mach_txt;"..sty_h4s..rht_col..sty_h4e.."]"
|
||||||
|
|
||||||
|
|
||||||
|
-- Assemble contents page
|
||||||
|
local eletome_cont = heading_lp..content_lp..
|
||||||
|
heading_rp..heading_rp_craft..craft_rp_txt
|
||||||
|
--heading_rp_mach..subhead_mach_gen..mach_rp_gen_txt
|
||||||
|
|
||||||
|
return eletome_cont
|
||||||
|
end
|
||||||
|
|
||||||
|
function eletome.craft_page(craft_description,page_num)
|
||||||
|
-- remove "action:" from string
|
||||||
|
local craft_description = string.match(craft_description, ":(.*)")
|
||||||
|
|
||||||
|
-- Convert craft_description back to craft
|
||||||
|
local raw_all_crafts = table.copy(elepm.craft.types)
|
||||||
|
local craft_click = {}
|
||||||
|
local craft_type
|
||||||
|
for craft_name,def in pairs(raw_all_crafts) do
|
||||||
|
if def.description == craft_description then
|
||||||
|
craft_click[craft_name] = def
|
||||||
|
craft_type = craft_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if craft_click == "nil" then
|
||||||
|
minetest.debug("error")
|
||||||
|
end
|
||||||
|
-- Craft page structured as 2 pages ie an open book
|
||||||
|
-- a single column on left page and single column
|
||||||
|
-- on the right page.
|
||||||
|
|
||||||
|
-- Assign Common styles to local vars
|
||||||
|
local sty_h0s = eletome.common_styles.style_h0s
|
||||||
|
local sty_h0e = eletome.common_styles.style_h0e
|
||||||
|
local sty_h1s = eletome.common_styles.style_h1s
|
||||||
|
local sty_h1e = eletome.common_styles.style_h1e
|
||||||
|
local sty_h2s = eletome.common_styles.style_h2s
|
||||||
|
local sty_h2e = eletome.common_styles.style_h2e
|
||||||
|
local sty_h3s = eletome.common_styles.style_h3s
|
||||||
|
local sty_h3e = eletome.common_styles.style_h3e
|
||||||
|
local sty_h4s = eletome.common_styles.style_h4s
|
||||||
|
local sty_h4e = eletome.common_styles.style_h4e
|
||||||
|
|
||||||
|
--------------------------
|
||||||
|
-- Craft page left page --
|
||||||
|
--------------------------
|
||||||
|
local heading_lp = "hypertext[0.5,1.0;8.5,9.0;craft_lp_h;"..sty_h0s..craft_description..sty_h0e.."]"
|
||||||
|
local head_sub_lp_ov = "hypertext[0.5,1.5;8.5,7.5;craft_lp_sh_ov;"..sty_h1s.."Overview"..sty_h1e.."]"
|
||||||
|
local ov_lp_txt = "hypertext[0.75,2.0;8.0,7.0;craft_lp_ov_text;"..sty_h3s..craft_click[craft_type].overview..sty_h3s.."]"
|
||||||
|
|
||||||
|
-- calculate approximatly how many lines "overview" takes
|
||||||
|
local length = string.len(craft_click[craft_type].overview)
|
||||||
|
local cpl = eletome.char_per_line
|
||||||
|
local num_lines = math.ceil(length/cpl)
|
||||||
|
local y_offset = num_lines*eletome.y_space_line
|
||||||
|
|
||||||
|
-- Find machines that do craft
|
||||||
|
local mach_names = {}
|
||||||
|
|
||||||
|
for name,def in pairs(minetest.registered_nodes)do
|
||||||
|
if def.craft_type == craft_type then
|
||||||
|
if def.ele_active_node and string.find(name,"active") then -- only insert active version of machine
|
||||||
|
table.insert(mach_names,{name,def.description})
|
||||||
|
|
||||||
|
elseif not def.ele_active_node then
|
||||||
|
table.insert(mach_names,{name,def.description})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local machines_lp = "style_type[item_image_button;bgimg=elepower_tome_bqimg1.png]"
|
||||||
|
local y_m_row = 0 --multiple rows of machines
|
||||||
|
for k,def in pairs(mach_names)do
|
||||||
|
if #mach_names == 1 then
|
||||||
|
machines_lp = machines_lp.."item_image_button[4,"..(2.7+y_offset+y_m_row)..";1.25,1.25;"..def[1]..";"..def[2]..";]"..
|
||||||
|
"hypertext[0.5,"..(4+y_offset+y_m_row)..";8.4,1;craft_mach_lab;"..sty_h3s..def[2]..sty_h3s.."]"
|
||||||
|
|
||||||
|
else
|
||||||
|
if (k % 2 == 0) then -- even key
|
||||||
|
machines_lp = machines_lp.."item_image_button[6,"..(2.7+y_offset+y_m_row)..";1.25,1.25;"..def[1]..";"..def[2]..";]"..
|
||||||
|
"hypertext[4.5,"..(4+y_offset+y_m_row)..";4.5,1;craft_mach_lab;"..sty_h3s..def[2]..sty_h3s.."]"
|
||||||
|
y_m_row = y_m_row + 2.5
|
||||||
|
else -- odd key
|
||||||
|
machines_lp = machines_lp.."item_image_button[2,"..(2.7+y_offset+y_m_row)..";1.25,1.25;"..def[1]..";"..def[2]..";]"..
|
||||||
|
"hypertext[0.5,"..(4+y_offset+y_m_row)..";4.5,1;craft_mach_lab;"..sty_h3s..def[2]..sty_h3s.."]"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
---------------------------
|
||||||
|
-- Craft page right page --
|
||||||
|
---------------------------
|
||||||
|
local head_sub_rp_rec = "hypertext[9.5,1.0;8.0,9.0;craft_lp_h;"..sty_h1s.."Recipes"..sty_h1e.."]"
|
||||||
|
|
||||||
|
local craft_reg_path = elepm.craft[craft_type]
|
||||||
|
local recipe_list = {}
|
||||||
|
local recipe_list_rdy = {}
|
||||||
|
|
||||||
|
|
||||||
|
if craft_type == "cooking" then
|
||||||
|
-- restructure craft recipe inputs/outputs, so easier to output to formspec
|
||||||
|
-- recipe_list = {
|
||||||
|
-- {input={item1,num},{item2,num},output={item,num}},
|
||||||
|
-- {input={item1,num},{item2,num},output={item1,num},{item2,num}}
|
||||||
|
-- }
|
||||||
|
|
||||||
|
for name,def in pairs(minetest.registered_items) do
|
||||||
|
local recipe = minetest.get_all_craft_recipes(name)
|
||||||
|
|
||||||
|
if recipe ~= nil then
|
||||||
|
for k,def in pairs(recipe) do
|
||||||
|
if def.method == "cooking" and def.output ~= "" then
|
||||||
|
if string.find(def.items[1],"group") then
|
||||||
|
def.items[1] = string.gsub(def.items[1],"group","default")
|
||||||
|
end
|
||||||
|
-- This structure matches below, double table nesting a bit redundant
|
||||||
|
|
||||||
|
table.insert(recipe_list,{input = {{def.items[1],1}},output = {{def.output,1}}})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
-- restructure craft recipe inputs/outputs, so easier to output to formspec
|
||||||
|
-- recipe_list = {
|
||||||
|
-- {input={item1,num},{item2,num},output={item,num}},
|
||||||
|
-- {input={item1,num},{item2,num},output={item1,num},{item2,num}}
|
||||||
|
-- }
|
||||||
|
|
||||||
|
for k,v in pairs(craft_reg_path) do
|
||||||
|
local input = {}
|
||||||
|
local output = {}
|
||||||
|
|
||||||
|
if type(v.output) == "table" then -- very rarly table eg grinding-fuel_rod_depleted
|
||||||
|
for k,v in pairs(v.output)do
|
||||||
|
local t_out = string.split(v," ")
|
||||||
|
table.insert(output,{t_out[1],tonumber(t_out[2]) or 1})
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
local t_out = string.gsub(tostring(v.output),"ItemStack%(\"","")
|
||||||
|
local t_out = string.gsub(t_out,"\"%)","")
|
||||||
|
local t_out = string.split(t_out," ")
|
||||||
|
table.insert(output,{t_out[1],tonumber(t_out[2]) or 1})
|
||||||
|
end
|
||||||
|
|
||||||
|
for k2,v2 in pairs(v.recipe)do
|
||||||
|
table.insert(input,{k2,v2})
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(recipe_list,{input = input,output = output})
|
||||||
|
end
|
||||||
|
--minetest.debug(dump(recipe_list))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- build recipe list
|
||||||
|
local y_off = 0
|
||||||
|
local x_off = 0
|
||||||
|
local col_cnt = 1
|
||||||
|
local recipe_cnt = 1
|
||||||
|
|
||||||
|
for k,def in pairs(recipe_list) do
|
||||||
|
local s_recipe ="style_type[label;font_size=-2;font=bold;textcolor=#FFF]"
|
||||||
|
local in_len = #def.input
|
||||||
|
local out_len = #def.output
|
||||||
|
local columns = 2
|
||||||
|
local col_gap = 0.75
|
||||||
|
local in_cnt = 1
|
||||||
|
|
||||||
|
if (in_len+out_len) == 2 then
|
||||||
|
columns = 3
|
||||||
|
end
|
||||||
|
|
||||||
|
if (in_len+out_len) == 3 then
|
||||||
|
col_gap = 1.5
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
for k,def in pairs(def.input) do
|
||||||
|
|
||||||
|
s_recipe = s_recipe.."item_image_button["..(9.5 + x_off)..","..(1.5+y_off)..";0.6,0.6;"..def[1]..";"..def[1]..";]"
|
||||||
|
s_recipe = s_recipe.."label["..(10 + x_off)..","..(1.99 + y_off)..";"..def[2].."]"
|
||||||
|
x_off = x_off+0.7
|
||||||
|
|
||||||
|
if in_cnt >= in_len then
|
||||||
|
s_recipe = s_recipe.."image["..(9.5 + x_off)..","..(1.5+y_off)..";0.6,0.6;elepower_tome_equals.png]"
|
||||||
|
x_off = x_off+0.7
|
||||||
|
end
|
||||||
|
in_cnt = in_cnt+1
|
||||||
|
end
|
||||||
|
|
||||||
|
for k,def in pairs(def.output)do
|
||||||
|
s_recipe = s_recipe.."item_image_button["..(9.5 + x_off)..","..(1.5+y_off)..";0.6,0.6;"..def[1]..";"..def[1]..";]"
|
||||||
|
s_recipe = s_recipe.."label["..(10 + x_off)..","..(1.99 + y_off)..";"..def[2].."]"
|
||||||
|
x_off = x_off+0.7
|
||||||
|
end
|
||||||
|
|
||||||
|
if col_cnt >= columns then
|
||||||
|
x_off = 0
|
||||||
|
y_off = y_off + 0.7
|
||||||
|
col_cnt = 1
|
||||||
|
else
|
||||||
|
x_off = x_off+col_gap
|
||||||
|
col_cnt = col_cnt + 1
|
||||||
|
end
|
||||||
|
table.insert(recipe_list_rdy,s_recipe)
|
||||||
|
recipe_list_rdy.columns = recipe_list_rdy.columns or columns
|
||||||
|
recipe_cnt = recipe_cnt + 1
|
||||||
|
|
||||||
|
--reset y_off(set) as these will be on page 2/3 etc
|
||||||
|
if recipe_cnt > recipe_list_rdy.columns*12 then
|
||||||
|
y_off = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Split recipes across 2 or more pages if needed.
|
||||||
|
local max_recipe_pp = 24 -- 2 columns
|
||||||
|
local num_recipe = #recipe_list_rdy
|
||||||
|
local pg_num = tonumber(page_num) or 1
|
||||||
|
local i = 1
|
||||||
|
local recipe_rp = ""
|
||||||
|
local fwd_page_name = "craft_page_fwd"
|
||||||
|
local bwd_page_name = "craft_page_bwd"
|
||||||
|
|
||||||
|
|
||||||
|
if recipe_list_rdy.columns == 3 then
|
||||||
|
max_recipe_pp = 36
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if pg_num > 1 then
|
||||||
|
-- Check if we need another fwd button
|
||||||
|
if pg_num*max_recipe_pp < num_recipe then
|
||||||
|
recipe_rp = recipe_rp.."button[15,0;2.5,0.5;"..fwd_page_name..";Page "..(pg_num + 1).." >>]"
|
||||||
|
end
|
||||||
|
-- Always need back button
|
||||||
|
recipe_rp = recipe_rp.."button[12.5,0;2.5,0.5;"..bwd_page_name..";<< "..(pg_num - 1).." Page]"
|
||||||
|
|
||||||
|
elseif num_recipe > max_recipe_pp then
|
||||||
|
recipe_rp = recipe_rp.."button[15,0;2.5,0.5;"..fwd_page_name..";Page "..(pg_num + 1).." >>]"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Pass craft_description to player recieve fields when fwd/bwd pressed - not visible on formspec
|
||||||
|
recipe_rp = recipe_rp.."field[10,12;1,0.5;craft_description;;"..craft_description.."]"
|
||||||
|
|
||||||
|
local pg_offset = (pg_num-1)*max_recipe_pp
|
||||||
|
i = i+pg_offset
|
||||||
|
|
||||||
|
while i <= (max_recipe_pp + pg_offset) and i <= num_recipe do
|
||||||
|
recipe_rp = recipe_rp..recipe_list_rdy[i]
|
||||||
|
i=i+1
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------
|
||||||
|
-- Assemble craft page --
|
||||||
|
-------------------------
|
||||||
|
local eletome_craft = heading_lp..head_sub_lp_ov..ov_lp_txt..machines_lp..
|
||||||
|
head_sub_rp_rec..recipe_rp
|
||||||
|
|
||||||
|
return eletome_craft
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
3
elepower_tome/mod.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = elepower_tome
|
||||||
|
description = Elepower Power Network User Guide
|
||||||
|
depends = elepower_machines
|
BIN
elepower_tome/textures/elepower_tome.png
Normal file
After Width: | Height: | Size: 441 B |
BIN
elepower_tome/textures/elepower_tome_bqimg1.png
Normal file
After Width: | Height: | Size: 798 B |
BIN
elepower_tome/textures/elepower_tome_equals.png
Normal file
After Width: | Height: | Size: 602 B |
BIN
elepower_tome/textures/elepower_tome_plus.png
Normal file
After Width: | Height: | Size: 565 B |