Read GML from a txt file

by Guova


Posted on December 19, 2012 at 12:07 AM



Read GML from a txt file

This source helps any Game Maker games read codes from a txt file and perform the code.

NOTE: DO NOT put // in any script txt file, this will cause malfunction and glitchy effect. FIXED!



Juju commented December 19, 2012 at 12:24 AM
If double backslashes cause problems, why don't you make checking for that caret part of the parser?
Guova commented December 19, 2012 at 8:16 AM
The problem is that the string itself read from the txt file ends up as one line. Double backslashes causes whatever beyond it as comment. I recommend use /*le comments*/ for commenting in a txt code file.
Cpsgames commented December 19, 2012 at 8:31 AM
As Juju said, why don't you make the parser do that?

CyEdit: Care to elaborate on your 1/10 rating? :P
Guova commented December 19, 2012 at 8:55 AM
Sounds like a tough one, but I'll give it a try.
sirxemic commented December 19, 2012 at 10:08 AM
The problem is that the string itself read from the txt file ends up as one line. Double backslashes causes whatever beyond it as comment. I recommend use /*le comments*/ for commenting in a txt code file.
Quote
You are putting the code on one line. Why don't you insert newlines?
Juju commented December 19, 2012 at 1:16 PM
Hopefully we're not coming across as hostile. Consider this an opportunity to improve your coding skills.

Also, having actually gone in and checked your code, I can tell you there's already a function that does exactly what you want already: execute_file() The only reason I thought you were doing this was to have lots of code snippets in the same file, each separated by a header.
Guova commented December 19, 2012 at 5:19 PM
Just fixed the double backslashes problem by adding new lines. And yes, I'm planning to add snippet later on to the script so there won't be something like overlapping draw/step/whatever event.
Alert Games commented December 21, 2012 at 4:51 PM
Although this may be good to know how to read code from a file, it should never really be used.

Using execute_string() inside of a game is not recommended, so putting a code file outside the game is even worse lol.

As for the coding used in the gmk, it is a good coding format. I think a parser to cut out bad code would be cool, but would take some work.
Mega commented December 22, 2012 at 3:59 PM
Not to burst the proverbial bubble, but execute_file().
Aistarin commented December 22, 2012 at 9:13 PM
Oh ok nevermind Cpsgames...
death commented January 08, 2013 at 1:58 AM
this is pretty easy to do, im not sure if this "example" is necessary.
JuurianChi commented January 08, 2013 at 1:59 AM
this is pretty easy to do, im not sure if this is necessary.
Quote
Neither are any of the 500 3d,platforming, clicktehmouse examples that already exist.
Don't be picky.
death commented January 08, 2013 at 2:14 AM
well... actually, some 3D examples are really helpful. For example, i learned some advanced things with GM tutorials teaching heightmaps and noise generation and how to apply it to texturing.