Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - dayowlron

#1
I will have several doors in my game so I created a function that I will call that will open and close my doors. Later when I get to adding sound I will put that in the one spot and will work for all my doors. All of my doors have a 5 image(frames numbered 0-4) animation for opening and closing. When a room loads I set the view for the door and then when the player wants to open or close the door I just call the function. When the door is open there is another walkable area that is enabled that allows them to go through the door. It is disabled when the player closes the door. This is where the problem occurs.
Code: ags


static function OpenDoor(Object*obj, int WalkableAreaToEnable) {
  if (obj.Frame==0) {
    obj.Animate(obj.Loop, 5, eOnce, eNoBlock, eForwards);
    if (WalkableAreaToEnable!=0) RestoreWalkableArea(WalkableAreaToEnable);
  }
}

static function CloseDoor(Object*obj, int WalkableAreaToDisable) {
  if (obj.Frame==4) {
    obj.Animate(obj.Loop, 5, eOnce, eNoBlock, eBackwards);
    if (WalkableAreaToDisable!=0) RemoveWalkableArea(WalkableAreaToDisable);
    player.PlaceOnWalkableArea();
  }
}


My problem is when the walkable area is removed and then i call player.PlaceOnWalkableArea sometimes it works sometimes it doesn't.
I have walkable area #1 always available so its not like it can't find a walkable area.

EDIT: I have even tried putting the player.PlaceOnWalkableArea() call in the repeatedly_execute function and verified that it is being called.
#2
I am having trouble with something. I need to get the object name but it is returning an empty string.
Just including code related to the problem.
Code: ags

  LocationType l;
  Object *o;
  o=Object.GetAtScreenXY(mouse.x, mouse.y);
  l=GetLocationType(mouse.x, mouse.y);
  if (l==eLocationObject) {
    return String.Format("%d %s",o.ID, o.Name);
  }

The object name field is filled in. It is called "oDoor". However my function is returning "1 ".
SMF spam blocked by CleanTalk