hotspot help

This forum is meant for posting anything related to Adventure Maker that doesn't fit in the other forums.Please post technical questions in the Technical Support Forum!

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

hotspot help

Postby muttlay » Wed Aug 25, 2010 6:36 pm

Hi
I wonder if someone could help me out.
I have worked out how to make a hotspot appear with a random picture inside it.
Now im stuck,id like to get the program to go to another frame after say 5 secs depending on what random hotspot picture is shown.
Thanks for your time.
muttlay
New Member
 
Posts: 4
Joined: Wed Aug 25, 2010 6:28 pm

Postby JasonMc » Wed Aug 25, 2010 7:19 pm

I might need some more information about what you're hoping to do, but here's my first attempt at it.

What you will want to do is, first of all, create a variant global variable titled "randompicturetitle".

Now, in the code for selecting a random picture, you will also want to have it set that variable at the same time. The variable in each instance should be set to the name of that picture.

If you need further instruction on doing that, please post the code you're using for displaying a random picture.

Next, on frame properties, you will want to enter this:

Code: Select all
Action.CreateTimedEvent 5, "RandomPictureGoToFrame", 0


Now, click on the "Procedures" button. You are going to create a new procedure in this window. Enter this code. I'd recommend copy and paste.

(P.S. The below code could also be replaced with a Select Case, but I prefer to use If)

Code: Select all
Sub RandomPictureGoToFrame()
If randompicturetitle=[NAME OF FIRST PICTURE] Then Action.GoToFrame [FIRST TARGET FRAME]

If randompicturetitle=[NAME OF SECOND PICTURE] Then Action.GoToFrame [SECOND TARGET FRAME]

If randompicturetitle=[NAME OF SECOND PICTURE] Then Action.GoToFrame [SECOND TARGET FRAME]

'And so on

End Sub


Again, I can help you best if you post the code you're using to make a hotspot appear with a random picture inside it.

-J
-Jason McDonald
Manager, Programmer
MousePaw Games

--
PocketWatch 1.0 Plugin now available in the Plugins Corner!
User avatar
JasonMc
Active Member
 
Posts: 99
Joined: Sun Jul 04, 2010 10:27 pm
Location: Pacific Northwest, USA

Postby muttlay » Wed Aug 25, 2010 8:41 pm

Thankyou

this is my code for generating a random htspot pic
randomize

i = int( RND * 4 ) + 1
if i = 1 then Action.LoadAPicture Hotspot(1), "AF.JPG"
if i = 2 then Action.LoadAPicture Hotspot(1), "PAT.JPG"
if i = 3 then Action.LoadAPicture Hotspot(1), "K.JPG"
if i = 4 then Action.LoadAPicture Hotspot(1), "NICK.JPG"

so if pat.jpg comes up in the hotspot pic im trying to to in 5 secs go to a new frame.
im just trying your advice now but am new to this and having trouble with the varible.
thanks for your speedy help.
mutt
muttlay
New Member
 
Posts: 4
Joined: Wed Aug 25, 2010 6:28 pm

Postby JasonMc » Wed Aug 25, 2010 11:47 pm

I had to rework it a little bit. Here is the exact step-by-step breakdown (plus explainations)

1. Double click on the hotspot you want people to click on to trigger the actions.

2. Click on "Advanced"

3. Click the "Variables..." button towards the bottom. This will open your Global Variables window.

4. Click "New Integer Variable..."

An integer variable can only contain whole positive numbers. On the other hand, a variant variable can contain just about any characters - letters, symbols, numbers, etc.

5. Type "htsppic", and click "OK". This will create a new integer variable under the name you just typed in.

6. Click "OK" on the Global Variables window. This will take you back to the hotspot properties window.

7. In the "Enter VBScript code:" box, enter this code:

Code: Select all
randomize
htsppic = int(rnd*(4-1+1))+1
'This selects a random number between one and four, and saves it to our "htsppic" variable.

Select Case (htsppic)
   Case "1":
      Action.LoadAPicture Hotspot(1), "AF.JPG"
      Action.CreateTimedEvent 5, "TARGET_FRAME", 0
   Case "2":
      Action.LoadAPicture Hotspot(1), "PAT.JPG"
      Action.CreateTimedEvent 5, "TARGET_FRAME", 0
   Case "3":
      Action.LoadAPicture Hotspot(1), "K.JPG"
      Action.CreateTimedEvent 5, "TARGET_FRAME", 0
   Case "4":
      Action.LoadAPicture Hotspot(1), "NICK.JPG"
      Action.CreateTimedEvent 5, "TARGET_FRAME", 0
End Select
'This triggers an action based on the number in the "htsppic" variable that was randomly selected.


Now, replace "TARGET_FRAME" on each Case with the name of the frame you want to go to when the picture listed above it is shown. Make sure you enclose the frame name in quotes!

Note, I used a select case system, which checked the contents of the variable "htsppic". Then, based on the result, it loaded a picture into hotspot one, and created a non-repeating timed event for five seconds that would go to a target frame when the five seconds had passed.

If you have trouble, the first three things to look at are...

a) Does the name of the variable you declared in Global Variables match up EXACTLY with the one in the code?

b) Are the target frame names and image names correct?

c) Are the image names and target names in quotes? Is all the rest of the syntax (scripting "grammar") correct?

(The code posted above SHOULD be free of errors, as I either tested or cross-checked the syntax of each element. But, if you copy and paste, and get a syntax error, I'll take another look.)

I hope this helps!

-J
-Jason McDonald
Manager, Programmer
MousePaw Games

--
PocketWatch 1.0 Plugin now available in the Plugins Corner!
User avatar
JasonMc
Active Member
 
Posts: 99
Joined: Sun Jul 04, 2010 10:27 pm
Location: Pacific Northwest, USA

Postby muttlay » Thu Aug 26, 2010 6:25 pm

thanks great help i understand a bit more,
but im getting a type missmatch on the target file now.
I entered the code and ran the test hotspot appears it waits 5 seconds then prints a error message type missmatch "hello" which is my target frame.

randomize
htsppic = int(rnd*(4-1+1))+1


Select Case (htsppic)
Case "1":
Action.LoadAPicture Hotspot(1), "AF.JPG"
Action.CreateTimedEvent 5, "hello", 0
Case "2":
Action.LoadAPicture Hotspot(1), "PAT.JPG"
Action.CreateTimedEvent 5, "hello", 0
Case "3":
Action.LoadAPicture Hotspot(1), "K.JPG"
Action.CreateTimedEvent 5, "hello", 0
Case "4":
Action.LoadAPicture Hotspot(1), "NICK.JPG"
Action.CreateTimedEvent 5, "hello", 0
End Select
muttlay
New Member
 
Posts: 4
Joined: Wed Aug 25, 2010 6:28 pm

Postby juhuwoorps » Thu Aug 26, 2010 6:37 pm

You're missing the Action.Gotoframe code.

Your code should be like this:

Code: Select all
Action.CreateTimedEvent 5, "Action.Gotoframe"hello""", 0
juhuwoorps
Code Master
 
Posts: 622
Joined: Tue Jul 08, 2008 3:13 pm

Postby JasonMc » Thu Aug 26, 2010 7:35 pm

Ahh, so I did. Nice catch, juhu.

Though, doesn't the frame need to be in double quotes now? There's one missing at the start of the frame name.

Try this, muttlay...

Code: Select all
Select Case (htsppic)
Case "1":
Action.LoadAPicture Hotspot(1), "AF.JPG"
Action.CreateTimedEvent 5, "Action.GoToFrame""hello""",0
Case "2":
Action.LoadAPicture Hotspot(1), "PAT.JPG"
Action.CreateTimedEvent 5, "Action.GoToFrame""hello""",0
Case "3":
Action.LoadAPicture Hotspot(1), "K.JPG"
Action.CreateTimedEvent 5, "Action.GoToFrame""hello""",0
Case "4":
Action.LoadAPicture Hotspot(1), "NICK.JPG"
Action.CreateTimedEvent 5, "Action.GoToFrame""hello""",0
End Select
-Jason McDonald
Manager, Programmer
MousePaw Games

--
PocketWatch 1.0 Plugin now available in the Plugins Corner!
User avatar
JasonMc
Active Member
 
Posts: 99
Joined: Sun Jul 04, 2010 10:27 pm
Location: Pacific Northwest, USA

Postby juhuwoorps » Thu Aug 26, 2010 7:49 pm

If you are using a integer variable for htspic you should have the case without quotes
juhuwoorps
Code Master
 
Posts: 622
Joined: Tue Jul 08, 2008 3:13 pm

Postby muttlay » Thu Aug 26, 2010 9:45 pm

Thankyou very much for your help.
its working fine now.
your a super star.
mutt
muttlay
New Member
 
Posts: 4
Joined: Wed Aug 25, 2010 6:28 pm

Postby JasonMc » Fri Aug 27, 2010 12:50 am

Glad we could help, mutt.

Juhu, incidentally, when I tested a similar select case using an integer variable, it did need the quotes. Perhaps it doesn't matter if they are or aren't used?
-Jason McDonald
Manager, Programmer
MousePaw Games

--
PocketWatch 1.0 Plugin now available in the Plugins Corner!
User avatar
JasonMc
Active Member
 
Posts: 99
Joined: Sun Jul 04, 2010 10:27 pm
Location: Pacific Northwest, USA


Return to Adventure Maker General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests