Page 1 of 1

Generating Game Data from .txt files

Posted: Fri Jun 01, 2018 12:25 am
by yeau
Hi all, :3

I'm new to Lua and LÖVE2d, and I want to make a game over this summer! Specifically, I want to make a strategy rpg, and was wondering if y'all have any ideas about how I could go about being able to generate cursor/play area through a text file.

ie/ if I were to have the below "x"s it would generate a 3x3 field (specifically it would be centred)

xxx
xxx
xxx

Possibly even having more complex files like:

xxx xx
xxx xxx
xxxxxxx

(where there can be tiles that don't contain information [whitespace] and other kinds of characters that generate tiles with different properties and etc.)


If you're having trouble picturing what I'm saying I've attached a link below (even though it's not great [it's the best I could find :death: ]) I followed a tutorial (Gridlocked LÖVE2d Tutorial) and I have that working, but I'm having trouble coming up with a way I could get what I wanted. I like how that Gridlocked Tutorial works though, essentially what it covers as being the player, I'd like to rework into being a cursor.

Any and all suggestions, tutorials or whatever are welcome :D


Aforementioned Fire Emblem Gif

Re: Generating Game Data from .txt files

Posted: Fri Jun 01, 2018 11:11 am
by veethree
There are ways to do what you describe. But you'd be better off just using a tile map editor like tiled. Tiled can export to .lua files so it's not hard to load them into your game. Plus there's a library called "sti" that can handle it for you.

Re: Generating Game Data from .txt files

Posted: Fri Jun 01, 2018 1:20 pm
by ivan
Sure, I use text files too.
It's very easy to parse text using pattern matching.
Alternatively you can use string.char/string.byte as described in my tutorial:
https://2dengine.com/?p=isometric
Note that it can get out of hand if you have more than 50-60 different tiles,
as you'll be wondering "hmm, what does tile '}' represent again?"

Re: Generating Game Data from .txt files

Posted: Fri Jun 01, 2018 5:03 pm
by yeau
Both 2dengine and TIled look pretty cool, I'll check these out, thanks :)