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.
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.
I obviously wasn't searching for the right thing. :-\
Cheers!
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@!"
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.
Any idea how it could be done in version 2.70?
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);
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.