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:
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?
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.
Checked case settings. Thanks (laugh)
Also note that this code will break as soon as you add a scrolling room.
Use this:
if (Region.GetAtRoomXY(mouse.x + GetViewportX(), mouse.y + GetViewportY()) == Region[1])
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.
I might want to use animated cursors, that is why I check mouse.Mode
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:
if (Region.GetAtRoomXY(mouse.x + GetViewportX(), mouse.y + GetViewportY()) == Region[1])
That was exactly the issue in this thread (http://www.adventuregamestudio.co.uk/forums/index.php?topic=53947.0).