New User / Game Idea Help

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
R0ck0 R4m4
Prole
Posts: 1
Joined: Fri Dec 29, 2023 9:48 pm

New User / Game Idea Help

Post by R0ck0 R4m4 »

Hello! I'm new to Lua and Love2D, though I did work a lot with Unity on a small 2D game project. I had an idea to make a parser-based adventure game similar to Hugo's House of Horrors as a way to learn, but I'm not sure if that is even in the scope of my ability at the moment. Does anyone have any thoughts on if this would be possible and the best place to start?

I could see myself breaking this into three parts:

1. Create a UI that includes the game area where the action happens and one for the text input field
2. Take input and check against a specific set of data to see if it is valid or invalid
3. Making the character do something based on input (walk, interact, etc...)

From what I've seen, with a bit of research, I would need to use an existing GUI library to accomplish this.

My initial thoughts would be to ask for input, store that using io.read(), and test it against a table, but I am not sure if there is a better way.

How would I use that input to interact with an object after checking to see if the input matches a valid command for the character/object in the scene?

Thanks a bunch!
User avatar
kingnoob
Prole
Posts: 29
Joined: Thu Dec 21, 2023 6:52 am

Re: New User / Game Idea Help

Post by kingnoob »

The style of the game is ancient. And the ui is just the keyboard. Today everyone has a mouse. So just use the mouse ui built into love2d. Left button to move to a door. Right mouse button to interact. A popup if there are choices or a popup that says the door is locked. So for every scene there is an image to load and a list: x1, y1, x2, y2, actions: for each actionable item in the scene. If you have all the scenes drawn and know what you want in them then the coding is quite simple.
RNavega
Party member
Posts: 251
Joined: Sun Aug 16, 2020 1:28 pm

Re: New User / Game Idea Help

Post by RNavega »

One of the reasons to use a library is to save time, yeah? If your game won't have a lot of screens with different UI layouts, I don't think you need a library for it. The time spent learning that new library could be better used by you setting up your UI using Löve's built-in drawing functions.

I did a simple example of a virtual machine for text-based games, but it's useful for any kind of game as it's just a way of structuring things in a sequence, like a theater script, so you can have cutscenes etc. Maybe it can give you some ideas: viewtopic.php?p=257854#p257854

If I wanted to interpret some simple English grammar then first I'd brush up on how English sentences are formed, then use the regex-like :gmatch() method of strings to break the input sentence into words / tokens, then try to find the verb and see if it's transitive / intransitive, find the subject and so on.
User avatar
Bobble68
Party member
Posts: 160
Joined: Wed Nov 30, 2022 9:16 pm
Contact:

Re: New User / Game Idea Help

Post by Bobble68 »

This is just my opinion, but I personally wouldn't recommend doing anything with a text input as your first project with Love2D - I'm sure you can probably use libraries to make them, but love itself doesn't offer much in terms of text input. I think this kind of project would also need some well thought out data structures (i.e. each room, all the objects within it, all the things the objects can be used for, plus the player which is not tied to a specific room), so I would recommend doing something simpler until you're a little more familiar with how lua works.

That being said, if you really want to go for it, do by all means! (I would be a huge hypocrite if I didn't mention my current project also has a way bigger scope than is advisable). Just some things to think about before you start.
Dragon
User avatar
dusoft
Party member
Posts: 510
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: New User / Game Idea Help

Post by dusoft »

You can check an input library good for you here:
https://github.com/xiejiangzhi/input

But basically you can just use this function and add entered characters to a stack:
https://love2d.org/wiki/love.textinput

You can also look for some basic text parsers to help you with tokenization, but really old text games just used this very simple model:
VERB OBJECT
e.g. TAKE BAG, EXAMINE DOOR etc.

Matching this to a table of verbs and objects (for that room or in inventory). This does not even require any complex parsing, just string splitting into two parts. Also another thing to support is VERB/OBJECT word abbreviation, so EXAMINE becomes EX or COMPUTER can be entered as COMP etc.
User avatar
pgimeno
Party member
Posts: 3551
Joined: Sun Oct 18, 2015 2:58 pm

Re: New User / Game Idea Help

Post by pgimeno »

I don't know that particular game, but I've played quite a few text adventure games, and even used a text adventure writing system called The Quill for ZX Spectrum and another called DAAD for PC.

Most text adventures in that time were based on one- or two-word sentences: INVENTORY, TAKE GEM, OPEN CHEST, etc. with a number of synonyms (e.g. TAKE = PICK UP) and some words ignored (like THE). A few more sophisticated engines (like The Hobbit for Spectrum or the Sierra adventures for a number of platforms) admitted more complex sentences like GIVE <object> TO <character> or TAKE DEEP BREATH. These probably used special parsing code just to detect these constructions.

And the gist of it is that it worked with a very simple interpreted language where there were "global" sentences (sentences that would do the same wherever you were, like INVENTORY or QUIT) and "per-room" sentences, which acted differently depending on where you were. Each word had its associated program.

There's a text adventure game for ZX Spectrum, Pharaoh's Tomb, written entirely in BASIC. To my surprise, it also used this "virtual machine" approach. Not sure if you'll want to study it.

Anyway, this approach in Lua is certainly well within reach, and I really doubt that HHH used a more sophisticated parser than the mentioned ones.

You may also look up the Z-Machine, a text adventure writing system, and its approach to parsing.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 55 guests