Control Panels


The current experiment is an entity called a Control Panel which:

  • Can monitor and adjust config of adjacent entities
  • Runs a Lua script that may be chosen on the fly

The first use case was adjusting Monorail stop car limits based on the contents of a nearby warehouse. Low supplies => increase deliveries. Sufficient supplies => reduce deliveries.

function on_tick()
    local cars = 6
 
    -- only adjacent entities are controllable
    local warehouse = api.adjacent_warehouse()
    local monorail = api.adjacent_monorail()
 
    -- stack{item,count}
    for i,stack in ipairs(api.entity_contents(warehouse)) do
        if stack[2] > api.warehouse_capacity(stack[1])/2 then
            cars = 3
        end
    end
  
    -- update stop max cars limit    
    api.monorail_cars(monorail,cars)
 
    -- debug/keepalive output
    if api.tick() % api.ups() == 0 then
        print(cars)
    end
end

The UI is a bit simplistic so far:


Reinventing an IDE in-game isn't that interesting. Instead maintain a library of scripts in a comfy external IDE or editor and import them.

Panels that use the same script can be told to auto-upgrade when a new version (file with the same name) is imported anywhere else in the game, or to stick with a known good version until manually upgraded.

The other lines of text are a scrolling console of print() output prefixed with the tick number.

For those who dislike scripting

Not everyone wants to write scripts though, which is fine. Probably a library of useful scripts comes with the game. Most people pick a pre-packaged script from a list and move on. Like picking mini-mods without the need to reload.

Adjacency limitation

Not sure how this will turn out. Limiting panels to accessing immediately adjacent entities keeps things technically simple and allows some spatial optimisation and parallelisation under the hood (which may be necessary for running Lua per-tick-per-panel with decent performance).

Chasing optimal adjacency does make one think carefully about the layout of other entities which is nice.

Comparison to mods

Not much idea what mods will look like yet or how they would compare to small, focused panel scripts. That's a much bigger scope and feels like a really step hill to start climbing this early in the dev process.

Get middenmoon

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.