Generating Game Data from .txt files

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
yeau
Prole
Posts: 4
Joined: Thu May 31, 2018 11:41 pm

Generating Game Data from .txt files

Post 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
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Generating Game Data from .txt files

Post 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.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Generating Game Data from .txt files

Post 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?"
User avatar
yeau
Prole
Posts: 4
Joined: Thu May 31, 2018 11:41 pm

Re: Generating Game Data from .txt files

Post by yeau »

Both 2dengine and TIled look pretty cool, I'll check these out, thanks :)
Post Reply

Who is online

Users browsing this forum: Bing [Bot], zingo and 1 guest