mirror of
https://asciireactor.com/factorio/adamo-chemical.git
synced 2024-11-25 14:15:07 +00:00
203 lines
7.6 KiB
Lua
203 lines
7.6 KiB
Lua
|
remote.add_interface("adamo-chemical", {
|
||
|
informatron_menu = function(data)
|
||
|
return mymod_menu(data.player_index)
|
||
|
end,
|
||
|
informatron_page_content = function(data)
|
||
|
return mymod_page_content(data.page_name, data.player_index, data.element)
|
||
|
end
|
||
|
})
|
||
|
|
||
|
--[[
|
||
|
If you implement the informatron_menu interface at all then you will have a page in Informatron even if you don't add additional sub-pages to the menu.
|
||
|
The deafult page has a menu caption of adamo-chemical.menu_adamo-chemical and a page title of adamo-chemical.title_adamo-chemical.
|
||
|
If you also add text to the page with the caption "adamo-chemical.page_adamo-chemical_text_1" then your mod should add the following to your local .cfg file:
|
||
|
[adamo-chemical]
|
||
|
menu_adamo-chemical=My Mod Name
|
||
|
title_adamo-chemical=My Mod Name
|
||
|
page_adamo-chemical_text_1=My descriptive text
|
||
|
]]--
|
||
|
|
||
|
function mymod_menu(player_index)
|
||
|
return {
|
||
|
minerals=1,
|
||
|
smelting=1,
|
||
|
processes=1
|
||
|
}
|
||
|
end
|
||
|
--[[
|
||
|
For the above menu items you should add to your local .cfg file (under [adamo-chemical]):
|
||
|
menu_minerals=minerals
|
||
|
title_minerals=minerals
|
||
|
page_minerals_text_1=Text about mineralss.
|
||
|
menu_smelting=smelting
|
||
|
title_smelting=smelting
|
||
|
page_smelting_text_1=Text about smeltings.
|
||
|
menu_processes=processes
|
||
|
title_processes=processes
|
||
|
page_processes_text_1=Text about processes.
|
||
|
menu_penguin=Pengiun
|
||
|
title_penguin=Pengiun
|
||
|
page_penguin_text_1=Text about pengiuns.
|
||
|
etc...
|
||
|
]]
|
||
|
|
||
|
function mymod_page_content(page_name, player_index, element)
|
||
|
-- main page
|
||
|
|
||
|
if page_name == "adamo-chemical" then
|
||
|
element.add {
|
||
|
type="label",
|
||
|
name="text_1",
|
||
|
caption={"adamo-chemical.page_adamo-chemical_text_1"}
|
||
|
}
|
||
|
-- Says dude's name in __1__
|
||
|
--element.add{
|
||
|
-- type="label",
|
||
|
-- name="text_1",
|
||
|
-- caption={
|
||
|
-- "adamo-chemical.page_text_1",
|
||
|
-- player.name or {"informatron.player_name", player_index}
|
||
|
-- },
|
||
|
-- style="heading_1_label"
|
||
|
--}
|
||
|
--local image_container = element.add{
|
||
|
-- type="frame",
|
||
|
-- name="image_1",
|
||
|
-- style="informatron_image_container",
|
||
|
-- direction="vertical"
|
||
|
--}
|
||
|
--image_container.style.horizontally_stretchable = true
|
||
|
--image_container.style.horizontal_align = "center"
|
||
|
--image_container.add{
|
||
|
-- type="button",
|
||
|
-- name="image_1",
|
||
|
-- style="adamo-chemical-image",
|
||
|
-- caption=
|
||
|
--} -- image is the background
|
||
|
element.add{
|
||
|
type="button",
|
||
|
name="image_1",
|
||
|
style="adamo-chemical-image"
|
||
|
}
|
||
|
|
||
|
element.add{
|
||
|
type="label",
|
||
|
name="text_3",
|
||
|
caption={"adamo-chemical.page_adamo-chemical_text_3"}
|
||
|
}
|
||
|
|
||
|
-- if #Informatron.get_menu_pane(player_index).children == 1 then
|
||
|
-- local conditional = element.add{
|
||
|
-- type="label",
|
||
|
-- name="text_3_c",
|
||
|
-- caption={"adamo-chemical.page_adamo-chemical_text_3_conditional"}
|
||
|
-- }
|
||
|
-- conditional.style.font_color = {255/255,230/255,192/255}
|
||
|
-- end
|
||
|
|
||
|
element.add{
|
||
|
type="label",
|
||
|
name="text_4",
|
||
|
caption={"adamo-chemical.page_adamo-chemical_text_4"}, style="heading_1_label"
|
||
|
}
|
||
|
element.add{
|
||
|
type="label",
|
||
|
name="text_5",
|
||
|
caption={"adamo-chemical.page_adamo-chemical_text_5"}
|
||
|
}
|
||
|
end
|
||
|
|
||
|
|
||
|
if page_name == "minerals" then
|
||
|
element.add {
|
||
|
type="label",
|
||
|
name="text_1",
|
||
|
caption={"adamo-chemical.page_minerals_text_1"}
|
||
|
}
|
||
|
end
|
||
|
|
||
|
if page_name == "smelting" then
|
||
|
element.add {
|
||
|
type="label",
|
||
|
name="text_1",
|
||
|
caption={"adamo-chemical.page_smelting_text_1"}
|
||
|
}
|
||
|
end
|
||
|
|
||
|
if page_name == "processes" then
|
||
|
element.add {
|
||
|
type="label",
|
||
|
name="text_1",
|
||
|
caption={"adamo-chemical.page_processes_text_1"}
|
||
|
}
|
||
|
--[[
|
||
|
To make an image you need to require the Informatron mod (so it loads first) then have some code like this in data.lua
|
||
|
informatron_make_image("mymod_penguin_image_1", "__adamo-chemical__/graphics/informatron/pengiun.png", 200, 200)
|
||
|
"mymod_penguin_image_1" must be unique per image.
|
||
|
"__adamo-chemical__/graphics/informatron/page_1_image.png" is the path to your image.
|
||
|
200, 200 is the width, height of the image
|
||
|
]]--
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
-- if page_name == "editor" then
|
||
|
-- element.add{type="label", name="text_1", caption={"informatron.page_editor_text_1"}}
|
||
|
-- end
|
||
|
--
|
||
|
-- if page_name == "console" then
|
||
|
-- element.add{type="label", name="text_1", caption={"informatron.page_console_text_1"}}
|
||
|
-- element.add{type="label", name="text_2", caption={"informatron.page_console_text_2"}, style="heading_1_label"}
|
||
|
-- element.add{type="label", name="text_3", caption={"informatron.page_console_text_3"}}
|
||
|
-- element.add{type="label", name="text_4", caption={"informatron.page_console_text_4"}, style="heading_1_label"}
|
||
|
--
|
||
|
-- element.add{type="label", name="text_scripting_intro", caption={"informatron.page_console_text_scripting_intro"}}
|
||
|
--
|
||
|
-- element.add{type="text-box", name="code_editor", text="/editor"}
|
||
|
--
|
||
|
-- element.add{type="label", name="label_editor", caption={"informatron.page_console_text_command_editor"}}
|
||
|
--
|
||
|
-- element.add{type="text-box", name="code_indestructible", text="/c game.player.character.destructible=false"}
|
||
|
-- element.add{type="label", name="label_indestructible", caption={"informatron.page_console_text_command_indestructible"}}
|
||
|
--
|
||
|
-- element.add{type="text-box", name="code_cheat", text="/c game.player.cheat_mode=true"}
|
||
|
-- element.add{type="label", name="label_cheat", caption={"informatron.page_console_text_command_cheat"}}
|
||
|
--
|
||
|
-- element.add{type="text-box", name="code_item", text="/c game.player.insert{name=\"infinity-chest\",count=1}"}
|
||
|
-- element.add{type="label", name="label_item", caption={"informatron.page_console_text_command_item"}}
|
||
|
--
|
||
|
-- element.add{type="text-box", name="code_teleport", text="/c game.player.teleport({0,0})"}
|
||
|
-- element.add{type="label", name="label_teleport", caption={"informatron.page_console_text_command_teleport"}}
|
||
|
--
|
||
|
-- local code_chart = element.add{type="text-box", name="code_chart", text="/c local radius=300 game.player.force.chart(game.player.surface, {{game.player.position.x-radius, game.player.position.y-radius}, {game.player.position.x+radius, game.player.position.y+radius}})"}
|
||
|
-- code_chart.word_wrap = true
|
||
|
-- code_chart.style.height = 50
|
||
|
-- element.add{type="label", name="label_chart", caption={"informatron.page_console_text_command_chart"}}
|
||
|
--
|
||
|
-- element.add{type="text-box", name="code_speed", text="/c game.speed=10"}
|
||
|
-- element.add{type="label", name="label_speed", caption={"informatron.page_console_text_command_speed"}}
|
||
|
--
|
||
|
-- element.add{type="text-box", name="code_set_evolution", text="/c game.forces[\"enemy\"].evolution_factor=0.5"}
|
||
|
-- element.add{type="label", name="label_set_evolution", caption={"informatron.page_console_text_command_set_evolution"}}
|
||
|
--
|
||
|
-- element.add{type="text-box", name="code_recipes", text="/c for name, recipe in pairs(game.player.force.recipes) do recipe.enabled = true end"}
|
||
|
-- element.add{type="label", name="label_recipes", caption={"informatron.page_console_text_command_recipes"}}
|
||
|
--
|
||
|
-- element.add{type="text-box", name="code_research", text="/c game.player.force.research_all_technologies()"}
|
||
|
-- element.add{type="label", name="label_research", caption={"informatron.page_console_text_command_research"}}
|
||
|
--
|
||
|
-- element.add{type="label", name="text_scripting_outro", caption={"informatron.page_console_text_scripting_outro"}}
|
||
|
--
|
||
|
-- for _, child in pairs(element.children) do
|
||
|
-- if child.type == "text-box" then
|
||
|
-- child.read_only = true
|
||
|
-- child.style.horizontally_stretchable = true
|
||
|
-- child.style.vertically_stretchable = true
|
||
|
-- child.style.top_margin = 15
|
||
|
-- end
|
||
|
-- end
|