I don't need the verbcoin wheel from the template to change rooms

Started by Hayoto, Wed 29/03/2023 08:42:13

Previous topic - Next topic

Hayoto

Good morning and sorry because I'm sure it has a much simpler solution than I think.
I decided to use the Verbcoin template, the problem is that if I put it as a region, a name does not appear indicating that there would be a path to change rooms.
So I put a hotspot next to the region but clicking it opens the wheel unnecessarily and I can't keep it closed.

Thank you very much in advance

Khris

There's no simple solution I'm afraid.

You have two options:
1) keep using regions and change action_label.Text to an exit name using code
2) use hotspots instead and mark them as exits, then handle the click differently

Both methods require storing extra information. With regions you need to assign them a name manually, for instance in room_Load since they have neither descriptions nor custom properties. With hotspots you need to add a custom property like a boolean "isExit" and set that to true.

While I prefer to use regions for exits, I guess in this situation hotspots make more sense.

1. Select the hotspot in the editor. In its Properties, select Properties in the Properties section (;)) then click the ellipses button.
In the window that pops up, click the Edit Schema button and in the new window, right-click the blank table and select "Add new property...".
Name: isExit
Type: Boolean
Default value: 0
Applies To: hotspots only
Click OK, then Close.
In the current window, double-click the cell showing False to change it to True, then click Close.
(the very first and last line of step 1. need to be repeated for every exit hotspot obviously)

2. Right-click the Scripts node in the project tree and pick "New Script", enter "ExitHandler" as the name.
Double-Click "Edit Script" below its node to open the script.
Paste the following function into the script:
Code: ags
void on_mouse_click(MouseButton button) {
  int mx = mouse.x, my = mouse.y;
  Hotspot* h = Hotspot.GetAtScreenXY(mx, my);
  if (button == eMouseLeft && h != null && h.GetProperty("isExit")) {
    ClaimEvent();
    player.Walk(mx, my, eBlock);
    h.RunInteraction(eModeInteract);
  }
}

This code will make the player walk to the clicked spot blocking, then run the hotspot's interact function. Simply put your ChangeRoom line in there.

Hayoto

Great Khris, of course it worked perfectly. On another occasion a little later I will explore the option of the action_label Text, Thank you very much

SMF spam blocked by CleanTalk