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 - js

#1
Hello,

In the callback  on_mouse_click(MouseButton button)

I try to detect which button has been pressed:

Code: ags
switch(button) {
  case eMouseLeft:
    Display("left button");
    break;
  default:
    Display("unknown button: %d", button);
    break;

The problem is when i press left button, it's not seen as a eMouseLeft code.

The enum is described like this in the documentation:

Code: ags
enum MouseButton {
  eMouseLeft,
  eMouseRight,
  eMouseMiddle,
  eMouseLeftInv,
  eMouseMiddleInv,
  eMouseRightInv,
  eMouseWheelNorth,
  eMouseWheelSouth
};

So eMouseLeft must be 0 or 1 i think (depending the start index).

When i press the buttons of my mouse, it triggers the default branch in my switch/case.

I get those values from my display box:
left : 5
right : 6
middle : 7
wheel up : 8
wheel down : 9 (note the value greater than the number of values in the enum)

Well... i don't understand what happens.

Thank you.
#2
Hello,

In debug build, i'd like to gather objects in all the room to check some relations between them, in their custom properties.

As objects are linked to rooms, i have made a shortcut key which start the check in the AGS game loop. The check changes room, gather objects and repeat until last room is reached.

At game startup, i fill the array (liste_room[]) with all the rooms index (when there are no more rooms, i put -1 as a value to indicate it's over).

Then, the keyboard shortcut initializes ask_for_objects_testing boolean to true.

And in the function repeatedly_execute() , i've put

Code: ags
  if (ask_for_objects_testing == true) {
    int initial_room = player.Room;
    for (int i=0; liste_room[i]>=0; i++) {
      log(String.Format("parsing room: %d", liste_room[i]));
      player.ChangeRoom(liste_room[i]);
    }
    // go back to initial room
    player.ChangeRoom(initial_room);
  }

But it hangs at the second call of player.ChangeRoom

I get this error:

NewRoom : Cannot run this command since there was a NewRoom command already queued to run in "GlobalScript.asc

So i think it's related a re-entrance issue in the internal loop of AGS, but i don't know how to handle this.

Thank you.
SMF spam blocked by CleanTalk