Simple question: Can't get room to recognize tile names

I need to check to see if a series of specific tiles are a certain type and it's not registering. Here's my process:

name1 = name 12,12
name2 = name 13,13
...
if name1 == "theCorrectTile" then
   if name2 == "theCorrectTile" then
      do the thing
   end
end

This is all in the room script by the way.

When all of the tiles are set to the "correct" tile, nothing happens. Any ideas?

Nvm. I figured it out. I needed to emit to a function in the player script like so:

Incorrect Tile:

on interact do
   swap "CorrectTile"
   emit checktile
end

Player:

on checktile do
   name1 = name 12,12
   name2 = name 13,13
  
   if name1 == "CorrectTile" then
      if name2 == "CorrectTile" then
         do the thing
      end
   end 
end

Two things:

  1. You can use "call" instead of "emit" to save ressources, as you already know what entity you're calling.
  2. since you are hard coding the tile positions, maybe move "checktile" to the room, so you won't run into issues with multiple rooms.

If what you are trying to do, is check if all "IncorrectTile"s are converted to "CorrectTile"s, you could probably also make it more flexible, by just counting all "IncorrectTile"s and do the thing, when there are zero left.

@gummipferd Thank you for the suggestion. I moved the player script to the room. Much neater.

The script failed when I changed "emit" to "call" though.

Your last suggestion is also great, but it don't think it applies to what I'm trying to accomplish since my game has multiple "IncorrectTiles" and "CorrectTiles." Thanks again!

Did you replace:

emit "eventName"

with:

tell event.player to
    call "eventName"
end

?