The Daily Click ::. Forums ::. Klik Coding Help ::. Array help 2
 

Post Reply  Post Oekaki 
 

Posted By Message

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
2nd November, 2008 at 02:49:13 -

Ok I've kinda worked out how to use the Dynamic array. But I have a new problem now... Lol I'm not that experienced with arrays.. Say I have a 10 by 10 grid that I want to look like this:

1,5, ,7,5,3,5, , ,9,
,7, , ,6, , , , , ,
, , ,8, , , ,8, , ,
, , , , , , , , , ,
, , , , , , , , , ,
, , , , , , , , , ,
, , , , , , , , , ,
, , , , , , , , , ,
, , , , , , , , , ,

(The spaces are just blanks)

I can save that as a *.csv file but when I open the file in Notepad it looks like this: 1,5, ,7,5,3,5, , ,9, ,7, , ,6, , , , , , , , ,8, , , ,8, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,



All as one big line and it looks that way in Excel too.. Thinking of Excel, is there a way to open it so it looks like the first example? ie: it has separate rows, not just one big long line...

Any help would be great!

 
n/a ...

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
2nd November, 2008 at 03:03:03 -

Hmm.. what's the difference between a boring old array and a dynamic array?

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
2nd November, 2008 at 03:49:29 -

dynamic arrays' size can be defined at runtimel.

if you want to put it in a grid like format into a text file, i would suggest looping through the array and printing the value to a text file followed by ',' and insert a newline when its the end of an array row.

id have to fiddle around to get it to work but i think i can get you an example.

 
n/a

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
2nd November, 2008 at 04:01:29 -

Lol thanks, an example would be exactly what I need. I think I kinda get what your saying but it would be great if you could show me with an example



 
n/a ...

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
2nd November, 2008 at 04:44:03 -

Oh nevermind lol I figured it out I'm making a level editor and when you insert tiles to the level it saves a certain value to the array in the correct location. You can define the size of the level (ie: the size of the grid) in the previous frame and the X value becomes Global Value X, so all I had to do was make sure the array's X dimension boundary was always the same as Global Value X, so you can have 12 x 13 grid or whatever and the array sets its dimensions and places everything correctly

Time to have a break lol too much coding is bad for your... uhh.. .... umm..... ... ... ... -zones out-....





 
n/a ...

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
2nd November, 2008 at 05:06:14 -

well here it is anyway.

i think its a better method anyway as you can have multiple arrays, and name them, in one text file and also have text based commands. string parser is a pretty amazing tool.

http://legendkpr.startlogic.com/files/arraytotextfilegridformat.zip

Image Edited by the Author.

 
n/a

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
2nd November, 2008 at 05:24:30 -

Hey thanks for that, it does work pretty much the same as the way I'm using but I'll keep my way for now.

Heres the code i used to figure out which cell of the array to write "Global Value M" to...

ColofX( "Easy Grid object", X( "Selector" ))<plus>(Global Value X)*(RowofY( "Easy Grid object", Y( "Selector" )-1))


That just calculates the position in the Easy Grid where you just added a tile and then converts it to the corresponding position in the array. Global Value M's value is determined by what kind of tile you just placed, so in all that I can get an array with values that represent a level grid with different tiles.

 
n/a ...

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
2nd November, 2008 at 05:46:30 -

no problem. if your way works thats great, but if it ever needs more funcionality like storing and retrieving other information into the text file along with the array then using the string parser is the way to go.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click