lib Namespace

The functions in this namespace provide support for common things that a script may do. This namespace is available for biome conditions, acoustic filtering, and chance percentages.

Object lib.iif(boolean result, Object trueResult, Object falseResult)

Selects an object based on a boolean result.

Arguments:
  • result (Boolean()) – A boolean valuethat is used to make a result selection

  • trueResult (Object()) – The object to return if the result is true

  • falseResult (Object()) – The object to return if the result is false

Returns:

trueResult or falseResult depending on the value of result.

Return type:

Object

Boolean lib.match(String pattern, String input)

Determines if the input matches the regular expression.

Arguments:
  • pattern (String()) – Regular expression to use for matching

  • input (String()) – The input to tapestry

Returns:

Applies the provided regular expression pattern to determine if input is a match.

Return type:

Boolean

Boolean lib.oneof(Object input, Object... possibles)

Determines of the input object is contained within the possible array.

Arguments:
  • input (Object()) – The input object of interest

  • possibles (Array()) – The possible values to check for

Returns:

true if input matches one of the possible objects, false otherwise

Return type:

Boolean

Boolean lib.isBetween(Double value, Double min, Double max)

Determines if the value is in between the min and max values, inclusive.

Arguments:
  • value (Double()) – The value to check for

  • min (Double()) – The minimum value of the interval

  • max (Double()) – The maximum value of the interval

Returns:

true if value is between min and max, inclusive.

Return type:

Boolean

Boolean lib.isModLoaded(String modId)

Indicates whether the specified mod is loaded.

Arguments:
  • modId (String()) – The ID of the mod to test for

Returns:

true if the mod is present, false otherwise

Return type:

Boolean