var name = candle_flame;var tile;var tw = GetTileWidth();var th = GetTileHeight();var tn = GetTileName(tile);var px = GetPersonX(name);var py = GetPersonY(name);var pl = GetPersonLayer(name);var dir = GetPersonDirection(MainChar);var x;var y;var l;switch (dir) {case "north": x = px; y = py - 2; l = pl; tile = GetTile(x, y, l); if (tn = "burnable_bush") //tile name to be changed later { if (py == y) { } } break;
var tn = GetTileName(undefined);
Yes, that will produce an error. You are effectively doing:Code: (javascript) [Select]var tn = GetTileName(undefined);
Code: [Select]var name = candle_flame;var tile;var tw = GetTileWidth();var th = GetTileHeight();var tn = GetTileName(tile);var px = GetPersonX(name);var py = GetPersonY(name);var pl = GetPersonLayer(name);var dir = GetPersonDirection(MainChar);var x;var y;var l;switch (dir) {case "north": x = px; y = py - 2; l = pl; tile = GetTile(x, y, l); if (tn = "burnable_bush") //tile name to be changed later { if (py == y) { } } break;I am not currently in front of a computer to test this on... Writing the code on my mobile phone. Looking at how this code is written so far, I'm wondering if it will produce an error on var tn due to the fact that var tile technically isn't being define until the switch (dir)?
I'm not even sure what you're trying to do in this example, I'm sure there's a way to do it that's more concise and won't make an error though.