Add technic.register_cable_tier(name, tier) (#294)

Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
This commit is contained in:
Buckaroo Banzai 2022-11-18 05:21:54 +01:00 committed by GitHub
parent c1cf1d0c37
commit ebba32ad25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -27,6 +27,10 @@ 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.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.

View File

@ -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)