Cool! I started to create a "Base capacities" widget that is used in transfer and market screens, to play with the LUA scripts. It is in very early stage, doesn't worth showing the current state but found some "could be improved" parts with it already. (Disclaimer: I'm no LUA expert.)
1. Simplify initialization
As I mentioned creating nodes is boring. Let's see, if I need 3 labels as a table header:
local building_head = ufo.create_string(box, "building_head", nil)
building_head:set_box(0, 20, 150, 20)
building_head:set_font("f_very_small_bold")
building_head:set_contentalign(ufo.ALIGN_CC)
building_head:set_longlines(ufo.LONGLINES_PRETTYCHOP)
building_head:set_text("_Building")
This is just one. I need 3 copies. To save my fingers I'll copy&paste&modify it. I'll have to replace building_head 7 times.
What if instead we could write:
local building_head = ufo.create_string(box, "building_head", {
["super"] = nil,
["box"] = { 0, 20, 150, 20 },
["font"] = "f_very_small_bold",
["contentalign"] = ufo.ALIGN_CC,
["longlines"] = ufo.LONGLINES_PRETTYCHOP,
["text"] = "_Building"
})
Less risk in mistyping or forget to replace building_head.
Also if I have a panel and would like to create nodes inside it, it would be so natural using the panel's method to create subnodes:
local row = ufo.create_component("panel", "cmp_basecap_line", nil)
local building = row:create_string("building", nil)
local freespace = row:create_string("freespace", nil)
local allspace = row:create_string("allspace", nil)
But currently we need the long form.
-geever