Text Adventure!
JavaScript code to save you the time of making text adventure commands.
Add your commands with a name and a javascript function to execute.
It'll function like Google's text adventure, once you have set up your commands.
You can also add commands on the fly, remove commands on the fly, and rename commands on the fly
(as well as access the actual JavaScript function that'll be executed.)
Click here to download textadventure.
Example code here
How to use:
Add commands with text_adventure.addCommand()
.
There are two parameters: cmdname
which is the name of your command and callback
which is the callback to be used when the user types in your command's name.
Remove commands with text_adventure.deleteCommand()
.
There is one parameter: cmdname
which is the name of the command that you want to remove.
Get a command's callback with text_adventure.getCommand()
.
There is one parameter: cmdname
which is the name of the command that you want to find the callback function of.
Rename a command with text_adventure.renameCommand()
.
There are two parameters: cmdnameold
which is the command that you're renaming and cmdnamenew
which is the new name for the command.