@@ -96,9 +96,10 @@ export class FieldTileset extends FieldImages implements FieldCustom {
9696 }
9797
9898 getValue ( ) {
99+ const project = pxt . react . getTilemapProject ( ) ;
99100 if ( this . selectedOption_ ) {
100101 let tile = this . selectedOption_ [ 2 ] ;
101- tile = pxt . react . getTilemapProject ( ) . lookupAsset ( tile . type , tile . id ) ;
102+ tile = project . lookupAsset ( tile . type , tile . id ) ;
102103
103104 if ( ! tile ) {
104105 // This shouldn't happen
@@ -109,12 +110,23 @@ export class FieldTileset extends FieldImages implements FieldCustom {
109110 }
110111 const v = super . getValue ( ) ;
111112
112- // If the user decompiled from JavaScript, then they might have passed an image literal
113- // instead of the qualified name of a tile. The decompiler strips out the "img" part
114- // so we need to add it back
115- if ( typeof v === "string" && v . indexOf ( "." ) === - 1 && v . indexOf ( `\`` ) === - 1 ) {
116- return `img\`${ v } \``
113+ if ( typeof v === "string" ) {
114+ if ( v . indexOf ( "." ) !== - 1 ) {
115+ // Possibly a qualified name like myTiles.tile1
116+ const tile = project . lookupAsset ( pxt . AssetType . Tile , v ) ;
117+ if ( tile ) {
118+ return pxt . getTSReferenceForAsset ( tile ) ;
119+ }
120+ }
121+
122+ // If not a qualified name, it's either an image literal or an asset reference like assets.tile`name`
123+ if ( v . indexOf ( `\`` ) === - 1 ) {
124+ // If the user decompiled from JavaScript, the decompiler strips out the "img" part
125+ // so we need to add it back
126+ return `img\`${ v } \``
127+ }
117128 }
129+
118130 return v ;
119131 }
120132
0 commit comments