Action on an inaccessible area

Started by Peegee, Sat 20/11/2021 08:31:26

Previous topic - Next topic

Peegee

Hello, a general question:

I have a character or an area where the player cannot yet access. If I click on it, the player cannot move to the area, but he still does his action, from where he is. How to avoid this?

Creamy

#1
You can draw a region in the area where the player character should be to trigger the event.

Then you add a condition when the player click on the hotspot/object/character:

Code: ags
if (Region.GetAtRoomXY(player.x, player.y) == region[1]) {
//perform the action
}

else {
//do something else
}


Or you can simply make the hotspot/object/character non clickable at first and activate it when the new area is accessible.
 

Peegee

Thank you for the answer. I try the first solution (you must not put "player.", Only the positions) but it does not work.

arj0n

Quote from: Peegee on Sat 20/11/2021 11:09:20
(you must not put "player.", Only the positions) but it does not work.
You should put 'player.x' & 'player.y', as these two are the player character's positions.

Peegee

Yes I put this:    if (Region.GetAtRoomXY(player.228, player.173) == region[7])
But the program doesn't take it.

He takes that well:     if (Region.GetAtRoomXY(228, 173) == region[7])
But that doesn't change my problem.

Crimson Wizard

Quote from: Peegee on Sat 20/11/2021 15:56:38
Yes I put this:    if (Region.GetAtRoomXY(player.228, player.173) == region[7])
But the program doesn't take it.

You seem to misunderstand, the proper way was to do literally
Code: ags
if (Region.GetAtRoomXY(player.x, player.y) == region[7])


The point is that you ask engine to check which coordinates player character is at. You don't have to know these coordinates yourself.

Peegee


SMF spam blocked by CleanTalk