diff --git a/technic/doc/api.md b/technic/doc/api.md index e79b42f..4cc22cb 100644 --- a/technic/doc/api.md +++ b/technic/doc/api.md @@ -27,7 +27,11 @@ Helper functions * Tells whether the node `nodename` is the cable of the tier `tier`. * `technic.get_cable_tier(nodename)` * Returns the tier of the cable `nodename` or `nil`. -* `technic.trace_node_ray(pos, dir, range)` +* `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 + * `technic.trace_node_ray(pos, dir, range)` * Returns an iteration function (usable in the for loop) to iterate over the node positions along the specified ray. * The returned positions will not include the starting position `pos`. diff --git a/technic/machines/register/cables.lua b/technic/machines/register/cables.lua index 607849f..7e1ce6c 100644 --- a/technic/machines/register/cables.lua +++ b/technic/machines/register/cables.lua @@ -9,6 +9,13 @@ function technic.get_cable_tier(nodename) return cable_tier[nodename] 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 item_place_override_node(itemstack, placer, pointed, node) -- Call the default on_place function with a fake itemstack local temp_itemstack = ItemStack(itemstack)