crazyjts Posted May 14, 2009 Posted May 14, 2009 The following section of code is supposed to take a user entered value (e.g. 6) and then take that value to create a predefined constant (e.g. $CrntXPLvl = $CL6XP = 9000) and subtract that constant from another constant ($CL10XP in this example) to obtain the remaining XP the character needs. The result I get for TotalXP is the value of the constant $CL10XP (i.e. 32000) and not the difference between $CL10XP and $CrntXPLvl (CL6XP in this example) which should be 23000 (i.e. 32000 - 9000). I'm sure it's the way I'm trying to use the $CrntXPLvl variable but I cannot figure out the correct way to do what I want. Any help is appreciated. Dim $CL5XP = 1000, $CL6XP = 9000, $CL7XP = 12000, $CL8XP = 18000, $CL9XP = 24000, $CL10XP = 32000 #include <Misc.au3> $CrntLvl = String(InputBox( "Current Level", "Enter your current level and click the OK button" ));gets user input for their current level (6 in this example) $CrntXPLvl = "$CL" & $CrntLvl & "XP";sets $CrntXPLvl equal to $CL<user level>XP, e.g. $CL6XP MsgBox(0,"","$CrntXPLvl = " & $CrntXPLvl);message box displaying that value for $CrntXPLvl If $CrntLvl >= 5 And $CrntLvl < 10 Then;check to see if the user entered value falls within the desired range $TotalXP = $CL10XP - $CrntXPLvl;calculate the total XP remaining based on the user enter value and the high end level MsgBox(0,"Info","Total XP required to move to the next level = " & $TotalXP);message box to display the remaining XP EndIf
PsaltyDS Posted May 14, 2009 Posted May 14, 2009 The following section of code is supposed to take a user entered value (e.g. 6) and then take that value to create a predefined constant (e.g. $CrntXPLvl = $CL6XP = 9000) and subtract that constant from another constant ($CL10XP in this example) to obtain the remaining XP the character needs. The result I get for TotalXP is the value of the constant $CL10XP (i.e. 32000) and not the difference between $CL10XP and $CrntXPLvl (CL6XP in this example) which should be 23000 (i.e. 32000 - 9000). I'm sure it's the way I'm trying to use the $CrntXPLvl variable but I cannot figure out the correct way to do what I want. Any help is appreciated. Dim $CL5XP = 1000, $CL6XP = 9000, $CL7XP = 12000, $CL8XP = 18000, $CL9XP = 24000, $CL10XP = 32000 #include <Misc.au3> $CrntLvl = String(InputBox( "Current Level", "Enter your current level and click the OK button" ));gets user input for their current level (6 in this example) $CrntXPLvl = "$CL" & $CrntLvl & "XP";sets $CrntXPLvl equal to $CL<user level>XP, e.g. $CL6XP MsgBox(0,"","$CrntXPLvl = " & $CrntXPLvl);message box displaying that value for $CrntXPLvl If $CrntLvl >= 5 And $CrntLvl < 10 Then;check to see if the user entered value falls within the desired range $TotalXP = $CL10XP - $CrntXPLvl;calculate the total XP remaining based on the user enter value and the high end level MsgBox(0,"Info","Total XP required to move to the next level = " & $TotalXP);message box to display the remaining XP EndIf I think you are trying to reinvent Eval("CL6XP"). Look it up in the help file. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Authenticity Posted May 14, 2009 Posted May 14, 2009 (edited) Dim $CL5XP = 1000, $CL6XP = 9000, $CL7XP = 12000, $CL8XP = 18000, $CL9XP = 24000, $CL10XP = 32000 #include <Misc.au3> $CrntLvl = String(InputBox( "Current Level", "Enter your current level and click the OK button" ));gets user input for their current level (6 in this example) $CrntXPLvl = Eval("CL" & $CrntLvl & "XP");sets $CrntXPLvl equal to $CL<user level>XP, e.g. $CL6XP MsgBox(0,"","$CrntXPLvl = " & $CrntXPLvl);message box displaying that value for $CrntXPLvl If $CrntLvl >= 5 And $CrntLvl < 10 Then;check to see if the user entered value falls within the desired range $TotalXP = $CL10XP - $CrntXPLvl;calculate the total XP remaining based on the user enter value and the high end level MsgBox(0,"Info","Total XP required to move to the next level = " & $TotalXP);message box to display the remaining XP EndIf Edited May 14, 2009 by Authenticity
crazyjts Posted May 14, 2009 Author Posted May 14, 2009 I think you are trying to reinvent Eval("CL6XP"). Look it up in the help file. Ah....perfect. Thank you!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now