I tried using the list object, because it's easier to play with than a string, but this method turned out to be completely stupid (a bit slow in TGF, doesn't work at all when compiled to flash). Should I use a string instead? Am I missing something fundamental?
I just wanna make my levels elsewhere, then drag them into the level editor and load them up as needed.
I wanted to be quite flexible with what I could store, you see, that's why I used the list object... Different values and strings for different object instances etc
Beats me how you'd do this without making it a royal pain for yourself - unless it's just one paragraph per level or something?
string parser is your friend.
An extension? In TGF2:NE?
I tried it with a string object, before realising I could adapt my list object version to work in Flash, but I'm very rusty with the built-in string parsing options and wanted to store data of whatever length for each tile, etc.
In the C world I would delimit each line as an object, and look for the '\n' (end of line - line feed and carriage return).
Perhaps this could be done in TGF:NE? Not sure if its possible really, I tried making an app to recieve binary data and the serial object was cutting out the null terminators ('/0' or number 0) , but surely a newline would be detectable...
I've loaded levels with a string object before but it was not all that fun. I used String Parser (sorry, I know - no extensions in TGF) to grab each character and retrieve its ASCII value (a number), which then changed the animation direction of the "tile object" before it was pasted into the backdrop. This gave me a total of 32 tiles but I'm sure you could get more by using another expression to change the current animation too.
Without the extension, I'd use 2-digit numbers stored in a string object (each level using a new paragraph)
At the most basic level, this would look like: (where number 01 is a background tile)
Yeah, this is sort of what my current system looks like - the list object is basically a multiline string and you can select a line by value, which is why it's more appealing than hacking together something similar with the string object and built-in parsing functions. It doesn't like having its values looped through when run through TGF2 itself, or a standard klik exe I imagine (it takes about a full second to load a level up) but funnily enough it's perfectly nippy when compiled to Flash. Unfortunately it won't respond to 'get focus', 'set line' or similar actions in Flash so I've got to specify a line in each expression.
Without the extension, I'd use 2-digit numbers stored in a string object
Somewhere between posts #2 and #3 (so around 3am) I ported most of my stuff over to this method, but it had me stumped on storing additional values and strings for certain tiles (e.g., signposts with unique text).
In your case I would do something like this (presuming you have some sort of tile based system);
- choose a special delimeter character dedicated to start a new tile code, for example: ¤
- the character following ¤ is your tile type, i.e. "1" means block, "e" means enemy, "S" means sign post.
- The characters following the tile type is parameters for the tile, which could be anything.
Your string would be something like this (for 5 blocks):
¤1¤1¤e¤SThis is a signpost text¤e
and would result in: block, block, enemy, a sign post with the text "This is a signpost", enemy
You could use different delimeters to have multiple parameters for objects etc.
This would of course require you to have some sort of editor to create these strings, as the strings themselves aren't very easy to read.
Hey Jenswa, You can use arrays in TGF2:NE, as you can ini for storing some local data, but the problem is you can't handle external files (of course!) and there's no real way to populate this stuff apart from in the event editor, which is pretty daft. It'd be cool if the array object came with a GUI when you placed it in the level editor.
So the solution is to copy and paste your levels into a string object or some such. I got it working with the list object shortly after making this topic but I'm glad everyone weighed in. Mårten's method is, well, probably better than mine, but I don't know my way around the built-in string parsing facilities well enough!