Making Game, need help

Open Left Door

function OLD(){

These pieces of code are very important in my game (besides the ‘BLAH BLAH BLAH’). Basically I want the game to do something like this:

if(OLD == false){

But can you do that if not please tell me a different way to do it

To do this, you will need to return a boolean value (true or false) in your function, and your if statement should look like this:

if(OLD() == false){

I understand where you’re going with your thought process, however there are a few different ways that you could accomplish what you’re attempting. Please see below for further details.

First off, Functions and Variables are very different in terms of how they’re used in programming.

var variable1 = ///value

function Object1 (Param1, Param2, ...) { ... }

The best way to use an if function would be to use a preset variable to distinguish whether or not Object1 should be run. This can be done in a few ways:

var boolean = false; ///Initializer
function Object1() { ... } ///Initializer

if (boolean == true){ Object1(); }; ///If statement CALLS Object1


var boolean = false;

function Object1( Param1 ) { ///If statement INSIDE Object1
    if (Param1 == true) { ... }


Both of these could be used for various purposes but the easiest way would be to simply call the object IF a certain condition applies. This would best be measured with a variable for obvious reasons.

I hope this helps!


If you’re wanting to get a value that’s returned from an object that’s slightly more complicated.

function Obj(){ //Object initializaiton
    return true;

if (Obj() == true){ ... };

Obj(); //Object Call

@toplearner basically hit it on the head but I misunderstood the question. Again I hope this helps!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.