HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Array Question: How to work with a grid

04-01-2004, 11:44 PM#1
Quantos
So here I was, about to make WAY too many triggers, til I realized that there are arrays. I'm not comfortable with Arrays in WE yet, but I'll get there.

I'm hoping for some help on how to do this:

Map Basics: The map is segmented in a grid pattern. Each grid spot has a region representing it. Horrizontally is represented by Numbers, Vertically is represented as Letters (Like a chess board) Without large details, each grid spot can have circumstances which allows for up to 4 Production points on them.

Goal: To use arrays to hold a piece of information about each square. In theory, you should be able to use 10 arrays with 10 spots each to hold it... instead of 100 individual variables. I just can't grasp how to do so correctly with WE triggers yet.

A mere example:
Array Name: iProdPoint[10]
Data:
A1 = 4 PP; A2 = 2 PP;
A3 = 0 PP; A4 = 1 PP;
A5 = 3 PP; A6 = 0 PP;
A7 = 2 PP; A8 = 1 PP;
A9 = 4 PP; A10= 1PP;

Can someone help me grasp the trigger needed to do this so that I can do the rest correctly. Thank you so much if you can help
04-02-2004, 07:33 PM#2
Quantos
I slightly understand it, I think.

So Custom script, an array that's up to 100 spaces long. Then everyone increment of 10 is a new row (21 = B1, 31 = C1.. ect) Gotcha.

Hrm... I'll touch up on this, but from my minor grasp, I might have to come back and ask again about how to implement this correctly. Thanks btw.
04-21-2004, 04:20 AM#3
AnarkiNet
hmm, im having a similar problem, i have the Ix function, but the array im trying to simulate is a 10x6 array, but its specificaly laid out like this:
(note, this is for the Magic: The Gathering map i am currently constructing)
6 "colors" (5 basic colors plus generic mana)
so i have the 6 colors, and i have an integer array, and i need to store the values of the amount of mana of each of those 6 colors that each of the 10 players has. is it just easier to use a 10x10 array and not use the last 4 spots for each thing?
ie, 7-10, 17-20, 27-30 would be unused, etc. or to set up the formula either ((x*6) + y) or ((y*10) + x) im not sure which of these is correct. help is appreciated.
04-21-2004, 12:14 PM#4
Quantos
How it was put to me was to forget the idea of a grid array, instead of thinking it as 1x1, 1x2, 1x3 for the array. Just think of the array as a 60 slot array.

So if you consider it as every 6 units of data is a player information

Player 1 Mana = Ix[0] - Ix[5]
Player 2 Mana = Ix[6] - Ix[11]
Player 3 Mana = Ix[12] - Ix[17]
ect...

That might be a hard way, but it's the only way I can consider it now... Though I'm rather a newb at making maps. I hope this idea helps you out.. or helps someone say something even more relevant :)
04-21-2004, 12:56 PM#5
AIAndy
The generic form of the formula is:
x * ymax + y
In your case ymax would be 6 then. So x * 6 + y will work.