Letter Code Puzzle The Complex Way (PROBLEM!)

This forum is meant for people to share their knowledge by writing their own tutorials for Adventure Maker.

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

Letter Code Puzzle The Complex Way (PROBLEM!)

Postby Jaked » Sat Sep 19, 2009 3:35 am

Okay, my original intention was a letter code puzzle, like mercede's number pad 1-9 thing except slightly different. I wanted there to be three boxes with letters A,B,C,D, and E. Each three has a left arrow on the left side that goes A,E, etc... and a right arrow that goes A,B, etc. Not only that, but under each box, there was a switch. If you flip the switch and it's on the correct letter, it becomes green. Else, red. Easy to do, but all in all, that's about 20 variables and I stumbled on a problem.

Variable Procedures and Frame Properties for Box 1 ONLY(To start the 1st box at A until told it's not A)

Procedures:

Code: Select all
If Box1Letter1=1 Then
Action.LoadAPicture Hotspot(1), "A.JPG"
End If
If Box1Letter2=1 Then
Action.LoadAPicture Hotspot(1), "B.JPG"
End If
If Box1Letter3=1 Then
Action.LoadAPicture Hotspot(1), "C.JPG"
End If
If Box1Letter4=1 Then
Action.LoadAPicture Hotspot(1), "D.JPG"
End If
If Box1Letter5=1 Then
Action.LoadAPicture Hotspot(1), "E.JPG"
End If


Frame Properties:

Code: Select all
Box1Letter1=1
Box1Letter2=0
Box1Letter3=0
Box1Letter4=0
Box1Letter5=0


It's at the Left and Right Arrows that I stumbled upon a problem. I realised now that the problem was that when I noticed my code was this:

Box 1 Left Arrow (A to E and E to D code):

Code: Select all
Box1Letters=Box1Letter1+Box1Letter2+Box1Letter3+Box1Letter4+Box1Letter5
If Box1Letter1=1 then
Box1Letter1=0
Box1Letter5=1
End If
If Box1Letter5=1 then
Box1Letter5=0
Box1Letter4=1
End If


Box 1 Right Arrow (A to B and B to C code)

Code: Select all
Box1Letters=Box1Letter1+Box1Letter2+Box1Letter3+Box1Letter4+Box1Letter5
If Box1Letter1=1 then
Box1Letter1=0
Box1Letter2=1
Action.LoadAPicture Hotspot(1), "B.JPG"
End If
If Box1Letter2=1 then
Box1Letter2=0
Box1Letter3=1
Action.LoadAPicture Hotspot(1), "C.JPG"
End If


When I tested it, I realised that It's just unlimitly going through the chain of events. Because it wasn't completely full circle, the Left Arrow just skipped E and went to D and the Right Arrow just skipped B and went to C. I wan't it to be a little different code and to do it without the Case Select because it's just akward. So without Case Select OR removing the arrows, can anyone tell me how to fix this?
My sig changes more often than Doctor Who (see your national BBC channel) regenarates into new melancholy actors. Oh look, Matt Smith! Gerard Butler! Colin Mochrie! That wolf from Twilight: New Moon!
User avatar
Jaked
Code Master
 
Posts: 729
Joined: Wed Jun 25, 2008 4:26 am

Postby Lyberodoggy » Sat Sep 19, 2009 8:03 am

You can't avoid select case. There's no need to. I 'm fixing the whole code:
remove the variables named in the form BoxnumberLetternumber and replace them with variables named BoxnumberLetter (so you 'll need only 3 variables
I assume that the first box is the hotspot number 1

Code: Select all
Sub LoadNextLetter(hotspotindex)
Set localvar=GetVariableReferenceFromName("Box"+hotspotindex+"Letter")
Select Case localvar
case 1
Action.LoadAPicture Hotspot(hotspotindex), "A.JPG"
case 2
Action.LoadAPicture Hotspot(hotspotindex), "B.JPG"
case 3
Action.LoadAPicture Hotspot(hotspotindex), "C.JPG"
case 4
Action.LoadAPicture Hotspot(hotspotindex), "D.JPG"
case 5
Action.LoadAPicture Hotspot(hotspotindex), "E.JPG"
end select
end sub

'Frame properties:
Box1Letter=1

'Left arrow
Box1Letter=Box1Letter-1
if Box1Letter=0 then Box1Letter=5
LoadNextLetter 1

'Right arrow
Box1Letter=Box1Letter+1
if Box1Letter=6 then Box1Letter=1
LoadNextLetter 1


This should do. However I didn't have the time to test it so it could have some bugs. Don't worry. Just test it and tell me if anything doesn't go as expected and I 'll fix it yesterday :P
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Jaked » Sat Sep 19, 2009 4:50 pm

Six if you count the switches. Or 10 if you count the SwitchCorrect variables, and 11 if you count Allswitches (Switch1+Switch2+Switch3). Also, am I able to call the left and right arrows Left Arrow and Right Arrow if they're Hotspot 2 and Hotspot 3?
My sig changes more often than Doctor Who (see your national BBC channel) regenarates into new melancholy actors. Oh look, Matt Smith! Gerard Butler! Colin Mochrie! That wolf from Twilight: New Moon!
User avatar
Jaked
Code Master
 
Posts: 729
Joined: Wed Jun 25, 2008 4:26 am

Postby Jaked » Sat Sep 19, 2009 5:01 pm

Also, I wasn't sure, so I did this:

Code: Select all
Sub LoadNextLetter(hotspotindex)
Set localvar=GetVariableReferenceFromName("Box"+hotspotindex+"Letter")
Select Case localvar
case 1
Action.LoadAPicture Hotspot(hotspotindex), "A.JPG"
case 2
Action.LoadAPicture Hotspot(hotspotindex), "B.JPG"
case 3
Action.LoadAPicture Hotspot(hotspotindex), "C.JPG"
case 4
Action.LoadAPicture Hotspot(hotspotindex), "D.JPG"
case 5
Action.LoadAPicture Hotspot(hotspotindex), "E.JPG"
end select
end sub

'Frame properties:
Box1Letter=1

'Hotspot 2
Box1Letter=Box1Letter-1
if Box1Letter=0 then Box1Letter=5
LoadNextLetter 1

'Hotspot 3
Box1Letter=Box1Letter+1
if Box1Letter=6 then Box1Letter=1
LoadNextLetter 1


And I got this

...

It was an error.
My sig changes more often than Doctor Who (see your national BBC channel) regenarates into new melancholy actors. Oh look, Matt Smith! Gerard Butler! Colin Mochrie! That wolf from Twilight: New Moon!
User avatar
Jaked
Code Master
 
Posts: 729
Joined: Wed Jun 25, 2008 4:26 am

Postby Lyberodoggy » Sat Sep 19, 2009 10:33 pm

This should go in the vbs procedures:

Code: Select all
Sub LoadNextLetter(hotspotindex)
Set localvar=GetVariableReferenceFromName("Box"+hotspotindex+"Letter")
Select Case localvar
case 1
Action.LoadAPicture Hotspot(hotspotindex), "A.JPG"
case 2
Action.LoadAPicture Hotspot(hotspotindex), "B.JPG"
case 3
Action.LoadAPicture Hotspot(hotspotindex), "C.JPG"
case 4
Action.LoadAPicture Hotspot(hotspotindex), "D.JPG"
case 5
Action.LoadAPicture Hotspot(hotspotindex), "E.JPG"
end select
end sub



Then create the three integer variables named Box1Letter, Box2Letter, Box3Letter.

Now make sure that the first letter hotspot is hotspot number 1, the second 2 and the third 3 (you can use the right click-> send back command)

Frame properties
Code: Select all
Box1Letter=1
Box2Letter=2
Box3Letter=3


Left button
Code: Select all
Box1Letter=Box1Letter-1
if Box1Letter=0 then Box1Letter=5
LoadNextLetter 1


Replace 1 with 2 and 3 for the other left arrows

Right Button
Code: Select all
Box1Letter=Box1Letter+1
if Box1Letter=6 then Box1Letter=1
LoadNextLetter 1
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Jaked » Sat Sep 19, 2009 10:45 pm

Well, if you think it's completely right, then take a looky here!

Image

It says, and I DIRECTLY quote:

"Error executing script:

The Scripting Engine returned the following error message

Type Mismatch: '[string: "Box"]'

Please click OK to continue or Cancel to exit the application."
My sig changes more often than Doctor Who (see your national BBC channel) regenarates into new melancholy actors. Oh look, Matt Smith! Gerard Butler! Colin Mochrie! That wolf from Twilight: New Moon!
User avatar
Jaked
Code Master
 
Posts: 729
Joined: Wed Jun 25, 2008 4:26 am

Postby Lyberodoggy » Sat Sep 19, 2009 11:01 pm

Yeah, sorry 'bout that. Change this line:
Set localvar=GetVariableReferenceFromName("Box"+hotspotindex+"Letter")
to
Set localvar=GetVariableReferenceFromName("Box"+cstr(hotspotindex)+"Letter")
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Jaked » Sat Sep 19, 2009 11:06 pm

Anyhoo so far it is this:

Variable Procedures:

Code: Select all
Sub LoadNextLetter(hotspotindex)
Set localvar=GetVariableReferenceFromName("Box"+cstr(hotspotindex)+"Letter")
Select Case localvar
Case 1
Action.LoadAPicture Hotspot(hotspotindex), "A.JPG"
Case 2
Action.LoadAPicture Hotspot(hotspotindex), "B.JPG"
Case 3
Action.LoadAPicture Hotspot(hotspotindex), "C.JPG"
Case 4
Action.LoadAPicture Hotspot(hotspotindex), "D.JPG"
Case 5
Action.LoadAPicture Hotspot(hotspotindex), "E.JPG"
End Select
End Sub


Frame Properties (SWITCH ON IMAGE OPTIONS AND STARTING VBS):

Code: Select all
Box1Letter=1
Box2Letter=2
Box3Letter=3
If Switch_1_Correct=1 Then
Action.LoadAPicture Hotspot(7), "Switch_ON_Right.JPG"
Else
Action.LoadAPicture Hotspot(7), "Switch_ON_Wrong.JPG"
End If
If Switch_2_Correct=1 Then
Action.LoadAPicture Hotspot(8), "Switch_ON_Right.JPG"
Else
Action.LoadAPicture Hotspot(8), "Switch_ON_Wrong.JPG"
End If
If Switch_3_Correct=1 Then
Action.LoadAPicture Hotspot(9), "Switch_ON_Right.JPG"
Else
Action.LoadAPicture Hotspot(9), "Switch_ON_Wrong.JPG"
End If


Left Arrows and right arrows

Code: Select all
Box1Letter=Box1Letter-1
if Box1Letter=0 then Box1Letter=5
LoadNextLetter 1


Code: Select all
Box1Letter=Box1Letter+1
if Box1Letter=6 then Box1Letter=1
LoadNextLetter 1




Switches Hotspots (ON AND OFF)

Set the OFF Switch Hotspots to only appear if Switch X(1, 2, or 3) is 0 and the ON switch is the polar opposite. Also set the hotspot for OFF with a basic LEVER DOWN and the ON one with two options: red for wrong, green for great for the

OFF SWITCHES (Turn on):

Code: Select all
Switch_1_On=1


ON SWITCHES (Turn off):

Code: Select all
Switch_1_On=0


Win Code:

Code: Select all
AllCorrect=Switch_1_On+Switch_1_Correct+Switch_2_On+Switch_2_Correct+Switch_3_On+Switch_3_Correct
AllSwitchesOn=Switch_1_On+Switch_2_On+Switch_3_On
AllLightsGreen=Switch_1_Correct+Switch_2_Correct+Switch_3_Correct
If AllCorrect=6 then
Action.Message "Everything's in order and you completed the test!"
Else if AllSwitchesOn=3 then
Action.Message "Halfway there!"
Else if AllLightsGreen=3 then
Action.Message "You got them all correct, you forgot the switches!"
Else
Action.Message "Are you SURE?"
End If
End If
End If
[/code]
My sig changes more often than Doctor Who (see your national BBC channel) regenarates into new melancholy actors. Oh look, Matt Smith! Gerard Butler! Colin Mochrie! That wolf from Twilight: New Moon!
User avatar
Jaked
Code Master
 
Posts: 729
Joined: Wed Jun 25, 2008 4:26 am

Postby Jaked » Sat Sep 19, 2009 11:11 pm

WAIT A MINUTE! What about the code? Like ABC or CAB? How do I set them individually if it's in VBS Procedures?
My sig changes more often than Doctor Who (see your national BBC channel) regenarates into new melancholy actors. Oh look, Matt Smith! Gerard Butler! Colin Mochrie! That wolf from Twilight: New Moon!
User avatar
Jaked
Code Master
 
Posts: 729
Joined: Wed Jun 25, 2008 4:26 am

Postby Lyberodoggy » Sun Sep 20, 2009 8:00 am

No, just add an if in each arrow, like this
if box1letter=2 then Switch_1_Correct=1

Where you must change 1 and 2 accordingly.
Also this code should be like this in the frame properties:
Box1Letter=1
Box2Letter=1
Box3Letter=1
LoadNextLetter 1
LoadNextLetter 2
LoadNextLetter 3

Because you want it to start on the first letter and show it
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Jaked » Sun Sep 20, 2009 7:27 pm

Yes, it is almost there! I believe it works, but now the switches won't turn green even when I put this in frame properties!

Code: Select all
If Switch_1_Correct=1 Then
Action.LoadAPicture Hotspot(7), "Switch_ON_Right.JPG"
Else
Action.LoadAPicture Hotspot(7), "Switch_ON_Wrong.JPG"
End If
If Switch_2_Correct=1 Then
Action.LoadAPicture Hotspot(8), "Switch_ON_Right.JPG"
Else
Action.LoadAPicture Hotspot(8), "Switch_ON_Wrong.JPG"
End If
If Switch_3_Correct=1 Then
Action.LoadAPicture Hotspot(9), "Switch_ON_Right.JPG"
Else
Action.LoadAPicture Hotspot(9), "Switch_ON_Wrong.JPG"
End If
My sig changes more often than Doctor Who (see your national BBC channel) regenarates into new melancholy actors. Oh look, Matt Smith! Gerard Butler! Colin Mochrie! That wolf from Twilight: New Moon!
User avatar
Jaked
Code Master
 
Posts: 729
Joined: Wed Jun 25, 2008 4:26 am

Postby Lyberodoggy » Sun Sep 20, 2009 9:26 pm

Can you upload a sample? I can't debug it if I can't check what happens myself. You can pm me if you don't want this to be public.
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Jaked » Thu Sep 24, 2009 5:21 pm

Nevermind! I took out the switches and it works just fine.
My sig changes more often than Doctor Who (see your national BBC channel) regenarates into new melancholy actors. Oh look, Matt Smith! Gerard Butler! Colin Mochrie! That wolf from Twilight: New Moon!
User avatar
Jaked
Code Master
 
Posts: 729
Joined: Wed Jun 25, 2008 4:26 am


Return to Post Your Own Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests

cron