Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Ricardo on Sun 13/11/2005 17:04:10

Title: Scripting help - Hotspot interaction (SOLVED)
Post by: Ricardo on Sun 13/11/2005 17:04:10
I want my character to say something whe I tell him to look at a hotspot but I can't seem to find the proper script command. Any help would be welcomed.
Title: Re: Scripting help - Hotspot interaction
Post by: Pumaman on Sun 13/11/2005 17:05:47
Try this:

player.Say("It's a hotspot.");

also, this really belongs in the Beginners Tech Forum.
Title: Re: Scripting help - Hotspot interaction
Post by: Ricardo on Sun 13/11/2005 17:16:49
I didn't mean the actual saying but how to activate it when he looks at the hotspot.
Title: Re: Scripting help - Hotspot interaction
Post by: Pumaman on Sun 13/11/2005 17:21:24
Have you worked through the beginner's tutorial (http://www.adventuregamestudio.co.uk/acintro3.htm)?
Title: Re: Scripting help - Hotspot interaction
Post by: Ricardo on Sun 13/11/2005 17:53:49
Yes, but the tutorial only teaches how to do it with the wizard. I'm trying to learn how to do it via scripting only.
Title: Re: Scripting help - Hotspot interaction
Post by: Pumaman on Sun 13/11/2005 17:58:31
It's the same process, but instead of choosing "Display a message" or whatever in the interaction editor, choose "Run script" and then press the "Edit script" button.
Title: Re: Scripting help - Hotspot interaction
Post by: Ricardo on Sun 13/11/2005 18:08:06
I know that. I don't think you understand me correctly. My problam is not making the chracter talk via scipt but to check if and when he looks/uses a hotspot (via script).
Title: Re: Scripting help - Hotspot interaction
Post by: Bernie on Sun 13/11/2005 18:35:07
You mean you don't want to use the hotspot/object interaction editor?
Title: Re: Scripting help - Hotspot interaction
Post by: Ricardo on Sun 13/11/2005 18:38:34
Exactly! It's not that I have anything against it, I'm just looking for ways to improve my scripting capabilities.
Title: Re: Scripting help - Hotspot interaction
Post by: Ashen on Sun 13/11/2005 18:43:52
To clarify (I hope):
The first part of the Interaction Editor - the part with Look at hotspot, Interact hotspot, Use inventory on hotspot, etc:
(http://www.adventuregamestudio.co.uk/images/intro3_2.jpg)
This bit, is how you set what happens when the player clicks on a hotspot, depending what mode they're using, and is used however you're setting the commands (scripting or the interaction editor commands).

I suppose you could script all that for yourself (with checks in on_mouse_click, and a whole host of custom functions, for example) but it's really not worth it.

The second part:
(http://www.adventuregamestudio.co.uk/images/intro3_3.jpg)
All you need from the drop-down menu is Run Script.
Title: Re: Scripting help - Hotspot interaction
Post by: Ricardo on Sun 13/11/2005 18:48:08
So basiclly you just saying that there isn't a specific script function for checking hotspot interaction (correct me if I'm wrong). Oh well... I guess I'll just have to give up on that one. TNX anyway
Title: Re: Scripting help - Hotspot interaction
Post by: Ashen on Sun 13/11/2005 18:57:52
There's no IsPlayerLookingAtHotspot() command, if that's what you mean.

When you click on the interaction type (e.g. Look at hotspot, in the first image) a function is created in the room script (accessable by Ctrl-E, or the '{}' button), which you can edit. The name of the function isn't constant though, so it's best not to try creating them yourself (More Detail (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=5376.0) - about room edge functions, but the same applies to hotspots, objects, etc.). If you want to call the interaction from somewhere else, you'd use the Hotspot.RunInteraction() command (e.g. hPicture.RunInteraction (eModeLookat);) - check the manual (http://www.adventuregamestudio.co.uk/manual/Hotspot.RunInteraction.htm) for more information.

And yes, this probably does belong in Beginner's Tech.
Title: Re: Scripting help - Hotspot interaction
Post by: Ricardo on Sun 13/11/2005 19:07:16
Quote from: Ashen on Sun 13/11/2005 18:57:52

There's no IsPlayerLookingAtHotspot() command, if that's what you mean.


That's exactly what i meant. Thanks again fot your help.
Title: Re: Scripting help - Hotspot interaction
Post by: SSH on Sun 13/11/2005 19:16:20
Actually, Ashen is wrong. You can do Hotspot.GetAtScreenXY(mouse.x, mouse.y) and if it is null, you are not looking at a hotspot, otherwise you are (and the function returns the pointer to that hotspot). You can also use IsIneractionAvailable to tell if a hotspot has an interaction, and you can use CallRoomScript with a aparameter to call a room-based funatiojn which can be codede to be hotspot specific. So you can entirely bypass the ineraction editor if you want, but it takes quite a lot of programming.
Title: Re: Scripting help - Hotspot interaction
Post by: Ashen on Sun 13/11/2005 20:52:02
QuoteThere's no IsPlayerLookingAtHotspot() command, if that's what you mean.

QuoteActually, Ashen is wrong. You can do Hotspot.GetAtScreenXY(mouse.x, mouse.y)

Yes, sorry - bad example. I meant, there're no in-built functions that return whether an interaction is being run - I used 'Looking' as that's what Ricardo originally mentioned, but IsPlayerUsing/TalkingTo/UsingInventoryOn/PickingUpHotspot() would all be the same.

EDIT: (As I was a bit confused by that, and I know what I meant to say)
As, in, you can't do:

if (IsPlayerLookingAtHotspot(hBigDoor) == 1) Display("That's a big door!"); // i.e 'Look at hotspot "BigDoor"'
if (IsPlayerUsingHotspot(hBigDoor) == 1) Display("The big door is locked."); // i.e. 'Use hotspot "BigDoor"'
//etc

Although you could probably create these functions, or similar, if you really wanted to.

The rest of what SSH said is what I meant by "checks in on_mouse_click and a whole host of custom functions" - he's just better at the details that I was.
Title: Re: Scripting help - Hotspot interaction
Post by: Rui 'Trovatore' Pires on Sun 13/11/2005 21:15:38
Naturally, though, if you're going to take that route, you hardly need to use AGS' interface and can feel free to check out other engines which are 100% script-oriented.
Title: Re: Scripting help - Hotspot interaction
Post by: Ricardo on Sun 13/11/2005 21:21:39
Thanks everybody. As I said, the purpose of this question wasn't practical but educational... All I was looking for was another way to improve my scripting skills and you helped me a lot with that.

Thanks again