Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | mattkw80 |
I’ve come across this multiple times, for various objects.
Sometimes I ask for an object, that’s just not going to be there, at that time.
So, my next statement is an IF… as in IF the thing is not there, don’t do anything.
In this example… I am setting a var called mytileint. This works normally… what it does it wherver my player is, it returns the ID of the tile. But, if my player wanders off the grid, there will be no tile there.
var mytileint = mytilemap.get_cellv(mytilemap.world_to_map($Player.position))
if mytileint and mytileint != null :
return
^ you can see what I am trying to do with the second line… I’m trying to say… if you didn’t get a tile… don’t do anything.
Can anyone take a peek at this for me?
(I’ve been in other positons like this… such as trying to return an inventory item of the players… same scenario… if the player doesn’t have the thing at the time, I get a null, and then the program crashes).