There are other tutorials which show how to create a codebox (a num pad where the player has to press the right sequence of numbers). This tutorial is made to show how to display the numbers pressed in a textbox.
Let's assume you want the player to input a 4 integer standard pin:
Go to the global procedures and type:
- Code: Select all
Function buttondisplay(buttonnumber)
If ConvertToNumber(TextBoxObject(1).Text)<=999 Then
TextBoxObject(1).text=TextBoxObject(1).text+cstr(buttonnumber)
End If
End Function
Remember!!! Change the index of the textbox if you use another textbox OR the parser plugin! Change 999 if you want to display more than 4 digits (for five digits enter 9999, for six 99999 etc).
Then go to the frame where your codebox is. Enter this to frame's advanced:
- Code: Select all
LoadControl TextBoxObject(1)
TextBoxObject(1).Visible=True
TextBoxObject(1).Move 215*15,384*15,200*15,15*15
Textboxobject(1).Locked=True
Remember!!! Change the coordinates to fit with your project and set the index to an available one (the same as in the function).
Now go to the nine or ten hotspots representing numbers from 0 or 1 to 9 (in this case, you will have a problem if the first digit is 0, so it's not recommended to use 0 first in the sequence). Type in each of them this:
- Code: Select all
buttondisplay(1)
where 1 must be changed depending on the number the hotspot is representing.
Create a "Clear" button and type this code in the Advanced:
- Code: Select all
TextBoxObject(1).text=""
Finally create an "Enter" button and modify this code to fit to your project:
- Code: Select all
If ConvertToNumber(TextBoxObject(1).text)= 1234 Then
MsgBox "You got it"
Else
MsgBox "try again"
TextBoxObject(1).text=""
End If
(change 1234 with the sequence you want, change the actions if the typed sequence is right etc).
Hope it was usefull.
Attaching sample...