Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: AdamM on Sun 12/02/2006 19:26:21

Title: Default message for actions
Post by: AdamM on Sun 12/02/2006 19:26:21
Hi guys. Here's an easy one. How do you set hotspots etc. to display a default message when the player clicks on them (e.g. if the player has their cursor set to Talk To, and clicks on an inanimate object, the game displays 'You can't talk to that' or similar)? I can't seem to find an contextual answer in the manual or by searching. Thanks in advance.
Title: Re: Default message for actions
Post by: Ashen on Sun 12/02/2006 19:50:12
You'll be wanting the unhandled_event function (near the bottom of this bit of the manual (http://www.adventuregamestudio.co.uk/manual/TextScriptEvents.htm)).

It IS a little obscure in the manual, but I'm surprised searching the forums didn't turn up anything usefull.
Title: Re: Default message for actions
Post by: AdamM on Sun 12/02/2006 19:55:48
I obviously wasn't searching for the right thing.  :-\

Cheers!
Title: Re: Default message for actions
Post by: Zoolander on Wed 15/02/2006 17:46:15
Is it possible in the unhandled_event function to script it so that the hotspots or objects are named in the default message?
For example: "I can't pick up that @OVERHOTSPOT@!"
Title: Re: Default message for actions
Post by: strazer on Wed 15/02/2006 18:37:40
You could do, for example (AGS v2.71 code):


  String thetext = String.Format("I can't pick up that %s!", Game.GetLocationName(mouse.x, mouse.y);
  player.Say(thetext);


Edit:

I think putting everything in one line would work as well:


  player.Say(String.Format("I can't pick up that %s!", Game.GetLocationName(mouse.x, mouse.y));


And thanks for the v2.70 code, Ashen.
Title: Re: Default message for actions
Post by: Zoolander on Wed 15/02/2006 19:10:27
Any idea how it could be done in version 2.70?
Title: Re: Default message for actions
Post by: Ashen on Wed 15/02/2006 19:45:34
More or less the same way (at least, GetLocationName(..) is still in there). You'll need to use the 2.7 string commands (obviously), and I think you'll need two of them:

string thetext;
string temp;
GetLocationName(mouse.x, mouse.y, temp);
StrFormat (thetext, "I can't pick up that %s!", temp);
player.Say(thetext);
Title: Re: Default message for actions
Post by: Scummbuddy on Wed 15/02/2006 20:16:03
I strongly suggest that you do not use default messages. The game will be much more well received if you take the time to explain why for each object in a room, as to why the character can not pick up such item; why they can not combine one item with another; why they can not put their lips on that; and so on.