Room look in BASS

Started by FauxSang, Thu 18/07/2024 17:38:17

Previous topic - Next topic

FauxSang

Just looking for a sanity check here.  I want to have a generic "look" interaction in each room, like how you'd get a general room description if you just typed "look" in an old sierra game.  I'm using the BASS template with the twoclick handler.  I think I have it working but it feels a little janky; just wondering if there's a better way.  This code goes into every room's script.  In my case, I'm letting the character Say() the description so it's handy to just use a dialog for each room.

Code: ags
function on_mouse_click(MouseButton which)
{
  if (GetLocationType(mouse.x,mouse.y) == eLocationNothing && which == eMouseRight) {
    ClaimEvent();
    dRoom2Look.Start();
  }
}

Any thoughts or tips?

eri0o

The scripts things that use global handlers like this one are executed from top to bottom, the room script being the last one, so there's no need to call ClaimEvent on a Room Script. That's the use of script ordering in general - besides dependency between scripts in ags3.

FauxSang

Thank you for your response! 

Documentation indicates the opposite - methods in room scripts execute first, then modules, then global; the purpose of the ClaimEvent global method is to stop the handlers from propagating upwards.

https://adventuregamestudio.github.io/ags-manual/Globalfunctions_General.html?highlight=claimevent&case_sensitive=0

eri0o

In that case documentation is correct and I am wrong.

Khris

You can simply put a bunch of player.Say("..."); commands in your script instead of using a dialog.

You can also use a custom property; add one for rooms to the schema (type: String, name: description).
Then add a new script above the two-click handler one:
Code: ags
function on_mouse_click(MouseButton which)
{
  if (GetLocationType(mouse.x,mouse.y) == eLocationNothing && which == eMouseRight) {
    ClaimEvent();
    player.Say(Room.GetTextProperty("description"));
  }
}

This way you won't have to paste this function into each new room.

SMF spam blocked by CleanTalk