Skip to content

Commit

Permalink
Merge pull request #344 from netux/feature/math-fuckton-of-spaces
Browse files Browse the repository at this point in the history
Add Math.FUCKTON_OF_SPACES constant
  • Loading branch information
CactusPuppy authored Nov 20, 2023
2 parents 517f665 + daa9a1f commit 1029c0e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/compiler/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,8 @@ function parseMember(object, member) {
return getAstForNumber(0.94965);
} else if (name === "RING_EXPLOSION_RADIUS_MULT") {
return getAstForNumber(0.48);
} else if (name === "FUCKTON_OF_SPACES" || name === "LOTS_OF_SPACES") {
return getAstForCustomString(" ".repeat(170));
} else {
error("Unhandled member 'math."+name+"'");
}
Expand Down
12 changes: 12 additions & 0 deletions src/data/opy/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ const opyConstants = {
"isConstant": true,
return: "unsigned float",
},
"FUCKTON_OF_SPACES": {
"description": "170 Em Spaces (U+2003). Add this to the end of a HUD text to ensure it will always be left-aligned.",
"args": null,
"isConstant": true,
return: "string"
},
"LOTS_OF_SPACES": {
"description": "170 Em Spaces (U+2003). Add this to the end of a HUD text to ensure it will always be left-aligned.",
"args": null,
"isConstant": true,
return: "string"
},
"INFINITY": {
"description": "The number infinity = 9999999999999999999.",
"args": null,
Expand Down
1 change: 1 addition & 0 deletions src/tests/builtinenums.opy
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ rule "enums":
I = Math.E
J = Math.PI
K = Color.BLUE
S = Math.FUCKTON_OF_SPACES
2 changes: 2 additions & 0 deletions src/tests/results/builtinenums.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ variables {
8: I
9: J
10: K
18: S
}
rule ("enums") {
event {
Expand All @@ -37,6 +38,7 @@ rule ("enums") {
Set Global Variable(I, 2.718281828459045);
Set Global Variable(J, 3.141592653589793);
Set Global Variable(K, Color(Blue));
Set Global Variable(S, Custom String("                                                                                                                                                                          ", Null, Null, Null));
}
}

13 changes: 13 additions & 0 deletions src/utils/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,16 @@ function getAstForNullVector() {
function getAstForCurrentArrayIndex() {
return new Ast("__currentArrayIndex__");
}
function getAstForCustomString(content, formatArgs = []) {
const [
arg1 = getAstForNull(),
arg2 = getAstForNull(),
arg3 = getAstForNull()
] = formatArgs;
return new Ast("__customString__", [
new Ast(content, [], [], "CustomStringLiteral"),
arg1,
arg2,
arg3
]);
}

1 comment on commit 1029c0e

@nathan130200
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk why blizzard still haven't fixed this issue with HUD texts alignment. Seems they just completed abandoned workshop but didn't removed because we're still using 😭

Please sign in to comment.