Walkable area on/off by object properties

Started by Zparrish, Sun 12/04/2009 19:55:49

Previous topic - Next topic

Zparrish

This is my problem

I have a front view / a door that is facing me, and it is an object. I have an opened door behind the closed door, which opens when i use a key on it. The problem is that I have a walkable area (2) on it that goes back in space to make it look like he walks back, and even when the door is closed, before I use the key, my guy walks through the door. How do I make it to when the door is closed, the walkable are is off, but when opened by the key, the walkable area is on??


For some stupid reason, it wont load it!! I am trying to make a walk able area removed when a certain object IS visible, and then restore it when the object is NOT visible. I need help with the removing part. Please!! Can anyone help?? The script says its a problem with the line below.....look.

  if (oopendoor.Visible = true;) }

What is wrong?? I really dont know and I'm pissed. Plz help. >:( >:( >:( ??? >:( >:( >:(

Ghost

You write "= " which means "assign a value to something" (as in x = 12).
To test if the value IS something, use "==".

You don't get a warning because the code actually is VALID, but keep in mind:
= equals assign
== equals test
;)

So:
Code: ags

function room_Load() {
  if (oopendoor.Visible == true) {
    RemoveWalkableArea(2);
  }
}


monkey0506

#2
The = operator is the assignment operator. You want the == boolean operator. Also you might consider checking your braces:
function room_Load()
{
  if (oopendoor.Visible == true) {
    RemoveWalkableArea(2);
  }
}
Yes. Like Ghost said. Also, what on earth was that semi-colon doing in your if statement?

By the way, you keep posting like this and you'll find you fit in just fine. Nothing rude or against the rules about posting in all caps with a non-descriptive title and pointless excessive punctuation. Welcome to the forums.

IndieBoy

Quote from: Calin Elephantsittingonface on Tue 08/02/2011 09:00:55
The only person in favour of the mobs seems to be IndieBoy.. but he's scottish so we dont listen to him anyway.

Zparrish

 ??? ??? ???

Thanks Ghost, but I'm still having trouble. Could you just igve me the whole code Plz? Here what I have...and it wont work.

function room_Load() {
  if (oopendoor.Visible == false) {
      (ocloseddoor.Visible == true) 
    RemoveWalkableArea(2);
  }

}

They are two diiferent objects that lay on top of each other, and when i use the key on the closed door, the open door appears. The problem is, I can walk through the closed one like its open....I'm so confused and need help. Thanks Ghost... for the help before.

Zparrish

Hey, could you give me the whole code plz. my guy walks through the closed door, and its being stuuupid. Thanks. and what do you mean Ill fit right in?

IndieBoy

Sounds like you are having a walkbehind problem. Watch this, it explains about object walkbehinds. And watch the rest of the videos they are very useful.
Quote from: Calin Elephantsittingonface on Tue 08/02/2011 09:00:55
The only person in favour of the mobs seems to be IndieBoy.. but he's scottish so we dont listen to him anyway.

Vince Twelve

Let's walk through your code.

Code: ags

function room_Load() {
  if (oopendoor.Visible == false) {

Here we use two equals signs because you're checking if one equals the other.  You can read it like "Is the 'Visible' property of the object 'oopendoor' equal to false? If so then:"
Code: ags

      (ocloseddoor.Visible == true)  

This is wrong.  You're using two equals signs.  This would mean. "Is the 'Visible' property of the object 'ocloseddoor' equal to false?"  But that's not what you want to say.  You want to say "Set the 'Visible' property of the object 'oclosedoor' to false."  To say that, we just use one equal sign.  And we don't need the parentheses around it.  Here's the correct code:

Code: ags


function room_Load(){
  if(oopendoor.Visible == false){ //Is opendoor visible?  If so, then:
    ocloseddoor.Visible = true; //set closeddoor to be visible and
    RemoveWalkableArea(2); //remove the walkable area.
  }
}


Read the comic, it speaks the truth.  And here's a handy little way to help you remember:  If you're using two equals signs, then you can flip the left and the right side and it still has the right meaning.

For example
     x == 6
has the same meaning as
     6 == x

They both check to see if the variable 'x' is equal to 6.  If so, they both return 'true' and if not, they both return false;

But you can't flip the sides when you're using one equal sign.

     x = 6
would set the variable x equal to 6, but
     6 = x
would try to set 6 equal to the value of x, but since you can't change what 6 equals (it's not a variable), this would produce an error.


SMF spam blocked by CleanTalk