Scripting help - Hotspot interaction (SOLVED)

Started by Ricardo, Sun 13/11/2005 17:04:10

Previous topic - Next topic

Ricardo

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.
May The Force be with you

Pumaman

Try this:

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

also, this really belongs in the Beginners Tech Forum.

Ricardo

I didn't mean the actual saying but how to activate it when he looks at the hotspot.
May The Force be with you

Pumaman


Ricardo

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.
May The Force be with you

Pumaman

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.

Ricardo

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).
May The Force be with you

Bernie

You mean you don't want to use the hotspot/object interaction editor?

Ricardo

Exactly! It's not that I have anything against it, I'm just looking for ways to improve my scripting capabilities.
May The Force be with you

Ashen

To clarify (I hope):
The first part of the Interaction Editor - the part with Look at hotspot, Interact hotspot, Use inventory on hotspot, etc:

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:

All you need from the drop-down menu is Run Script.
I know what you're thinking ... Don't think that.

Ricardo

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
May The Force be with you

Ashen

#11
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 - 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 for more information.

And yes, this probably does belong in Beginner's Tech.
I know what you're thinking ... Don't think that.

Ricardo

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.
May The Force be with you

SSH

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.
12

Ashen

#14
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:
Code: ags

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.
I know what you're thinking ... Don't think that.

Rui 'Trovatore' Pires

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.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Ricardo

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
May The Force be with you

SMF spam blocked by CleanTalk