Author | Message | Time |
---|---|---|
Forged | I am hosting a war3 Tourny and need a program that can take a list of maps and randomlly spit one out. The problem is I have no idea how to do this, I assume it has something to do with arrays but for the most part I am clueless. Can someone please help me? | June 25, 2004, 4:19 PM |
Spht | [quote author=Forged link=board=31;threadid=7440;start=0#msg67139 date=1088180354] I am hosting a war3 Tourny and need a program that can take a list of maps and randomlly spit one out. The problem is I have no idea how to do this, I assume it has something to do with arrays but for the most part I am clueless. Can someone please help me? [/quote] You can use Dir to get the filename of each map in the maps folder while loading them into a string array. When finished, you can then use the formula Int((upperbound - lowerbound + 1) * Rnd + lowerbound) to pick out a random map filename from the string array. upperbound being UBound result and lowerbound being LBound result of the string array. | June 25, 2004, 4:55 PM |
Forged | [code] Public Sub GetMap() Dim Random As Integer Dim Maps As String Dim count As Integer Dim Pick As String Maps = Dir(App.Path & "/maps.txt") Open Maps For Input As #1 Do Input #1, Pick count = count + 1 Loop Until EOF(1) Close #1 Randomize Random = (Rnd * count) - 1 If Random <> 1 Then Random = Random - 1 End If Open Maps For Input As #1 Do Line Input #1, Pick Random = Random - 1 Loop While Random <> 0 Form1.Text1.Text = "Use " & Pick End Sub [/code] It picks the first map on the list -_- | June 25, 2004, 7:18 PM |
Stealth | Did you listen to a word Spht said? He even gave you the random selection formula. | June 25, 2004, 10:37 PM |