LAN and WiFi
LAN and WiFi networks are groups of connected entities that send and receive signals consisting of key:value pairs. Keys may be any text string, including internal item names. Values are integers.
Control Panels form LANs
Control Panels can be manually linked by cables to form a LAN. Cables may be up to 10m long, and pass under other entities.
WiFi Towers form WiFi meshes
WiFi Towers automatically link up with other towers and panels within a 30m radius.
Control Panels run Lua
Control Panels can run Lua scripts which may:
- Monitor and control adjacent entities
- Send and receive on LAN and WiFi networks, if connected
- Define custom input fields in the entity popup window
- Change the color of the panel to indicate status or activity
Lua scripts supply two entry points:
- function main() called each tick
- gui = {...} to declare custom input fields
Lua scripts included
Several Lua scripts are included, ready to go, no custom scripting required. Of course if you like scripting and modding, go nuts.
Example of a customizable constant signal generator:
gui = { title = "Constant signal", description = "Broadcast a steady signal to a network", fields = { network = { title = "Network", type = "string", options = { lan = "LAN", wifi = "Wifi", }, description = "The target network to receive signals", default = "lan", order = "a", }, key = { title = "Name", type = "string", description = "Name of signal to broadcast", default = "", order = "b", }, val = { title = "Value", type = "integer", description = "Value of signal to broadcast", default = 1, order = "c", }, log = { title = "Log Activity", type = "boolean", description = "Periodically log activity to console", default = true, order = "d", }, } } function main() local fields = api.gui_fields() local good_signal = fields.key ~= "" if not good_signal then print("waiting for signal name") api.color(api.colors.warn) api.sleep(api.ups()) return end api.color(api.colors.ok) -- activity log if api.tick() % api.ups() == 0 and fields.log then print("current signal: " .. fields.key .. ":" .. fields.val) end local send = fields.network == "lan" and api.lan_send or api.wifi_send send(fields.key, fields.val) end
The corresponding UI that generates:
Complex networks
Complex networks are possible:
- The LAN to Wifi and Wifi to LAN scripts turn panels into network bridges
- The Warehouse deliveries and Monorail deliveries scripts work together to auto-scale the number of incoming cars to a Monorail Tower stop
- The Entity contents script reads the items in anything -- belt, machine, warehouse, monorail -- and converts them to signals
Factorio's influence
Networks have some aspects in common with Factorio networks:
- Signals with the same key automatically sum on the network. There's no concept of sender id or IP, just aggregated keys and values. If signals were packets they would be a kind of anonymous UDP broadcast
- Signals last one tick and must be resent every tick to be persistent
They differ in some other important ways though:
- A integer-zero signal is valid. The existence of the signal is independent of the value
- The keys are text strings, so while it's easy to use item names as keys, anything goes. If you want to prefix keys with sender id or a namespace for better control, that's fine
Future plans
- A wiki documenting the available API calls, possibly in-game
- More useful scripts will be bundled as they
appear(occur to me!) - The API will be expanded to allow deeper control of crafting machines
- AI Candles in networked clusters will be necessary for late-game
Get middenmoon
middenmoon
That's no moon. It's a giant ball of trash!
Status | In development |
Author | dorfl |
Genre | Simulation, Puzzle |
Tags | 2D, factory |
More posts
- Belt decisions18 hours ago
- Less rough game design3 days ago
- Control Panels17 days ago
- Upgrades27 days ago
- Crossing beams32 days ago
- Messing with Monorails34 days ago
- Rough game design41 days ago
Leave a comment
Log in with itch.io to leave a comment.