Poly Modding Framework
Posted: Sat Aug 20, 2022 2:08 pm
Mod-Info-Header
- 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?