0 Members and 1 Guest are viewing this topic.
rem Gets the connector that contains the connector namerem provided. rem returns the connector with that type, or null if rem none were found.function firstConnectorOfType(item, connectorName) dim result dim i for i=1 to item.connectors if contains(item.connector[i].value, connectorName) then result = item.connector[i] end if next return resultend functionrem Unlocks the connector, sets it, then locks the connector again.function changeConnector(connector, connectorName) connector.locked = false connector.value = connectorName connector.locked = trueend function
dim width = "Width"
function width() return "Width"end function
if item.dim[width()].numvalue > 24 thenrem whatever
function changeConnector(connector, connectorName) connector.locked = false connector.value = connectorName connector.locked = trueend function
And now I can reuse it wherever. But it feels a bit weird to write.
Dim LengthDim = Item.Dim["Length"]
rem Safely checks to see if the dimension, by namerem exists on the item. It does this using a forrem for loop. This helps to avoid errors becauserem a dimension does not exist by name on the item.function hasDimension(item, dimension) dim result dim i for i=1 to item.dims if item.dim[i].name = dimension then result = true end if next return resultend function