Merge pull request #2299 from IvarK/fix/automator-fixes

Fix/automator fixes
This commit is contained in:
IvarK 2022-03-16 21:03:16 +02:00 committed by GitHub
commit 25c066e451
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 122 additions and 41 deletions

View File

@ -163,8 +163,6 @@ export class AutomatorScript {
}
export const AutomatorData = {
// 1 is the ID for the documentation page
currentInfoPane: 1,
// Used for getting the correct EC count in event log
lastECCompletionCount: 0,
// Used as a flag to make sure that wait commands only add one entry to the log instead of every execution attempt

View File

@ -190,8 +190,8 @@ export const AutomatorCommands = ((() => {
: undefined;
const xHighest = ctx.xHighest ? ctx.xHighest[0].children.$value : undefined;
const fixedAmount = ctx.currencyAmount
? `${ctx.currencyAmount[0].children.NumberLiteral[0].image}
${ctx.currencyAmount[0].children.AutomatorCurrency[0].image}`
? `${ctx.currencyAmount[0].children.NumberLiteral[0].image}` +
` ${ctx.currencyAmount[0].children.AutomatorCurrency[0].image.toUpperCase()}`
: undefined;
const on = Boolean(ctx.On);
let input = "";
@ -489,9 +489,13 @@ export const AutomatorCommands = ((() => {
return AUTOMATOR_COMMAND_STATUS.NEXT_TICK_NEXT_INSTRUCTION;
};
},
blockify: ctx => automatorBlocksMap[
ctx.PrestigeEvent[0].tokenType.name.toUpperCase()
]
blockify: ctx => ({
...automatorBlocksMap[
ctx.PrestigeEvent[0].tokenType.name.toUpperCase()
],
wait: ctx.Nowait === undefined,
respec: ctx.Respec !== undefined
})
},
{
id: "startDilation",
@ -656,6 +660,7 @@ export const AutomatorCommands = ((() => {
},
blockify: ctx => ({
inputValue: ctx.$studies.image,
wait: ctx.Nowait === undefined,
...automatorBlocksMap.STUDIES
})
},
@ -722,6 +727,7 @@ export const AutomatorCommands = ((() => {
},
blockify: ctx => ({
inputValue: ctx.$presetIndex,
wait: ctx.Nowait === undefined,
...automatorBlocksMap.LOAD
})
},
@ -803,8 +809,9 @@ export const AutomatorCommands = ((() => {
return AUTOMATOR_COMMAND_STATUS.NEXT_TICK_SAME_INSTRUCTION;
};
},
blockify: () => ({
blockify: ctx => ({
target: "DILATION",
wait: ctx.Nowait === undefined,
...automatorBlocksMap.UNLOCK
})
},
@ -842,6 +849,7 @@ export const AutomatorCommands = ((() => {
blockify: ctx => ({
target: "EC",
inputValue: ctx.eternityChallenge[0].children.$ecNumber,
wait: ctx.Nowait === undefined,
...automatorBlocksMap.UNLOCK
})
},

View File

@ -467,8 +467,9 @@ window.player = {
scripts: {
},
execTimer: 0,
type: AUTOMATOR_TYPE.TEXT,
type: AUTOMATOR_TYPE.BLOCK,
forceUnlock: false,
currentInfoPane: 4
},
achTimer: 0,
},

View File

@ -2,7 +2,8 @@ export const TUTORIAL_STATE = {
DIM1: 0,
DIM2: 1,
DIMBOOST: 2,
GALAXY: 3
GALAXY: 3,
AUTOMATOR: 4
};
// Tutorial has two ways of moving on, either by Tutorial.moveOn() or by having it's condition be true
@ -24,6 +25,10 @@ const tutorialStates = [
{
id: TUTORIAL_STATE.GALAXY,
condition: () => AntimatterDimension(8).amount.gte(80)
},
{
id: TUTORIAL_STATE.AUTOMATOR,
condition: () => Player.automatorUnlocked
}
];

View File

@ -3,7 +3,7 @@
}
.c-automator-tab {
height: 50rem;
height: 57rem;
width: 100rem;
}

View File

@ -77,6 +77,13 @@ export const BlockAutomator = {
.replace("COMMENT", "//")
.replace("BLOB", "blob ");
if (block.canWait && block.wait === false) {
if (block.cmd === "LOAD") {
parsed = parsed
.replace("STUDIES LOAD PRESET", "STUDIES NOWAIT LOAD PRESET");
} else parsed += ` NOWAIT`;
}
if (block.respec) parsed += ` RESPEC`;
if (block.target) parsed += ` ${block.target}`;
if (block.secondaryTarget) parsed += ` ${block.secondaryTarget}`;
if (block.inputValue) parsed += ` ${block.inputValue}`;

View File

@ -67,12 +67,14 @@ export const automatorBlocks = [
nested: true
}, {
cmd: "STUDIES",
hasInput: true
hasInput: true,
canWait: true
}, {
cmd: "UNLOCK",
targets: ["EC", "DILATION"],
hasInput: true,
targetsWithoutInput: ["DILATION"]
targetsWithoutInput: ["DILATION"],
canWait: true
}, {
cmd: "START",
targets: ["EC", "DILATION"],
@ -97,14 +99,21 @@ export const automatorBlocks = [
}, {
cmd: "RESPEC"
}, {
cmd: "INFINITY"
cmd: "INFINITY",
canRespec: true,
canWait: true
}, {
cmd: "ETERNITY"
cmd: "ETERNITY",
canRespec: true,
canWait: true
}, {
cmd: "REALITY"
cmd: "REALITY",
canRespec: true,
canWait: true
}, {
cmd: "LOAD",
hasInput: true
hasInput: true,
canWait: true
}, {
cmd: "NOTIFY",
hasInput: true
@ -124,23 +133,31 @@ export const automatorBlocksMap = automatorBlocks.mapToObject(b => b.cmd, b => b
</script>
<template>
<draggable
:list="blocks"
:group="{ name: 'code-blocks', pull: 'clone', put: false }"
:sort="false"
:clone="clone"
style="display: flex; align-items: center; flex-wrap: wrap;"
>
<div
v-for="block in blocks"
:key="block.id"
class="o-automator-command o-automator-block-list"
<div>
<p>Drag and drop these blocks to the area on the left!</p>
<draggable
class="block-container"
:list="blocks"
:group="{ name: 'code-blocks', pull: 'clone', put: false }"
:sort="false"
:clone="clone"
>
{{ block.cmd }}
</div>
</draggable>
<div
v-for="block in blocks"
:key="block.id"
class="o-automator-command o-automator-block-list"
>
{{ block.cmd }}
</div>
</draggable>
</div>
</template>
<style scoped>
.block-container {
margin: 1rem 0;
display: flex;
align-items: center;
flex-wrap: wrap;
}
</style>

View File

@ -80,7 +80,7 @@ export default {
},
watch: {
infoPaneID(newValue) {
AutomatorData.currentInfoPane = newValue;
player.reality.automator.currentInfoPane = newValue;
}
},
created() {
@ -94,7 +94,7 @@ export default {
},
methods: {
update() {
this.infoPaneID = AutomatorData.currentInfoPane;
this.infoPaneID = player.reality.automator.currentInfoPane;
this.isBlockAutomator = player.reality.automator.type === AUTOMATOR_TYPE.BLOCK;
this.errorCount = AutomatorData.currentErrors().length;
this.runningScriptID = AutomatorBackend.state.topLevelScript;

View File

@ -41,8 +41,8 @@ export default {
currentScript() {
return CodeMirror.Doc(this.currentScriptContent, "automato").getValue();
},
modeIconClass() {
return this.automatorType === AUTOMATOR_TYPE.BLOCK ? "fa-cubes" : "fa-code";
blockSelected() {
return this.automatorType === AUTOMATOR_TYPE.BLOCK;
},
isTextAutomator() {
return this.automatorType === AUTOMATOR_TYPE.TEXT;
@ -57,6 +57,9 @@ export default {
if (this.automatorType === AUTOMATOR_TYPE.BLOCK) return "Switch to the text editor";
return "Switch to the block editor";
},
tutorialClass() {
return Tutorial.glowingClass(TUTORIAL_STATE.AUTOMATOR);
}
},
created() {
EventHub.ui.on(GAME_EVENT.GAME_LOAD, () => this.onGameLoad(), this);
@ -103,13 +106,16 @@ export default {
},
toggleAutomatorMode() {
const scriptID = ui.view.tabs.reality.automator.editorScriptID;
Tutorial.moveOn(TUTORIAL_STATE.AUTOMATOR);
if (this.automatorType === AUTOMATOR_TYPE.BLOCK) {
// This saves the script after converting it.
BlockAutomator.parseTextFromBlocks();
player.reality.automator.type = AUTOMATOR_TYPE.TEXT;
if (player.reality.automator.currentInfoPane === 4) player.reality.automator.currentInfoPane = 1;
} else if (BlockAutomator.fromText(this.currentScriptContent)) {
AutomatorBackend.saveScript(scriptID, AutomatorTextUI.editor.getDoc().getValue());
player.reality.automator.type = AUTOMATOR_TYPE.BLOCK;
player.reality.automator.currentInfoPane = 4;
} else {
Modal.message.show("Automator script has errors, cannot convert to blocks.");
}
@ -125,7 +131,14 @@ export default {
<AutomatorControls />
<AutomatorButton
v-tooltip="automatorModeTooltip"
:class="modeIconClass"
class="fa-cubes remove-margin-right"
:class="{ 'not-selected': !blockSelected, ...tutorialClass }"
@click="toggleAutomatorMode()"
/>
<AutomatorButton
v-tooltip="automatorModeTooltip"
class="fa-code remove-margin-left"
:class="{ 'not-selected': blockSelected, ...tutorialClass }"
@click="toggleAutomatorMode()"
/>
</div>
@ -138,5 +151,15 @@ export default {
</template>
<style scoped>
.not-selected {
opacity: 0.3;
}
.remove-margin-left {
margin-left: -0.2rem; /* negate the border */
}
.remove-margin-right {
margin-right: -0.2rem; /* negate the border */
}
</style>

View File

@ -90,15 +90,15 @@ export default {
},
validateInput(value) {
let validator, lines;
const defines = BlockAutomator.lines.filter(line => line.cmd === "DEFINE");
if (this.b.nest) {
const clone = Object.assign({}, this.b);
clone.nest = [];
lines = BlockAutomator.parseLines([clone]);
lines = BlockAutomator.parseLines([...defines, clone]);
validator = AutomatorGrammar.validateLine(lines.join("\n"));
} else {
lines = BlockAutomator.parseLines([this.b]);
validator = AutomatorGrammar.validateLine(lines[0]);
lines = BlockAutomator.parseLines([...defines, this.b]);
validator = AutomatorGrammar.validateLine(lines.join("\n"));
}
this.idxOffset = lines[0].indexOf(value);
@ -121,6 +121,28 @@ export default {
<div class="o-automator-command">
{{ b.cmd }}
</div>
<select
v-if="b.canWait"
v-model="b.wait"
class="o-automator-block-input"
@change="updateBlock(block, b.id)"
>
<option :value="true" />
<option :value="false">
NOWAIT
</option>
</select>
<select
v-if="b.canRespec"
v-model="b.respec"
class="o-automator-block-input"
@change="updateBlock(block, b.id)"
>
<option :value="false" />
<option :value="true">
RESPEC
</option>
</select>
<select
v-if="b.targets"
v-model="b.target"