Skip to content

Commit

Permalink
WIP: Fix issue where actors referenced within scripts were not always…
Browse files Browse the repository at this point in the history
… being linked correctly
  • Loading branch information
chrismaltby committed Jun 28, 2024
1 parent 9a9696d commit 53f08b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lib/compiler/scriptBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,9 @@ extern void __mute_mask_${symbol};
if (typeof id === "number") {
this.actorIndex = id;
this._setConst(addr, this.actorIndex);
} else if (typeof id === "string" && id.startsWith(".")) {
this.actorIndex = -1;
this._set(addr, id);
} else if (typeof id === "string") {
const newIndex = this.getActorIndex(id);
this.actorIndex = newIndex;
Expand Down Expand Up @@ -3985,7 +3988,10 @@ extern void __mute_mask_${symbol};
// --------------------------------------------------------------------------
// Call Script

callScript = (scriptId: string, input: Dictionary<string | ScriptValue>) => {
callScript = (
scriptId: string,
input: Dictionary<string | ScriptValue | ScriptBuilderFunctionArg>
) => {
const { customEvents } = this.options;
const customEvent = customEvents.find((ce) => ce.id === scriptId);

Expand Down Expand Up @@ -4016,7 +4022,8 @@ extern void __mute_mask_${symbol};
if (
typeof variableValue !== "string" &&
variableValue.type !== "variable" &&
variableValue.type !== "number"
variableValue.type !== "number" &&
variableValue.type !== "argument"
) {
const [rpnOps, fetchOps] = precompileScriptValue(
optimiseScriptValue(variableValue)
Expand Down Expand Up @@ -4057,6 +4064,8 @@ extern void __mute_mask_${symbol};
if (typeof actorValue === "string") {
const actorIndex = this.getActorIndex(actorValue);
this._stackPushConst(actorIndex, `Actor ${actorArg.id}`);
} else if (actorValue.type === "argument") {
this._stackPush(actorValue.symbol);
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/shared/lib/scripts/scriptDefHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export const isActorField = (
args: ScriptEventArgs,
scriptEventDefs: ScriptEventDefs
) => {
// Custom event calls
if (fieldName.startsWith("$actor[")) {
return true;
}
const field = getField(cmd, fieldName, scriptEventDefs);
return !!field && field.type === "actor" && isFieldVisible(field, args);
};
Expand Down

0 comments on commit 53f08b9

Please sign in to comment.