Remote tile swap - crashing the game

If you want to tell a specific tile in the room to swap you need to target it using coordinates like this:

tell x,y to
  swap "lock"
end

If you want every matching tile in the room to be told to swap, an easy way is using emit. On the tile add an event like this:

on removeVines do
  swap "lock"
end

Then in your lockspecial tile script:

on collect do
  emit "removeVines"
end

Beware that multiple emits in the same frame can have a performance impact, but just one like this on collect should be fine.

As for why your approach isn't working it's because tell tileName to targets the tile prototype instead of any specific tile instance. That might sound a bit confusing if you're not a programmer but think of the tiles in the editor as "prototypes" that get instantiated in the room when you place them. You can have many instances of a tile in a room (a lock at 12,7 is a different tile to a lock at 18,4 but they are both the same type of tile).

Certain functions, like swap, only work on instances of tiles and not the prototype. Basically anything that only makes sense to happen to a tile that is in a room!

As a rule of thumb most of the time you'll probably want to use tell with coordinates, not a tile name.

1 Like