Interesting idea. There are many ways of doing this, of course. Here is one simplified way (for example, it assumes that objects names and action names do not collide). First tokenize the user string to find objects (by name), then find actions (functions) for this objects. I have just pushed an example here (and in the attachment).Echo wrote:I want to make a verb-noun parser for my visual novel game engine. A verb-noun parser is used to recognize input made as strings by the player. For example you could type in "open door", then the computer will use the verb-noun parser to recognize the word open as a verb, you are telling the computer that you want to open something but what? then it looks for a noun to attach this verb to, door is a noun, it is an object, then using the computers programmed logic it will link the two, open + door, it then recognizes this as a valid action and performs the task.
I know how this works in my mind but I have no idea how to code this from scratch in Lua, I have a hint that it involves something to do with converting variables into strings and vice versa, could be wrong though.
[SOLVED] Verb-Noun Parser
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Verb-Noun Parser
- Attachments
-
- VerbNounParser.love
- (4.29 KiB) Downloaded 100 times
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
Re: Verb-Noun Parser
Wow thanks, this example is great but looking through the code I see some meta table stuff and objects so I would need to learn a bit about meta methods and OOP before I can fully implement this into my own code but thanks alot!
Re: Verb-Noun Parser
The most important is the concept to tokenize the input, and - for each lowercased word - find an "object" and then its "methods". All the other code is just to show you how it could work (and to actually make it playable). You probably do not need all that.Ekamu wrote:Wow thanks, this example is great but looking through the code I see some meta table stuff and objects so I would need to learn a bit about meta methods and OOP before I can fully implement this into my own code but thanks alot!
So, you are welcome, alot, and have fun!
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
Re: [SOLVED] Verb-Noun Parser
haha thanks a lot!
Who is online
Users browsing this forum: No registered users and 0 guests