How to do something an array normally would?
by J Sears · in Torque Game Builder · 11/16/2006 (3:04 pm) · 8 replies
If I've done my research right then arrays don't work in script (which sure does make some things tough) so anyone who's read my other posts knows I'm trygin to make a freecell game.
Here's the problem:
I need to set up a bunch of variables or strings to represent the cards in the diffrent games (most freecell games have 1 mil - 2.5 million different games). So I need a different "array" for each game so I can find out in what order the cards are. Then I would run a for loop and get each card one after another and mount them to get the right game order. I have been trying for about 6-7 hours straight now trying to figure out how to accomplish this without an array since in an array it's easy you'd have array[%i] to get that value where the i is your counting number. I can't figure out how to do this without an array. I'm thinking up some complex ideas on things that might work but to type in a million combinations for the levels in some very complex way would well completly suck obviously. Anyone have an idea?
Here's the problem:
I need to set up a bunch of variables or strings to represent the cards in the diffrent games (most freecell games have 1 mil - 2.5 million different games). So I need a different "array" for each game so I can find out in what order the cards are. Then I would run a for loop and get each card one after another and mount them to get the right game order. I have been trying for about 6-7 hours straight now trying to figure out how to accomplish this without an array since in an array it's easy you'd have array[%i] to get that value where the i is your counting number. I can't figure out how to do this without an array. I'm thinking up some complex ideas on things that might work but to type in a million combinations for the levels in some very complex way would well completly suck obviously. Anyone have an idea?
#2
11/16/2006 (6:03 pm)
But I though arrays couldn't be passed into functions in script?
#3
11/16/2006 (11:04 pm)
Use SimSets. It is more work, but you can pass it everywhere.
#4
11/16/2006 (11:13 pm)
Or you could attach the array to an object and pass that.
#5
so Tom maybe set the array up in a function, in another function set up a for loop, send the for loop variable into the array function to mark which array spot to read send back the value. I might try that too but that seems so excessive to run through that process for every card to get it's starting spot and then still go through the mounting of them
11/17/2006 (7:12 am)
Will have to look into the SimSets when I get home thank youso Tom maybe set the array up in a function, in another function set up a for loop, send the for loop variable into the array function to mark which array spot to read send back the value. I might try that too but that seems so excessive to run through that process for every card to get it's starting spot and then still go through the mounting of them
#6
http://www.garagegames.com/blogs/10513/5705
The foo() functions should be returning %wrapper, I believe.
- Matthew Durante
11/17/2006 (7:26 am)
Take a look at the comments for:http://www.garagegames.com/blogs/10513/5705
The foo() functions should be returning %wrapper, I believe.
- Matthew Durante
#7
11/17/2006 (7:59 am)
J, I think Tom was suggesting making the array a field of another object. It could be a field of a script object or one of the other objects in your game. Then you can just pass the object and reference the array from that. What you're talking about with different functions sounds awfully convoluted but also be comforted that TGB can perform thousands of calculations in less than a millisecond.
#8
11/19/2006 (9:29 pm)
I thank you all for your help, after looking at a bunch of different ways to do things and trying a couple I think I have it all worked out now.
Torque Owner Ben R Vesco