How to load data into an Array
I am currently trying to make a Random Name Generator. I am using two single dimensional arrays. Array 1 is the first name, and array2 is the last name. I would like to click a button and then choose a random entry from array 1 and array 2. This is similar to the beginning of the game worms where one can randomly generate names for the worms.
I have this fully functioning, however, in order to populate the data in the arrays, I needed to use the tutorial in the Power Users Guide to Windows Dev, to create and save each new record. THen i copy/renamed the array and moved it to the work directory i am working in. There must be an easier way.
Does anyone have some pointers into how to load a comma delimited file into an array string?
thanks in advance,
rubes
Re: How to load data into an Array
By mentioning i am using the array object probably indicates that I am using MMF 2 Developer, but if not, that is the software I am using
Re: How to load data into an Array
There is a Random Name Generator Extension you can use.
Marv
Re: How to load data into an Array
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=231250#Post2312 50
Hooray for self advertising!
This is precisely why I made the PresetArray object.
Re: How to load data into an Array
I am not familiar with that extension, but this is some basic funtionality that I would like to master without that extension (if it is possible). I'm looking thru the tutorials from your link Marv, quite an impressive number.
Re: How to load data into an Array
OK, this seems to be what I am looking for. It took a little bit of set up tweeking, and let me ask you if these settings seems correct:
Width:10
Height: 1
Array: Jonny,Jane,Robert,Lisa,Ken,Jordan,Melissa,Chris, Debbie,Rick,Extra
Delimiter: ,
I have a button w/a click event that sets a Static Text box text with this formula:
ValueAt$( "Preset Array", Random(10), 0)
I am currently just looking for a single dim array, however, in the future i would like to do first & last names at random, and was going to do 2 separate single dim arrays. Would you suggest that or a 2 dimensional array? If 2, could you help w/how the logic works?
You guys are so fast and helpful, it is really helping me get up to speed.
Re: How to load data into an Array
I made this:
http://www.create-games.com/download.asp?id=8360
It can load XML spreadsheet files generated in Excel / OpenOffice / etc, and convert them to MMF2's own array format (and vice versa).
This has the big advantage that you can use 3-dimensional arrays, whereas .csv arrays are limited to 2-dimensions, which is seldom, if ever enough.
Also, MMF2 arrays are smaller and can't be edited with a simple text editor (making it a little harder for players to cheat).
Re: How to load data into an Array
I must be missing something. What's the difference between Preset Array and String Tokenizer?
Re: How to load data into an Array
Can't you use the List object, hidden? Create a text file with lots of names, load it in the list object, assign each line a number and use a random number generator to pull out the assigned name?
Re: How to load data into an Array
MuddyMole, that looks awesome. I've downloaded it and will be using that in the future.
Jamie, I'm not familiar w/the String Tokenizer, but will read up on it.
ChrisStreet, I found a tutorial on Marv's site that does just this thing, but haven't had a chance to play with it.
I know I'll be using arrays a lot in the future (at i believe I will), so I'm practicing some concepts right now. Being so new, I'm not familiar with all of the techniques nor extensions available (or where to find them).
I want to thank everyone who has been commenting. You are a warm bunch, with lots to share. I cannot believe the quickness of the responses on this forum.
I'm sure I'll have more questions as I poke around and study everything