diff --git a/CHANGELOG.md b/CHANGELOG.md index 513a617a7..fd80dee1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix UI palette text control code. Palette indices now go from 1 to 8, because zero byte is a string terminator [@untoxa](https://github.com/untoxa) - Fix issue where migrating old projects could cause gbvm symbols to become empty, preventing build from completing (opening a broken project will now automatically fix this issue) - Fix issue where sprites could end up with empty state id values +- Fix issue where script labels could may not match script behaviour when referring to deleted actors (dropdown would say Self, label would say Player, game would use Self) ## [4.1.3] - 2024-09-16 diff --git a/src/components/script/hooks/useScriptEventTitle.tsx b/src/components/script/hooks/useScriptEventTitle.tsx index 2d46eac6a..807968185 100644 --- a/src/components/script/hooks/useScriptEventTitle.tsx +++ b/src/components/script/hooks/useScriptEventTitle.tsx @@ -128,6 +128,12 @@ export const useScriptEventTitle = ( / /g, "" ); + } else if ( + actorsLookup[entityId] && + sceneActorIds && + sceneActorIds.indexOf(entityId) > -1 + ) { + return l10n("FIELD_SELF"); } else if (entityType === "actorPrefab") { return l10n("FIELD_SELF"); } else { diff --git a/src/lib/compiler/scriptBuilder.ts b/src/lib/compiler/scriptBuilder.ts index a414ff02e..13c6432e8 100644 --- a/src/lib/compiler/scriptBuilder.ts +++ b/src/lib/compiler/scriptBuilder.ts @@ -5553,16 +5553,20 @@ extern void __mute_mask_${symbol}; getActorIndex = (id: string): number => { const { entity, entityType, scene } = this.options; + // Actor == player if (id === "player" || (id === "$self$" && entityType !== "actor")) { return 0; } + // Actor == Self if (id === "$self$" && entity) { return getActorIndex(entity.id, scene); } + // Find actor in current scene const index = getActorIndex(id, scene); + // Actor id not found but entity was set, fall back to Self if (entity && index === 0) { return getActorIndex(entity.id, scene); }