Skip to content

Commit 5594b6d

Browse files
committed
Added UDim2 nodes
1 parent 4386767 commit 5594b6d

6 files changed

Lines changed: 110 additions & 0 deletions

File tree

nodes/udim2/udim2fromoffset.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"type": "FUNCTION",
3+
"color": [
4+
150,
5+
100,
6+
255
7+
],
8+
"title": "UDim2 From Offset",
9+
"inputs": {
10+
"x": {
11+
"defaultValue": "100"
12+
},
13+
"y": {
14+
"defaultValue": "100"
15+
}
16+
},
17+
"outputs": [
18+
"udim2"
19+
]
20+
}

nodes/udim2/udim2fromscale.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"type": "FUNCTION",
3+
"color": [
4+
150,
5+
100,
6+
255
7+
],
8+
"title": "UDim2 From Scale",
9+
"inputs": {
10+
"x": {
11+
"defaultValue": "0.5"
12+
},
13+
"y": {
14+
"defaultValue": "0.5"
15+
}
16+
},
17+
"outputs": [
18+
"udim2"
19+
]
20+
}

nodes/udim2/udim2new.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"type": "FUNCTION",
3+
"color": [
4+
150,
5+
100,
6+
255
7+
],
8+
"title": "UDim2 New",
9+
"inputs": {
10+
"scaleX": {
11+
"defaultValue": "0"
12+
},
13+
"offsetX": {
14+
"defaultValue": "0"
15+
},
16+
"scaleY": {
17+
"defaultValue": "0"
18+
},
19+
"offsetY": {
20+
"defaultValue": "0"
21+
}
22+
},
23+
"outputs": [
24+
"udim2"
25+
]
26+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from typing import Optional
2+
from src.Node import Node
3+
4+
class UDim2FromOffset(Node):
5+
def __init__(self) -> None:
6+
super().__init__("nodes/udim2/udim2fromoffset.json")
7+
8+
def toLuau(self) -> Optional[str]:
9+
x = self.getInputValue("x") or "100"
10+
y = self.getInputValue("y") or "100"
11+
12+
r = f'UDim2.fromOffset({x}, {y})'
13+
14+
self.setOutputValue("udim2", r)

src/models/udim2/UDim2FromScale.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from typing import Optional
2+
from src.Node import Node
3+
4+
class UDim2FromScale(Node):
5+
def __init__(self) -> None:
6+
super().__init__("nodes/udim2/udim2fromscale.json")
7+
8+
def toLuau(self) -> Optional[str]:
9+
x = self.getInputValue("x") or "0.5"
10+
y = self.getInputValue("y") or "0.5"
11+
12+
r = f'UDim2.fromScale({x}, {y})'
13+
14+
self.setOutputValue("udim2", r)

src/models/udim2/UDim2New.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from typing import Optional
2+
from src.Node import Node
3+
4+
class UDim2New(Node):
5+
def __init__(self) -> None:
6+
super().__init__("nodes/udim2/udim2new.json")
7+
8+
def toLuau(self) -> Optional[str]:
9+
scale_x = self.getInputValue("scaleX") or "0"
10+
offset_x = self.getInputValue("offsetX") or "0"
11+
scale_y = self.getInputValue("scaleY") or "0"
12+
offset_y = self.getInputValue("offsetY") or "0"
13+
14+
r = f'UDim2.new({scale_x}, {offset_x}, {scale_y}, {offset_y})'
15+
16+
self.setOutputValue("udim2", r)

0 commit comments

Comments
 (0)