Region is not an array?? Question about GetRoomAtXY - SOLVED

Started by johanvepa, Wed 21/09/2016 22:44:24

Previous topic - Next topic

johanvepa


I am doing a function that checks if the mouse hovers over a region. If it does, and the cursor is not PickUp, then it should change to PickUp.

I am doing this:
Code: ags




function room_RepExec()
{
  if (Region.GetAtRoomXY(mouse.x, mouse.y) == Region[1])
  {
    if (mouse.Mode != eModePickup)
    {
      mouse.Mode = eModePickup;
    }
  }


since the manual told me this is a correct example:
if (Region.GetAtRoomXY(player.x, player.y) == region[0])
  Display("The player is not currently standing on a region.");

But AGS tells me that Region is not an array. What is wrong here?

Crimson Wizard

#1
Small-case region is an array. Capital-case Region is a type.

AGS script is case sensitive. You need to make sure you are using correct letter case in your script.


Khris

Also note that this code will break as soon as you add a scrolling room.

Use this:
Code: ags
  if (Region.GetAtRoomXY(mouse.x + GetViewportX(), mouse.y + GetViewportY()) == Region[1])

dayowlron

It is not a big deal either but it is not necessary to check to see if mouse mode is not eModePickUp before setting it to be that.

What I mean is:
    if (mouse.Mode != eModePickup)
    {
      mouse.Mode = eModePickup;
    }

could have been just written as:
    mouse.Mode = eModePickup;

since if it is already set then setting it again is not going to change things.

If you have animated cursor that would be the only reason to check first.
Pro is the opposite of Con                       Kids of today are so much different
This fact can clearly be seen,                  Don't you know?
If progress means to move forward         Just ask them where they are from
Then what does congress mean?             And they tell you where you can go.  --Nipsey Russell

johanvepa

I might want to use animated cursors, that is why I check mouse.Mode

johanvepa

Quote from: Khris on Thu 22/09/2016 12:04:39
Also note that this code will break as soon as you add a scrolling room.

Use this:
Code: ags
  if (Region.GetAtRoomXY(mouse.x + GetViewportX(), mouse.y + GetViewportY()) == Region[1])


That was exactly the issue in this thread.

SMF spam blocked by CleanTalk