Skip to content

Commit

Permalink
Add register_cable_tier API function (minetest-mods#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfence authored Nov 4, 2022
1 parent 705961e commit 66e20a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions technic/doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions technic/machines/register/cables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down

0 comments on commit 66e20a9

Please sign in to comment.