Skip to content

Commit 8b99101

Browse files
committed
feat: add new instance properties from updated offsets (v0.1.8)
- Add Humanoid properties: JumpHeight, HipHeight, MaxSlopeAngle, RigType, FloorMaterial, Jump, MoveDirection, AutoRotate - Add BasePart properties: Transparency, Color, Anchored, CanCollide, CanTouch - Add AssemblyLinearVelocity and AssemblyAngularVelocity (Velocity as alias) - Add GuiObject properties: RichText, BackgroundColor3, BorderColor3, TextColor3, Rotation - Add Player properties: Country, MinZoomDistance, MaxZoomDistance, CameraMode - Add Camera properties: CameraType, CameraSubject - Add DataModel.PlaceVersion and Workspace.DistributedGameTime - Add Color3 datastructure with conversion methods (ToHex, ToRGB, ToHSV, etc.)
1 parent 832ed40 commit 8b99101

3 files changed

Lines changed: 599 additions & 6 deletions

File tree

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "robloxmemoryapi"
7-
version = "0.1.7"
7+
version = "0.1.8"
88
description = "Python Library that abstracts reading and writing data from the Roblox DataModel"
99
readme = { file = "README.md", content-type = "text/markdown" }
1010
requires-python = ">=3.9"

‎src/robloxmemoryapi/utils/rbx/datastructures.py‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,96 @@ def __eq__(self, other):
4747
and self.Y == other.Y
4848
)
4949

50+
class Color3:
51+
def __init__(self, r=0, g=0, b=0):
52+
self.R = float(r)
53+
self.G = float(g)
54+
self.B = float(b)
55+
56+
def __repr__(self):
57+
return f"{self.R}, {self.G}, {self.B}"
58+
59+
def __eq__(self, other):
60+
return (
61+
isinstance(other, Color3)
62+
and self.R == other.R
63+
and self.G == other.G
64+
and self.B == other.B
65+
)
66+
67+
def __add__(self, other):
68+
if isinstance(other, Color3):
69+
return Color3(self.R + other.R, self.G + other.G, self.B + other.B)
70+
raise TypeError("Color3 can only be added to Color3")
71+
72+
def __sub__(self, other):
73+
if isinstance(other, Color3):
74+
return Color3(self.R - other.R, self.G - other.G, self.B - other.B)
75+
raise TypeError("Color3 can only be subtracted by Color3")
76+
77+
def __mul__(self, other):
78+
if isinstance(other, (int, float)):
79+
return Color3(self.R * other, self.G * other, self.B * other)
80+
if isinstance(other, Color3):
81+
return Color3(self.R * other.R, self.G * other.G, self.B * other.B)
82+
raise TypeError("Color3 can only be multiplied by Color3 or a number")
83+
84+
__rmul__ = __mul__
85+
86+
def __truediv__(self, other):
87+
if isinstance(other, (int, float)):
88+
return Color3(self.R / other, self.G / other, self.B / other)
89+
if isinstance(other, Color3):
90+
return Color3(self.R / other.R, self.G / other.G, self.B / other.B)
91+
raise TypeError("Color3 can only be divided by Color3 or a number")
92+
93+
def __neg__(self):
94+
return Color3(-self.R, -self.G, -self.B)
95+
96+
def ToHex(self):
97+
return f"#{int(self.R * 255):02x}{int(self.G * 255):02x}{int(self.B * 255):02x}"
98+
99+
def ToTuple(self):
100+
return (self.R, self.G, self.B)
101+
102+
def ToVector3(self):
103+
return Vector3(self.R, self.G, self.B)
104+
105+
def ToRGB(self):
106+
return (int(self.R * 255), int(self.G * 255), int(self.B * 255))
107+
108+
def ToHSV(self):
109+
maxc = max(self.R, self.G, self.B)
110+
minc = min(self.R, self.G, self.B)
111+
112+
if maxc == minc:
113+
return (0, 0, maxc)
114+
115+
h = 0
116+
if maxc == self.R:
117+
h = (self.G - self.B) / (maxc - minc)
118+
elif maxc == self.G:
119+
h = 2 + (self.B - self.R) / (maxc - minc)
120+
else:
121+
h = 4 + (self.R - self.G) / (maxc - minc)
122+
123+
return (h / 6, maxc, minc)
124+
125+
def ToCMYK(self):
126+
if self.R == 0 and self.G == 0 and self.B == 0:
127+
return (0, 0, 0, 1)
128+
129+
c = 1 - self.R
130+
m = 1 - self.G
131+
y = 1 - self.B
132+
k = min(c, m, y)
133+
134+
return (c, m, y, k)
135+
136+
def ToCMY(self):
137+
return (1 - self.R, 1 - self.G, 1 - self.B)
138+
139+
50140
class Vector3:
51141
def __init__(self, x=0, y=0, z=0):
52142
self.X = float(x)

0 commit comments

Comments
 (0)