Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support
KeyCount = KeyCount + 1
KeyCount = KeyCount + 1
Text(1).caption = Text(1).caption & "q" 'If this is the "M-key" hotspot
If KeyCount > len(Answer) Then
keyCount = 0
Text(1).caption = ""
Action.Message "You pull the paper from the typewriter and start over"
ElseIf KeyCount = len(Answer) Then
If Text(1).caption = Answer Then
'SUCCESS!!!!!
Action.GoToFrame "success"
End If
End If
Answer = "mary had a little lamb"
KeyCount = 0
Text(1).caption = ""
reneuend wrote:
From Shadow's Response:
Using the hotspot().tag method we can store the keypress character in the hotspot's tag. Why? What is the advantage?
The biggest advantage is that it makes the hotspots all the same. So, any changes that need to be done can be done in 1 place and not in every hotspot. It also removes the need for a counter!
I'm still using a textbox. a typewriter image with a hotspot on each letter key.
Each hotspot will have the following code in the advanced tab:
- Code: Select all
ProcessHotSpotClick(Action.GetHotspotNumber)
This calls the ProcessHotSpotClick routine and passes the hotspot number to that routine.
Click on the [procedures...] button and add this routine:
- Code: Select all
sub ProcessHotSpotClick(tagvalue)
Dim hsvalue
hsvalue = Hotspot(tagvalue).tag
Text(1).caption = Text(1).caption & hsvalue
If Text(1).caption = Answer Then
'Success
Action.GoToFrame "success"
ElseIf len(text(1).caption) = len(Answer) Then
'fail!
Action.message "Rats! You pull the paper from the typewriter," & vbcrlf & "crumple it, and start over."
Text(1).caption = ""
Else
'do nothing
End If
End Sub
You probably would change the message or the action that should happen when the player gets the correct answer, but that is about all. Plus, since the routine is in one place, you can affect all of the hotspots in this routine. For instance, i could add a click sound to the "Else" statement.
Finally, Add the following code to set up the tags in the Frames Properties - Advanced Tab:
- Code: Select all
Answer = "test"
Text(1).caption = ""
Hotspot(2).tag = "q"
Hotspot(3).tag = "w"
Hotspot(4).tag = "e"
Hotspot(5).tag = "r"
Hotspot(6).tag = "t"
Hotspot(7).tag = "y"
Hotspot(8).tag = "u"
Hotspot(9).tag = "i"
Hotspot(10).tag = "o"
Hotspot(11).tag = "p"
Hotspot(12).tag = "a"
Hotspot(13).tag = "s"
Hotspot(14).tag = "d"
Hotspot(15).tag = "f"
Hotspot(16).tag = "g"
Hotspot(17).tag = "h"
Hotspot(18).tag = "j"
Hotspot(19).tag = "k"
Hotspot(20).tag = "l"
Hotspot(21).tag = "z"
Hotspot(22).tag = "x"
Hotspot(23).tag = "c"
Hotspot(24).tag = "v"
Hotspot(25).tag = "b"
Hotspot(26).tag = "n"
Hotspot(27).tag = "m"
Hotspot(28).tag = " "
Change the value for the variable, Answer to the value you want the player to solve.
Be sure to add this 1 variable under "Advanced-Variables":
Answer as variant
marina wrote:Wow!!!
Thanks a lot again
I'm sure as well Reneuend's is a great piece of code for me! I'll know tomorrow morning, now I'm about to go to sleep
You know, ShadowHunter, the "Gallo rosso" is quite far from my home; if you have been near "San Giovanni", you missed me for a handful of meters.
I'm fond of grappa! Next time you come to Rome send me a message!
Return to Adventure Maker Technical Support and Bug Reports
Users browsing this forum: No registered users and 0 guests