activate walkable areas

Started by JpGames, Tue 15/05/2007 04:45:59

Previous topic - Next topic

JpGames

Well, I'm lost with this  ???

I want create a walkable area, but in one part of it, the player just can access after he complete a puzzle. I mind, a walkable area with a door in the middle. Until the player do not opens the door, he cant access to the other side.

I tried with regions, but the result was no good. Also using 2 diferent walbale areas, but again i cant do it.

Any suggestion? Im sure the solution is very easy, but after almost 2 days i really appreciatte a help here.

JpGames

EDIT Im sorry, i made a mistake and posted this in the wrong thread  ::)

Gilbert

Look up RemoveWalkableArea() and RestoreWalkableArea() from the manual.

Basically you can just remove an area in "first time enters room" and then re-enable when the character can walk on it again.

JpGames

#2
I did that. I used walkable area 1 for the part where the player can walk free, and walkable area 2 for the area acroos the door. When the players open the door, i activate the walkable area 2, but the player can go into that area. I verify the masks, ans both are in contact.

JpGames

Khris

Quote from: JpGames on Tue 15/05/2007 17:53:56When the players open the door, i activate the walkable area 2, but the player can go into that area.

Well, that's exactly what's supposed to happen, isn't it? ;)
Did you mean that the player can step on area No. 2 before he opened the door?
Or did you mean he can't step on it after the door is open?

Ashen

Since it's not the obvious solution it seemed to be, topics merged and unlocked.

JpGames, in future PM a moderator to unlock a thread for you, don't just start a new one.
I know what you're thinking ... Don't think that.

JpGames

Ashen, thanks for your tip.

ok, i have this in the player enters room before fade in:

if (puertaabierta == 0) {
removewalkablearea(2);
}

when the players opens the door, i change the variable (puertaabierta = 1), but the player cant enter in the walkablearea 2  ???

Im sure the variable is good declared and i also imported it. I put a little command to see the value (the player say the value)

if (puertaabierta == 0) {
ccapitan.say ("Its close");
}
if (puertaabierta == 1) {
ccapitan.say ("Its open");
}

And the players says "its open". I cheked, and there are not unfilled spaces between both areas (1 & 2).

I miss something??? Im feeling frustrate with this  :'(

JpGames

Gilbert

That's because you probably didn't actually reactivate the area after opening the door. :P

Aside from setting the variable to 1, you need to use RestoreWalkableArea() to reactivate the area.

Andail

Yeah, just changing the variable will not change anything in the room until you call the function again.

JpGames

Thanks, that was my mistake to forgot that. Now i working great :)

JpGames

WolfBlacker

I don't want to make a new topic because my problem is similar. So:

I've tried with "First time player enters the room" to remove walkable area. To that point evrything is ok, character can't walk on it. But when I want to restore that area, it doesn't work. This is the script for removing:
// script for Room: First time player enters room
{
RemoveWalkableArea (2);
}
}
And this for restoring:
if (player.ActiveInventory == inventory[3]){
  RestoreWalkableArea (2);

  }

Ashen

Where have you put the RestoreWalkableArea bit?
I know what you're thinking ... Don't think that.

WolfBlacker

Whole part of the script:

#sectionstart object1_a  // DO NOT EDIT OR REMOVE THIS LINE
function object1_a() {
  // script for Object 1: Use inventory on object
  if (player.ActiveInventory == inventory[3]){
  RestoreWalkableArea (2);

  }

Ashen

Are you definitely using the right Item on the right object? Try using the Item's script-o-name (e.g. iKey) instead of inventory[3]. Also, add a couple of Display commands, to check if it's running at all. (Oh, and double check that it's actually Walkable Area 2 you want to be removing/restoring, of course.)
I know what you're thinking ... Don't think that.

WolfBlacker

Well, I think id doesn't work at all, DisplayMessage doesn't work too (and it is just after the RestoreWalkableArea). How to make it working?

Ashen

Again, is it definitely the right Item and Object you're using? Try:

Code: ags

  // script for Object 1: Use inventory on object
  Display ("Item %d used on object 1.", player.ActiveInventory.ID);
  if (player.ActiveInventory == inventory[3]){
  RestoreWalkableArea (2);
  }


That should at least tell you what item you're using. If it doesn't display anything, you're either not in the right cursor mode, or clicking the wrong object.
I know what you're thinking ... Don't think that.

WolfBlacker

#15
Well, it shows me an error -.- (I know, I suck at script) I was copying-pasting the code, and it shows me an error about null pointer referenced (I should modify it? Write chracter[EGO] instead of player, and something else?)

Ashen

What was the exact error message, and when does it show (when you try to test the game, when you interact with the object ...)?

player is automatically generated so that can't be null, if this is in the 'Use inventory on object' interaction player.ActiveInventory can't be null either ... By elimination it looks like inventory[3] isn't a valid item - again, what if you use the script-o-name instead?
I know what you're thinking ... Don't think that.

WolfBlacker

Exact message:
Error: run_text_script1: error -6 running function 'object1_a':
Error: Null pointer referenced
in Room 1 script (line 6)

Line 6 is the "Display ("Item %d used on object 1.", player.ActiveInventory.ID);". When I'm using the script-o-name, nothing changes.

Gilbert

I didn't read all the stuff yet, but when no item is currently selected for a character ActiveInventory will be null.
Try changing the line to:
if (play.ActiveIntory!=null) Display ("Item %d used on object 1.", player.ActiveInventory.ID);

Khris

The .ID bit throwing the error was my initial guess, too, and it seems to indeed be the cause, but how come "use inv on object" is called when ActiveInventory==null?

WolfBlacker: Are you using some kind of template? Or the default game?

SMF spam blocked by CleanTalk