difficulties disabling walkabke areas and object solidity SOLVED thanks

Started by TonyJ, Thu 24/02/2011 15:18:32

Previous topic - Next topic

TonyJ

I have recently started using the ags after using another engine for some time and although I'm getting used to it I'm having problems as stated in the title.
What I have is a door that is an object, this leads to another area, the door is initially visible and it stands at the leading edge of a walkable area, when the game runs the player can interact with the door correctly, in the method required to open it, for ease of creation it just disappears to reveal an open doorway, the problem is that  the player can walk through the door and because the walkable area is active, can proceed to the next room, the player is set to solid, however when i try to disable walkable area i get an error which states ' Error (line 2): Variable 'RemoveWalkableArea' is already imported, and also I get the same when I try to enable walkable area and even though I have door as solid (I think) its not.
Forgive me if I've not been able to find the answer elsewhere I've been crawling these pages and the manual for days before signing up and couldn't find a solution that works.

Cheers

Matti

Quote from: TonyJ on Thu 24/02/2011 15:18:32
when i try to disable walkable area i get an error which states ' Error (line 2): Variable 'RemoveWalkableArea' is already imported, and also I get the same when I try to enable walkable area

It looks like you didn't place the command inside any function (room load, rep-exe..), but instead at the top of the room script. That's why AGS probably thinks you're trying to import a variable.

Regarding the door: You can manually set object.BlockingHeight and object.BlockingWidth which should solve the problem.

Khris

Yes, if you put commands directly into the script, AGS wouldn't know when to execute them.

What AGS does is call various functions at various points in time.
E.g. when a room is loaded, before it is faded in, i.e. at the point in time where the room should be set up, AGS looks at the "Enters room before fadein" row in the room's events table. If a function name was entered into the field, AGS calls that function in the room's script.

So what you do is open the room, click the lightning bolt icon, then on "Enters room before fadein", then the little ellipses button. This adds the function (room_Load) to the room script. You can now put stuff in between { and }.

In your case you'd put
Code: ags
  if (oDoor.Visible) RemoveWalkableArea(2);
  else RestoreWalkableArea(2);


oDoor is the door object's script name; replace it with whatever you put in the door object's Name field.

This mechanism of linking events to functions is explained in the manual: Tutorial -> Starting off -> Tutorial part 3.

SMF spam blocked by CleanTalk