Command Line Interpreterby Alex Peterson |
|
Takes input from a player and breaks it down into commands. Useful for text based games. [More] |
To download this demo for your Linux/Mac installation, enter this on your command line:
DreamDownload byond://AlexPeterson.Interpreter##version=1 Emulator users, in the BYOND pager go to File | Open Location and enter this URL:byond://AlexPeterson.Interpreter##version=1 |
How it works
This shows you one way you can take apart a user's sentence into it's component parts and turn that into a series of commands that can be executed. Part 1: Takes the user's input as text Part 2: Removes anything unnecessary Part 3: Makes a list called parts which contains Commands Objects and Numbers. Part 4: Makes a list called format which contains corresponding values of "c","o" or "n" to each command, object and number. Finally it executes each command right to left, giving it whatever information it finds to the right of the command. That command is then replaced in the parts list by whatever value it returned. Example: "Pick up the candles from the table" becomes: parts = ("/Command/pick_up", "candles"," /Command/from", "table" format= ("c", "o", "c", "o") Executes "/Command/from" becoming: parts = (/Command/pick_up", "candles", "table") format = ("c", "o", "o") Executes "/Command/pick_up" This command then takes the first object off of the second object. In this case it will take the candles off of the table. |
Please support BYOND through Membership or a donation!
|
Related Demos
|
Copyright © 2024 BYOND Software.
All rights reserved.
en.wikipedia.org/wiki/Lexical_analysis