Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: EnterTheStory (aka tolworthy) on Tue 11/11/2008 11:46:57

Title: how do I detect an interaction type?
Post by: EnterTheStory (aka tolworthy) on Tue 11/11/2008 11:46:57
All my room hotspots have one of two interaction types: "player go to a different room" or or "run script."

Whenever someone clicks the mouse I run a "tidy up" function, resetting some variables to zero. But I don't want to do that if "run script" is being called (in case those variables are needed). How can I tell which interaction is being called?

Or do I need to go into every hotspot and edit it manually, calling my "tidy up" code separately each time?
Title: Re: how do I detect an interaction type?
Post by: GarageGothic on Tue 11/11/2008 12:24:23
Can't you do the cleaning up in the on_event for eEventLeaveRoom?
Title: Re: how do I detect an interaction type?
Post by: EnterTheStory (aka tolworthy) on Tue 11/11/2008 15:24:15
Quote from: GarageGothic on Tue 11/11/2008 12:24:23
Can't you do the cleaning up in the on_event for eEventLeaveRoom?
No, because that can't tell how the person left the room. If a character left via "player go to a different room" then I need to reset all variables. But if she left via "run script" then I need to preserve the variables for the next room.
Title: Re: how do I detect an interaction type?
Post by: GarageGothic on Tue 11/11/2008 15:34:54
Ah, I didn't realize the player could also leave rooms via the "run script" events. How about adding a custom property (bool) that you set to true for the "player go to a different room" hotspots, and then run your clean-up code in the on_mouse_click for those hotspot before calling RunInteraction?

Title: Re: how do I detect an interaction type?
Post by: SSH on Tue 11/11/2008 17:03:18
You could:

make a ChrisTChangeRoom function which sets a global variable "nocleanup" to 1. Use this in all scripts. Then in your on_event, only cleanup  if nocleanup is 0. Then always reset it to 0 in the on_event handler, too.
Title: Re: how do I detect an interaction type?
Post by: EnterTheStory (aka tolworthy) on Tue 11/11/2008 18:48:32
Quote from: SSH on Tue 11/11/2008 17:03:18
You could:

make a ChrisTChangeRoom function which sets a global variable "nocleanup" to 1. Use this in all scripts. Then in your on_event, only cleanup  if nocleanup is 0. Then always reset it to 0 in the on_event handler, too.


Ah, that would work! I don't fancy going through all 700 "normal" hotspots, but it would be much less work to go through the 50 or so "special" hotspots. Thanks.

Which leads to the next question... is there a way to access the code in each hotspot from a script? Name, walkToX, etc., are accessible, but I don't now how to see inside the interaction without opening every single hotspot one at a time and tunneling down the layers of boxes for each one (80 roomx x 10 hotspots on average... and I can't remember which ones have scripts :(
Title: Re: how do I detect an interaction type?
Post by: Trent R on Tue 11/11/2008 19:54:56
You could try a macro program and record the mouse movements and clicks to click the events tab, and the ellipsis button.

Then just use the general definitions pull down at the the top of the script editor. If you're 'correctly' named all of your elements, you can just look for hspot1_Look, hTable_Interact, etc, etc and jump straight to it.


~Trent
PS-One program I've used before was AutoHotKey, and was fairly simple to script it.



Crap. Didn't realize you were still talking about the old editor. I don't know if my advice still applies...

~Trent
Title: Re: how do I detect an interaction type?
Post by: Pumaman on Tue 11/11/2008 23:08:59
Quote from: tolworthy on Tue 11/11/2008 18:48:32
Which leads to the next question... is there a way to access the code in each hotspot from a script? Name, walkToX, etc., are accessible, but I don't now how to see inside the interaction without opening every single hotspot one at a time and tunneling down the layers of boxes for each one (80 roomx x 10 hotspots on average... and I can't remember which ones have scripts :(

No, there isn't -- one of the reasons why the interaction editor was scrapped in AGS 3 :)