Game Maker's Garage Forum

Game Creation => Code Exchange => Topic started by: GMG Kurt on June 21, 2011, 12:26:19 PM

Title: FILEIO grid nav [GM/SC?]
Post by: GMG Kurt on June 21, 2011, 12:26:19 PM
This can definitely be used for GameMaker, and if someone could convert it, than also for SilverCreator.

If you base grid nav on arrays that take up 60-100 lines of code like me, than this i'll save you.
Code: [Select]
    IF stage = 1 THEN
      REPEAT vertical_positioning
        FILEIO INPUT 1 stage1
        FILEIO READ 1 array$
      END REPEAT
      FILEIO CLOSE 1
    END IF
all you need to do is set up the file (ie. stage1) in the first card like so
Code: [Select]
FILEIO OUTPUT 1 stage1
FILEIO WRITE 1 11111000000000000000000000
FILEIO WRITE 1 11111000000000000000000000
FILEIO WRITE 1 01111000000000000000000000
FILEIO WRITE 1 01111100000000000000000000
FILEIO WRITE 1 01111110000000000000000000
FILEIO WRITE 1 00111110000000000000000000
FILEIO WRITE 1 00111111000000000000000000
FILEIO WRITE 1 00111111000000000000000000
FILEIO WRITE 1 01111110000000000000000000
FILEIO WRITE 1 11111110000000000000000000
FILEIO WRITE 1 11111110000000000000000000
FILEIO WRITE 1 01111110000000000000000000
FILEIO WRITE 1 01111111111111111111100000
FILEIO WRITE 1 01111111111111111111110000
FILEIO WRITE 1 01111111111111111111111000
FILEIO WRITE 1 00111111111111111111111000
FILEIO WRITE 1 00011111111111111111110000
FILEIO WRITE 1 00000011111111111111100000
FILEIO WRITE 1 00000000110000001110000000
FILEIO WRITE 1 00000000010000000100000000
FILEIO WRITE 1 00000000000000000000000000
FILEIO WRITE 1 00000000000000000000000000
FILEIO WRITE 1 00000000000000000000000000
FILEIO WRITE 1 00000000000000000000000000
FILEIO WRITE 1 00000000000000000000000000
FILEIO WRITE 1 00000000000000000000000000
FILEIO CLOSE 1
you can see the stage. neat huh!

physically writhing the array out (even on separate lines) doesn't work.
and you don't even have to make the file,
but if you want to (such as when cheating) open a new doc in Text Edit, and click Format>Make Plain Text then save it w/ text encoding: 'Western (Mac OS Roman)' The numbers and such still have to be put in through GM though.

^---I spent so much time on the explanation above, because you can use it to cheat at GM games that utilize the FILEIO command. Albeit this only works if you own GM, and know how the developer encoded his document. A hard task especially if they decide to hide them!---^


7-5 lines of code compared to 60-100 lines, not to shabby don't you think?
I developed this with my new (short) RPG 'Fathers'
and since it'll be open source you can see more examples in that.

P.S. If you found this useful or amazing. click my reputation counter.
Title: Re: FILEIO grid nav [GM/SC?]
Post by: Silverwind on June 22, 2011, 06:25:35 AM
What exactly does this do?
Title: Re: FILEIO grid nav [GM/SC?]
Post by: GMG Kurt on June 23, 2011, 12:18:28 PM
it's just like having an array hold your grid nave values, but it makes a text doc do that instead.
It shrinks the file
it takes less time to program
and as said above: less lines of code

and theres a fail safe: If anyone tampers with the documents. it resets them to their original values.
Title: Re: FILEIO grid nav [GM/SC?]
Post by: GMG Kurt on July 10, 2011, 08:51:02 AM
I developed a SC method, and accidentally put it in another post. I only realized just now, so here's the SC along with the GM method explained differently

This can definitely be used for GameMaker, and SilverCreator
I'll be making a tutorial on it also


If you base grid nav on arrays that take up 60-100 lines of code like me, than this i'll save you.

Code: [Select]
    IF stage = 1 THEN
      REPEAT vertical_positioning
        FILEIO INPUT 1 stage1
        FILEIO READ 1 array$
      END REPEAT
      FILEIO CLOSE 1
    END IF

first set up the file (ie. stage1) in the first card like so
Code: [Select]
FILEIO OUTPUT 1 stage1
FILEIO WRITE 1 11111000000000000000000000
FILEIO WRITE 1 11111000000000000000000000
FILEIO WRITE 1 01111000000000000000000000
FILEIO WRITE 1 01111100000000000000000000
FILEIO WRITE 1 01111110000000000000000000
FILEIO WRITE 1 00111110000000000000000000
FILEIO WRITE 1 00111111000000000000000000
FILEIO WRITE 1 00111111000000000000000000
FILEIO WRITE 1 01111110000000000000000000
FILEIO WRITE 1 11111110000000000000000000
FILEIO WRITE 1 11111110000000000000000000
FILEIO WRITE 1 01111110000000000000000000
FILEIO WRITE 1 01111111111111111111100000
FILEIO WRITE 1 01111111111111111111110000
FILEIO WRITE 1 01111111111111111111111000
FILEIO WRITE 1 00111111111111111111111000
FILEIO WRITE 1 00011111111111111111110000
FILEIO WRITE 1 00000011111111111111100000
FILEIO WRITE 1 00000000110000001110000000
FILEIO WRITE 1 00000000010000000100000000
FILEIO WRITE 1 00000000000000000000000000
FILEIO WRITE 1 00000000000000000000000000
FILEIO WRITE 1 00000000000000000000000000
FILEIO WRITE 1 00000000000000000000000000
FILEIO WRITE 1 00000000000000000000000000
FILEIO WRITE 1 00000000000000000000000000
FILEIO CLOSE 1
you can see the stage. neat huh!

physically writhing the array out (even on separate lines) doesn't work.
and you don't even have to make the file,
but if you want to (such as when cheating) open a new doc in Text Edit, and click Format>Make Plain Text then save it w/ text encoding: 'Western (Mac OS Roman)' The numbers and such still have to be put in through GM though.

^---I spent so much time on the explanation above, because you can use it to cheat at GM games that utilize the FILEIO command. Albeit this only works if you own GM, and know how the developer encoded his document. A hard task especially if they decide to hide them!---^


7-5 lines of code compared to 60-100 lines, not to shabby don't you think?
I developed this with my new (short) RPG 'Fathers'
and since it'll be open source you can see more examples in that.

SC is the same basis. (any differences you may notice is that there are also built in SPRITE commands)
set up in the 'open card'
Code: [Select]
CREATESPRITE 1, "redsnake.png"
MOVESPRITE 1, 0, 0
OPENOUTFILE 1, "stage1"
FILEWRITELINE 1, "110110111"
FILEWRITELINE 1, "101011101"
FILEWRITELINE 1, "111111111"
FILEWRITELINE 1, "111100110"
FILEWRITELINE 1, "101100111"
FILEWRITELINE 1, "111111101"
FILEWRITELINE 1, "011111111"
CLOSEOUTFILE 1

then in keydown is the bulk
Code: [Select]
   LET yco = newy / 48
   LET yco = yco + 1
   LET xco = newx / 33
   LET xco = xco + 1
   OPENINFILE 1, "stage1"
  
   FOR repeat = 1 to yco
      LET quadrant$=FILEREADLINE$(1)
   NEXT
  
   LET space$ = MID$(quadrant$, xco, 1)
directions are almost identical to the Gm version

To develop the SC port I had too make my own application. My first SC application
http://www.mediafire.com/?qfd287g17gfyk4a
Title: Re: FILEIO grid nav [GM/SC?]
Post by: GMG Kurt on December 08, 2011, 06:06:29 PM
So when Conors wanted a 2-D array for SC it just hit me my SC grid nav. did just that.

It used to work, but now it doesn't.  [smiley=lolk.gif] since I forgot the very little SC that I knew, and can't find out where the 1.5 documents are :-/. I can't fi it myself
The error should be somewhere in the way I took data from the .txt document, or the MID function. I hate to bring up this old thread but it's bugging me that it inexplicably broke.
Title: Re: FILEIO grid nav [GM/SC?]
Post by: Connors on December 10, 2011, 07:44:27 PM
Oh yeah how does SC's file reading work? Will it take just any .txt file?
Title: Re: FILEIO grid nav [GM/SC?]
Post by: Gan on December 10, 2011, 08:16:43 PM
It'll take any file as long as it contains text.
Title: Re: FILEIO grid nav [GM/SC?]
Post by: Connors on December 10, 2011, 08:24:02 PM
I may just have the levels stored in a method for now actually, since I still have to type in all the tiles. However I could also add a function that loads a map from a file since it would have the same end result. If I do add custom support the game's levels will remain in the game so you can't cheat and it will be able to load custom levels from files.
Title: Re: FILEIO grid nav [GM/SC?]
Post by: GMG Kurt on December 11, 2011, 09:07:08 PM
Yes is was your level editor you were making a while ago, that gave me the initial idea, that and how cluttered QOM's grid nav. was.
Also it was how nobody used FILEIO commands, and I was looking for a good excuse to use them.

I'm going to use something similar for my iPhone game (which I've finnaly started  [smiley=WaveyWave2.gif]) So players can transfer maps even between computers.  [smiley=happy.gif]
Title: Re: FILEIO grid nav [GM/SC?]
Post by: Connors on December 12, 2011, 10:04:22 AM
Sounds pretty awesome.