- Name: Poly Modding Framework
- Version: 0.1.0
- Factorio-Version: 1.1.61
- Description:
- License: MIT
- Release: 2022-08-20
- Download-Url: Download
- Website: https://biterunion.github.io/poly
- Dependencies: None.
- Category: Lib.
I started writing a base planner mod a few weeks ago and realized that I spent most of my time writing boring, boilerplate GUI code. To speed-up implementation and also to have a more clean and structured approach to GUIs, I moved all GUI code to a separate framework mod. This has now evolved into a first proof-of-concept implementation called Poly: https://mods.factorio.com/mod/poly.
The main advantage of Poly (in my opinion) is that it allows to write GUIs in a declarative style instead of LuaGuiElement's low-level imperative style. This allows for cleaner code that is much easier to understand. This is a simple example to give you an idea how it looks:
Poly also has convenient APIs for event handling and managing multiple windows, e.g., to show modal dialogs. You can find more details in the docs.Code: Select all
Window:new { -- configure window's titlebar titlebar = { title = 'Counter' }, -- add content to the window Frame:new { name = 'content', direction = 'horizontal', style = { 'inside_shallow_frame_with_padding' }, Flow:new { name = 'counter', style = 'player_input_horizontal_flow', Label:new { name = 'counter_caption', caption = 'My Counter' }, -- add button for opening CaptionDialog SpriteButton:new { style = 'tool_button', sprite = 'utility/rename_icon_normal', on_gui_click = EventHandler:register(WindowManager, 'open', -- WindowManager:open's arguments: WindowManager.Anchor.screen(player), CaptionDialog) }, SpinnerLabel:new { name = 'counter_value', initial_value = 0 } } } }
I wanted to post this here to maybe get some feedback.
Is there any demand for a framework like this?
What do you think of the declarative style?
Do you have any suggestions?
Poly Modding Framework
- BiterUnion
- Inserter
- Posts: 21
- Joined: Fri Aug 19, 2022 7:58 am
- Contact:
Poly Modding Framework
Mod-Info-Header
Re: Poly Modding Framework
On the surface, this looks similar to the gui framework provided in Factorio Library (FLIB), used by mods like Factory Planner, in a more compact style. It will be interesting to see the differences in implemtation and developer preference. Thank you for sharing!
My mods: Multiple Unit Train Control, Smart Artillery Wagons
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
- BiterUnion
- Inserter
- Posts: 21
- Joined: Fri Aug 19, 2022 7:58 am
- Contact:
Re: Poly Modding Framework
I didn't know about flib, thanks for the link! It does indeed look quite similar.
- BiterUnion
- Inserter
- Posts: 21
- Joined: Fri Aug 19, 2022 7:58 am
- Contact:
Re: Poly Modding Framework
I had a closer look at flib and think I have a better understanding now of the differences to my mod. My goal for Poly is to provide concepts on how to implement whole aspects of mods (e.g. multiple GUIs or how to store data in global in a concise way) instead of loosely coupled utilities like in flib. I think there are use-cases for both approaches.
I am currently working on cleaning up and testing my proof-of-concept implementation and will post updates once new functionality has been added.
I am currently working on cleaning up and testing my proof-of-concept implementation and will post updates once new functionality has been added.