From 66e20a9231b9fea823f9b683e495c57ef9a4ad41 Mon Sep 17 00:00:00 2001 From: sfence Date: Fri, 4 Nov 2022 19:23:44 +0100 Subject: [PATCH] Add register_cable_tier API function (#612) --- technic/doc/api.md | 4 ++++ technic/machines/register/cables.lua | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/technic/doc/api.md b/technic/doc/api.md index efbb3ea..e22cc96 100644 --- a/technic/doc/api.md +++ b/technic/doc/api.md @@ -35,6 +35,10 @@ Available functions: * `technic.is_tier_cable(nodename, tier)` * Tells whether the node `nodename` is the cable of the tier `tier`. * Short version of `technic.get_cable_tier(nodename) == tier` +* `technic.register_cable_tier(nodename, tier)` + * Register user defined cable to list of known tier cables. + * `nodename`: string, name of the node + * `tier`: string, tier name ## Machines diff --git a/technic/machines/register/cables.lua b/technic/machines/register/cables.lua index 139a395..95dcaea 100644 --- a/technic/machines/register/cables.lua +++ b/technic/machines/register/cables.lua @@ -11,6 +11,13 @@ function technic.get_cable_tier(name) return cable_tier[name] end +function technic.register_cable_tier(name, tier) + assert(technic.machines[tier], "Tier does not exist") + assert(type(name) == "string", "Invalid node name") + + cable_tier[name] = tier +end + local function check_connections(pos) -- Build a table of all machines local machines = {}