structures¶
Module containing basic and general structures that occur in Terraria save files.
It has three submodules, each containing a different structure:
color¶
Submodule for color structures.
- class lihzahrd.terraria.utils.structures.color.ColorRGB(*, r: int, g: int, b: int)¶
- class lihzahrd.terraria.utils.structures.color.ColorRGB(*, r: float, g: float, b: float)
- class lihzahrd.terraria.utils.structures.color.ColorRGB(*, h: str)
An opaque 24-bit color.
Can be created from RGB integers (0-255), from RGB floats (0.0-1.0), or from a hex code.
Creating from RGB integers¶
RGB integers are converted to floats via
component / 255.Warning
No checks are performed to make sure the components are within the expected ranges (
0-255)!- param r:
Red component.
- param g:
Green component.
- param b:
Blue component.
Creating from RGB floats¶
RGB floats are stored directly in the structure, without being altered.
Warning
No checks are performed to make sure the components are within the expected ranges (
0.0-1.0)!- param r:
Red component.
- param g:
Green component.
- param b:
Blue component.
Creating from hex code¶
Hex codes are converted to RGB floats via
int(h[n:n+2], 16) / 255.Trailing
#are optionally stripped.Warning
No checks are performed to make sure the hex code is valid!
- param h:
Hex color.
Attributes and methods¶
coordinates¶
Submodule for pairs of coordinates.
- class lihzahrd.terraria.utils.structures.coordinates.Coordinates(x: Value, y: Value)¶
A pair of coordinates of the generic type
InternalValue.In Terraria worlds,
InternalValuewill be eitherfloat(usually when referring to entities) orint(usually when referring to tiles).- x: Value¶
The horizontal coordinate, with the negative axis being left, and the positive axis being right.
- y: Value¶
The vertical coordinate, with the negative axis being up, and the negative axis being down.
- __eq__(other: Any) bool¶
- Returns:
If compared with other
Coordinates, whether both individual coordinates are equal. Otherwise,NotImplemented.
- __ne__(other: Any) bool¶
- Returns:
If compared with other
Coordinates, whether either coordinate is not equal to its corrispective. Otherwise,NotImplemented.
rectangle¶
Submodule for rectangle structures.
- class lihzahrd.terraria.utils.structures.rectangle.Rectangle(left: Value, right: Value, top: Value, bottom: Value)¶
A rectangle of generic type
InternalValuein a cartesian plane, not locked to the origin.In Terraria worlds,
InternalValuewill always beint.- left: Value¶
Coordinate of the left edge of the rectangle.
- right: Value¶
Coordinate of the right edge of the rectangle.
- top: Value¶
Coordinate of the top edge of the rectangle.
- bottom: Value¶
Coordinate of the bottom edge of the rectangle.