Using Print to show if a variable is defined

Monkey Forums/Monkey Programming/Using Print to show if a variable is defined

Grey Alien(Posted 2011) [#1]
Hiya, I'm using Monkey this weekend for the Ludum Dare 22 game jam. Anyway I'm still a total Monkey noob and may be posting a few queries on here (after searching).

I searched for this but couldn't find anything.

Let's say I have a class called Player and I make a variable player:Player

Then I want to test if that has been set. In BlitzMax I could just say Print player=null and it would tell me if player is defined or not.

In Monkey that fails so I started off with Print String(Int(Bool(player))) and finally reduced it to Print Int(player=Null).

Is there a better way than this? Thx!


therevills(Posted 2011) [#2]
I would just do this:

if player = null Then Print "Player is null"


What game are you doing for the jam?


Grey Alien(Posted 2011) [#3]
Oh haha, yeah could do :-)

A game called Always Alone. Not sure how good it'll be as there's a learning curve I'm going through.


Grey Alien(Posted 2011) [#4]
Btw, nice work on Diddy I've been checking it out. Some of it is familiar ;-) and wow there's tons of new stuff and platform specific stuff. It's great! Going to be a huge timesaver. Thanks.


Grey Alien(Posted 2011) [#5]
Oh is the preference to use Delta Time now instead of Fixed Rate Logic? I guess it's better on slower systems than running at 200 Logic FPS :-)


Tibit(Posted 2011) [#6]
Hi Grey, welcome to Monkey! :)