Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: MyEakinBack on Tue 21/04/2015 03:20:05

Title: Walkable areas not turned off using room_FirstLoad
Post by: MyEakinBack on Tue 21/04/2015 03:20:05
Okay, it's obvious I don't know what I'm talking about when trying to help others with code. So let me try to ask a question then before I do something wrong.

I've used the following types of statements many times to remove walkable areas. They seem to work, but then one of my testers started a game and the walkable areas were not removed.

Code (ags) Select

function room_FirstLoad()
{
  RemoveWalkableArea(2);
  RemoveWalkableArea(4);
  hLever.Enabled = false;
}


I do have code in room_Load (variable and attribute setting only), room_AfterFadeIn, room_RepeadlyExecute (lots of stuff). The after-fade-in code does blocking activity (characters walking in the room).

The only explanation I have is that somehow she pushed a button and prevented the FirstLoad code from running. So I want to prevent that from ever happening. I was going to move all the RemoveWalkableArea's into room_Load and set up a room-scope boolean variable to check for first load. This is to force the areas to be removed (by having them happen before the fade in).

Does this sound like a good plan? I really don't want to see these walkable areas not getting removed.
Title: Re: Walkable areas not turned off using room_FirstLoad
Post by: Slasher on Tue 21/04/2015 03:59:56
Hi,

yes, you could place all conditions in room load using booleans etc.

You could make a boolean: loaded_first (set to false in global pane) and set to 'true' after room fade in events or at some point in that room.

Example:

if (loaded_first==false)
do this
else
do this


Title: Re: Walkable areas not turned off using room_FirstLoad
Post by: Monsieur OUXX on Tue 21/04/2015 09:07:40
RemoveWalkableArea is supposed to work in room_FirstLoad.
- Add some Breakpoint to make sure that code is called every time.
- Don't forget that Walkable Areas are reset each time the player re-entres the room. So if you put RemoveWalkableArea in room_firstLoad it will do it only the first time...
Title: Re: Walkable areas not turned off using room_FirstLoad
Post by: Khris on Tue 21/04/2015 11:33:01
There is no way she pushed a button and prevented the function from running.
If the walkable areas are active, there are only two possibilities:
a) room_FirstLoad isn't called in the first place, since you typed the function without linking it to the room event
b) it's called, but then the walkable areas are re-activated by faulty game logic elsewhere in the room script

Needless to say, this should be the case for everybody who tests the game, not just one person.
Title: Re: Walkable areas not turned off using room_FirstLoad
Post by: MyEakinBack on Tue 21/04/2015 21:56:05
I really appreciate the replies. Thank you.

This is a really tricky one because I can't reproduce the error. I test software for a living, so I know what it is like to be told "I can't reproduce your error, so it doesn't exist." by a developer. I don't want to be that sort of developer, so I think I'll put the code in room_Load anyway. I've been all over this code, and just can't figure out why it doesn't work. A set break point moves right through the function every time. Oh well...

My post reads like frustration so I apologize if I came across negatively. Thanks again.
Title: Re: Walkable areas not turned off using room_FirstLoad
Post by: Crimson Wizard on Tue 21/04/2015 23:28:42
I should point out that, as stated in the manual:
Quote
NOTE: When the player leaves the screen, all the walkable areas are reset. Therefore, if you want an area to remain off when they leave the screen, you will need to set a flag, then run the RemoveWalkableArea command in the "Player enters room" event when they return.
From the script example you posted, you remove the areas only in room_FirstLoad, i.e. only once the player visits the room for the first time.
So, the question is, is it possible, by game logic, for player to leave and return to this room, and if yes, are these areas supposed to be disabled again?
E: and Monsieur OUXX noted that too. Unfortunately, you did not specify these details, so I'll keep the question here.

Regarding player report, I am software developer myself (so we are close in our area of expertise :)) and on occasions too many to count users failed to describe erroneous situation precisely enough to reproduce it. I can't judge, because I know nothing of the person who does tests for you, but maybe she forgot some important details, or understood the situation wrong, etc.
Anyway, I've never heard of Room_FirstLoad failing to run, so I doubt its the case.
Title: Re: Walkable areas not turned off using room_FirstLoad
Post by: MyEakinBack on Wed 22/04/2015 01:18:48
Oh gosh, I think you nailed it now. My bad for not reading the other messages closely enough. Gotta slow down self.

QuoteNOTE: When the player leaves the screen, all the walkable areas are reset. Therefore, if you want an area to remain off when they leave the screen, you will need to set a flag, then run the RemoveWalkableArea command in the "Player enters room" event when they return.

I always tested that room in one shot. I never left and came back. Guess I just assumed the state of the walkable areas was saved along with the rest of the room state. That doesn't makes sense to me, but I guess it is what it is.

This room actually has 1944 lines of script. I use every available walkable area. Ladders move back and forth, lock, unlock, retract when players move. This puzzle is as she said "annoying" I think. Hope you all hate it! :wink:

I'm so appreciative of the help from all of you!

Oh, I should have mentioned that Lady_Ogress did a great job of testing this. She sent me her save game file which proved to me that the error was indeed real.

It turns out I already had the flags for other reasons. So a much easier fix than feared:

Code (ags) Select

function room_Load()
{
  // remove walkable areas if ladders not in place
  if (!Ladder1and2_connected) RemoveWalkableArea(2);
  if (!Ladder4_in_place) RemoveWalkableArea(4);
  if (!Ladder13_in_place) RemoveWalkableArea(6);
  if (!Ladder14_in_place) RemoveWalkableArea(7);
  if (!Ladder8_in_place) RemoveWalkableArea(9);
  if (!Gangway_connected) RemoveWalkableArea(10);
  if (!Ladder10_in_place) RemoveWalkableArea(11);
  if (!Ladder12_in_place) RemoveWalkableArea(13);
  if (!Ladder15_in_place) RemoveWalkableArea(15);
}
Title: Re: Walkable areas not turned off using room_FirstLoad
Post by: Monsieur OUXX on Thu 23/04/2015 13:43:54
I'm eager to see this game