ID:267001
 
Ok, I need to define a list. Simple enough. Im just wonder how I would define a list that is set something like this.
grid[2][2]
grid[1][1] = "1,1"
grid[1][2] = "1,2"
grid[2][1] = "2,1"
grid[2][2] = "2,2"

Im hoping there is a much easier way then entering each specific value one by one.
-DogMan
PS:
Also, how does the Add() proc work when I want to add to the 'x' and not the 'y', or vise versa.
I'm guessing something like this is what you want to for creating the list:
for(var/index1 = 1 to 2)
for(var/index2 = 1 to 2)
grid[index1][index2] = "[index1],[index2]"

However, I'm not quite sure what you are asking about the Add() proc.
In response to ACWraith
That would work, but not in my case. Thanks anyway though.
I probably should have went through this in more detail, I just find it hard to put my thoughts into words sometimes.
I want to make a 20 by 20 grid (Map[20][20]).
Then I want too fill in all the slots in the grid. However the catch is there is no pattern.
For example.
Map[1][1] = /turf/grass
Map[1][2] = /turf/grass
Map[1][3] = /turf/dirt
...
Map[2][4] = /turf/rocks
Map[2][5] = /turf/dirt
and so on until all the slots in the list are full.
Ive figured out how to make something in my game that would allow me to make a map in Dream Maker, then copy a 20x20 section of it into Map[20][20], however surely there is a way I can hard code it in there.
I made up something that resembles what you suggested, but with a bunch of if()'s that check the index1 and index2 vars too see what type should go into the slot.
This would do the job, so Im currently using it, but now I really want to know if its possible to set it up when creating the list.


What I was asking about Add wasnt too clear either. I was just wondering how the list procs work in reguards to a grid like the one I just made.
Like if I had Map[2][2], and wrote src.Map.Add("Test"), where would it go? I can test it out and see, but Im wondering how it can be manipulated. So if adding it makes Map become Map[2][3], how would I make it so that it adds to Map[var1][] instead of Map[][var2] (Or vise versa).
Anyway, thanks again for trying to help.
-DogMan
In response to Dog Man
What exactly are you trying to do with this?
In response to Dog Man
Dog Man wrote:
[snip]
For example.
Map[1][1] = /turf/grass
Map[1][2] = /turf/grass
Map[1][3] = /turf/dirt
...
Map[2][4] = /turf/rocks
Map[2][5] = /turf/dirt
[snip]
I really want to know if its possible to set it up when creating the list.

The closest thing I can think of is:

list/Map = list( list( /turf/grass, /turf/grass, /turf/dirt), list( "blah1", "blah2", "blah3", /turf/rocks, /turf/dirt))

[snip]
Like if I had Map[2][2], and wrote src.Map.Add("Test"), where would it go?
[snip]

Adding to a lists of lists results in the thing added to go to the end of the outer list, not a list inside that list. Map would have a length of 3 after adding "Test". The inner lists would not be changed. If you want to safely access an inner list, set a var that references it. Ex: var/list/inner = Map[1]
In response to ACWraith
ACWraith wrote:
The closest thing I can think of is:

list/Map = list( list( /turf/grass, /turf/grass, /turf/dirt), list( "blah1", "blah2", "blah3", /turf/rocks, /turf/dirt))

Thanks. Im pretty sure thats exactly what I was after.
-DogMan
In response to Garthor
Im trying to make it store a map, and then build it using Map[20][20].
Ive got most of the system done. Basically it will make a new Map[tx][ty] (locate((T.x - 20) + tx,(T.x - 20) + tx, T.z)
With T being the corner turf of the map, and tx starting at 1 and getting increasing each time it goes through it (ty increasing each time tx gets to 20).
That part all works fine. Currently I have a working version set up, the only problem is the way the turf type is selected.
I currently use a lot of if()'s to set var/nexttype, then it creates a new nexttype.
-DogMan
In response to Dog Man
It would be a lot easier to simply make a map file instead. You just need to create a text file, and then for typseof(/turf), add to the file "a" = (TURF,/area), area being the area it's in. Then do b, c, d, e, f, g, whatever, anything at all. Store these in a list. Once you have those, have, (1,1,1) = {" and then start adding rows of the turfs from top to bottom. Open up a .dmp file in notepad to see this. And end the file in "}. This will also make it easy to share map files, and veiw them.
In response to Garthor
Thanks. Ive got one question though. How do I go about adding that (The map) into my game at runtime?
-DogMan
In response to Dog Man
By editing the .dme file to #INCLUDE it.
In response to Garthor
Ok, I didnt know that was possible at run time.
-DogMan
In response to Dog Man
Oh, it isn't. Adding to the map at runtime is somewhat more difficult....

Try parsing through the text, searching for = signs. When one is found, go back a character, then read the whole line, up to (and including) the ). Then, find the turf in there, so you have a list of turfs. Then you can parse the map part of the file to place the turfs down.