Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/renderer/config-blocks/Lookup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
/>

<button
class:invisible={i === 0}
class:invisible={i === 0 && lookupTable.pairs.length === 1}
on:click={() => {
removeLine(i);
}}
Expand Down
26 changes: 15 additions & 11 deletions src/renderer/config-blocks/components/VariableManager.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@
): ScriptSegment[] | undefined {
const processed = preProcessor(statement);
const assignments: ScriptSegment[] = [];
const variableNames = splitParts(processed.split("=")[0]);
const variableValues = splitParts(processed.split("=")[1]);
const variableNames = splitParts(processed.split("=")[0]).map((s) =>
s.trim(),
);
const variableValues = splitParts(processed.split("=")[1]).map((s) =>
s.trim(),
);

if (variableNames.length !== variableValues.length) {
throw new Error("Error parsing variables: mismatched names and values!");
Expand Down Expand Up @@ -148,14 +152,14 @@
}

function addVariable() {
const obj = { name: "", value: "" };
segments.push(obj);
validators.push({
value: false,
func: (e) => new Validator(e).isLuaVariable().Result(),
});
handleInput();
handleChange();
segments = [...segments, { name: "", value: "" }];
validators = [
...validators,
{
value: false,
func: (e) => new Validator(e).isLuaVariable().Result(),
},
];
}

function removeVariable(index: number) {
Expand Down Expand Up @@ -202,7 +206,7 @@
</div>

<button
class:invisible={i === 0}
class:invisible={segments.length === 1}
on:click={() => {
removeVariable(i);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import Indentation from "./Indentation.svelte";
import EditableName from "../../../../config-blocks/components/EditableName.svelte";
import { selected_actions } from "../../../../runtime/selected-actions.store";
import { logger } from "../../../../runtime/runtime.store";
import { get } from "svelte/store";
import { information } from "../../../../config-blocks/CodeBlock.svelte";
import { Modal } from "../../../modals/modal.store";
Expand Down Expand Up @@ -99,10 +100,17 @@
return;
}

logger.set({
type: "alert",
mode: 0,
classname: "luanotok",
message: `Invalid edit discarded. Action block reverted to last valid state.`,
});

updateAction(
action,
new ActionData(action.short, action.synced, action.name),
action.isValid(),
true,
);
}

Expand Down
8 changes: 8 additions & 0 deletions src/renderer/runtime/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,14 @@ export class GridEvent extends RuntimeNode<EventData> {
});
}

if (!this.isValid()) {
return Promise.resolve({
value: true,
text: "Nothing to sync, event has invalid actions.",
type: GridOperationType.SEND_EVENT_TO_GRID,
});
}

const element = this.parent as GridElement;
const page = element.parent as GridPage;
const module = page.parent as GridModule;
Expand Down
Loading