Fix some miscellaneous automator bugs

This commit is contained in:
SpectralFlame 2023-04-23 20:23:00 -05:00 committed by cyip92
parent d9c3963aa3
commit df14ef7198
3 changed files with 19 additions and 13 deletions

View File

@ -49,9 +49,13 @@ import { AutomatorLexer } from "./lexer";
const commentRule = { regex: /(\/\/|#).*/u, token: "comment", next: "start" };
// Note: This is a state machine which determines the syntax highlighting for the automator. It has no bearing on the
// actual functionality and behavior of the automator itself. Matches to the supplied regexes will color the matched
// text according to the specified color of cm-[token] in liquibyte.css
// This is a state machine which determines the syntax highlighting for the automator. Top-level props define
// the states, the array entries define the transition rules which are checked in order of appearance, and next
// specifies which state to transition to after consuming the given regex. Without an entry for "next" the state
// machine will remain in the same state and run the transition check after consuming the regex. The "next" prop
// in the line with "sol" is a fallback transition which will be followed if none of the rules are matched.
// Matches to the regexes will color the matched text according to the specified color of cm-[token] in liquibyte.css
// Note: This has no bearing on the actual functionality and behavior of the automator itself and is purely visual.
CodeMirror.defineSimpleMode("automato", {
// The start state contains the rules that are intially used
start: [
@ -91,12 +95,12 @@ import { AutomatorLexer } from "./lexer";
studiesList: [
commentRule,
{ sol: true, next: "start" },
{ regex: /t[1-4]/ui, token: "number" },
{ regex: /(antimatter|infinity|time)(?=[\s,]|$)/ui, token: "variable-2" },
{ regex: /(active|passive|idle)(?=[\s,]|$)/ui, token: "variable-2" },
{ regex: /(light|dark)(?=[\s,]|$)/ui, token: "variable-2" },
{ regex: /(antimatter|infinity|time)(?=[\s,|]|$)/ui, token: "number" },
{ regex: /(active|passive|idle)(?=[\s,|]|$)/ui, token: "number" },
{ regex: /(light|dark)(?=[\s,|]|$)/ui, token: "number" },
{ regex: /[1-9][0-9]+(?=[\s,|])/ui, token: "number" },
{ regex: /[a-zA-Z_][a-zA-Z_0-9]*/u, token: "variable", next: "commandDone" },
{ regex: /[1-9][0-9]+/ui, token: "number" },
{ regex: /([1-9]|1[0-2])$/ui, token: "number" },
],
studiesLoad: [
commentRule,

View File

@ -443,15 +443,17 @@ import { AutomatorLexer } from "./lexer";
if (typeof val === "string") return () => player.reality.automator.constants[val];
return () => val;
});
const isLockedCurrency = ctx.compareValue.map(cv => {
// Some currencies are locked and should always evaluate to false if they're attempted to be used
const canUseInComp = ctx.compareValue.map(cv => {
if (cv.children.AutomatorCurrency) {
const unlockedFn = cv.children.AutomatorCurrency[0].tokenType.$unlocked;
return unlockedFn ? unlockedFn() : true;
}
return false;
// In this case, it's a constant (either automator-defined or literal)
return true;
});
if (isLockedCurrency[0] || isLockedCurrency[1]) return false;
if (!canUseInComp[0] || !canUseInComp[1]) return () => false;
const compareFun = ctx.ComparisonOperator[0].tokenType.$compare;
return () => compareFun(getters[0](), getters[1]());
}

View File

@ -459,7 +459,7 @@ GameDatabase.reality.automator = {
<blockquote>commands</blockquote>
}`,
description: `Defines an inner block of the script where commands are repeated; the comparison is checked at the
start and every time the loop repeats. If the condition is false when the UNTIL statement is first reached, the
start and every time the loop repeats. If the condition is true when the UNTIL statement is first reached, the
inner block of commands will be skipped entirely.
<br><br>
If an prestige event (ie. Infinity, Eternity, or Reality) is specified instead of a condition, then the block
@ -480,7 +480,7 @@ GameDatabase.reality.automator = {
<blockquote>commands</blockquote>
}`,
description: `Defines an inner block of the script where commands are repeated; the comparison is checked at the
start and every time the loop repeats. If the condition is false when the WHILE statement is first reached, the
start and every time the loop repeats. If the condition is true when the WHILE statement is first reached, the
inner block of commands will be skipped entirely.`,
examples: [
`while ep < 1e500`,