hefty Posted April 22, 2006 Share Posted April 22, 2006 (edited) I get a zero? HotKeySet("{Home}", "n") While 1 Sleep(10000) WEnd Func n() $Pet1 = string( "strider" ) $Pet2 = string( "stalker") $God1 = string( "grenth" ) $God2 = string( "balthazar" ) $FirstName = Random( String($God1), ($God2)) $LastName = Random( String($Pet1), ($Pet2)) $FullName = String( $FirstName + "s " + $Lastname ) MsgBox(64, "Your Pet's Name", $FullName ) EndFunc Edited April 22, 2006 by hefty Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 22, 2006 Share Posted April 22, 2006 (edited) I get a zero? HotKeySet("{Home}", "n") While 1 Sleep(10000) WEnd Func n() $Pet1 = string( "strider" ) $Pet2 = string( "stalker") $God1 = string( "grenth" ) $God2 = string( "balthazar" ) $FirstName = Random( String($God1), ($God2)) $LastName = Random( String($Pet1), ($Pet2)) $FullName = String( $FirstName + "s " + $Lastname ) MsgBox(64, "Your Pet's Name", $FullName ) EndFunc Your use of Random() is broken. That function only returns numbers. Try this: #include<array.au3> Dim $Pet[1] _ArrayAdd($Pet, "strider") _ArrayAdd($Pet, "stalker") _ArrayAdd($Pet, "strutter") $Pet[0] = UBound($Pet) - 1 Dim $God[1] _ArrayAdd($God, "grenth") _ArrayAdd($God, "balthazar") _ArrayAdd($God, "kobol") $God[0] = UBound($God) - 1 HotKeySet("{Home}", "_n") While 1 Sleep(5000) WEnd Func _n() $FirstName = $God[Random(1, $God[0], 1)] $LastName = $Pet[Random(1, $Pet[0], 1)] $FullName = $FirstName & "'s " & $LastName MsgBox(64, "Your Pet's Name", $FullName) EndFunc ;==>_n What I like about this kind of array is how easy it can be updated. Just insert another _ArrayAdd() line and it adjust to the number of items in the array (via the Ubound function). Look at the line that sets $FirstName. All three parameters for the Random() function are numbers. "1" is the minimum number. The second number is the maximum value and comes from $God[0], which contains the maximum index for that array (from Ubound). The last "1" is a flag to generate an integer instead of a floating point number. All that use of String() was extraneous. The number returned by Random() is then used as the index for getting the name from the array. Check out the various functions used in the helpfile for AutoIT, which is also the complete command reference. Edited April 22, 2006 by PsaltyDS 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 Link to comment Share on other sites More sharing options...
hefty Posted April 22, 2006 Author Share Posted April 22, 2006 Your use of Random() is broken. That function only returns numbers. Try this: #include<array.au3> Dim $Pet[1] _ArrayAdd($Pet, "strider") _ArrayAdd($Pet, "stalker") _ArrayAdd($Pet, "strutter") $Pet[0] = UBound($Pet) - 1 Dim $God[1] _ArrayAdd($God, "grenth") _ArrayAdd($God, "balthazar") _ArrayAdd($God, "kobol") $God[0] = UBound($God) - 1 HotKeySet("{Home}", "_n") While 1 Sleep(5000) WEnd Func _n() $FirstName = $God[Random(1, $God[0], 1)] $LastName = $Pet[Random(1, $Pet[0], 1)] $FullName = $FirstName & "'s " & $LastName MsgBox(64, "Your Pet's Name", $FullName) EndFunc;==>_n What I like about this kind of array is how easy it can be updated. Just insert another _ArrayAdd() line and it adjust to the number of items in the array (via the Ubound function). Look at the line that sets $FirstName. All three parameters for the Random() function are numbers. "1" is the minimum number. The second number is the maximum value and comes from $God[0], which contains the maximum index for that array (from Ubound). The last "1" is a flag to generate an integer instead of a floating point number. All that use of String() was extraneous. The number returned by Random() is then used as the index for getting the name from the array. Check out the various functions used in the helpfile for AutoIT, which is also the complete command reference. thankyou very much Link to comment Share on other sites More sharing options...
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