Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phreaknation/plugin.dialogmanager
https://github.com/phreaknation/plugin.dialogmanager
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/phreaknation/plugin.dialogmanager
- Owner: phreaknation
- License: other
- Created: 2017-02-14T02:02:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-02-19T08:30:11.000Z (over 7 years ago)
- Last Synced: 2024-01-12T01:57:59.697Z (6 months ago)
- Language: JavaScript
- Size: 20.5 KB
- Stars: 15
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-phaser - Dialog Manager - (Uncategorized / Uncategorized)
- gamedev-awesome - dialogs-manager
README
# Dialog Manager
By Joel Dies[Demo](http://codepen.io/phreaknation/full/NdZWdw/)
[Video](https://youtu.be/0RNYi8aXYG4)
**This is not 100% documented but is on its way to being 100% documented.**
Help support these efforts by becoming a [Patreon](https://www.patreon.com/diesoft)
## Including in a project
Include the script into your html page.Required Modules:
+ [Lodash](lodash.com) [CDNJS](https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js)
```
```
In your create of your phaser project.
```
game.plugins.add(PhreakNation.Plugins.DialogManager);
```#### Example:
```
var config = require('./path/to/config.js');
var manDiag;
(function() {
'use strict';var state = function state(game) {};
state.prototype = {
...
create: function () {
...
manDiag = this.game.plugins.add(PhreakNation.Plugins.DialogManager);
manDiag.load(config);
var Conv = manDiag.get('dialog', 1);
Conv.play();
console.log('[%s]: %s', Conv.actor().name(), Conv.text());
var list = Conv.answers();
var choice = _.random(0, 2);
console.log('Options: ', list);
console.log('Chose: `%s`', list[choice]);
Conv.choose(choice);
console.log('[%s]: %s', Conv.actor().name(), Conv.text());Conv.next();
console.log('[%s]: %s', Conv.actor().name(), Conv.text());Conv.next();
console.log('[%s]: %s', Conv.actor().name(), Conv.text());list = Conv.answers();
choice = _.random(0, 2);
console.log('Options: ', list);
console.log('Chose: `%s`', list[choice]);
Conv.choose(_.random(0, 1));
console.log('[%s]: %s', Conv.actor().name(), Conv.text());Conv.next();
console.log('[%s]: %s', Conv.actor().name(), Conv.text());
}
...
},
...
};window.MyGame.states.MyState = state;
})();
```### Manager Methods
### version()
Return the plugin version.#### Example:
```
manDiag.version();
```### description()
Return a description of this plugin.#### Example:
```
manDiag.description();
```### format(text)
Internal Usage. Formats a text based on variables in the string.#### Example:
```
var str = manDiag.format('Hey there {actor:0x002}, I am doing good.');
// if there was a reference to `actor:0x002` set to `Actor` in the config. See provided config for details
// 'Hey there Actor, I am doing good.'
```### get(id, type)
Grabs an item from the config.#### Example:
```
var Conv = manDiag.get(1, 'dialog');
```### load(config)
Loads a config file.#### Example:
```
manDiag.load(config);
```### new()
TBD#### Example:
```
// TBD
```### Dialog Methods
### actor()
Gets the active actor.#### Example:
```
var actor = Conv.actor();
```### answers()
Gets the list of answers when there is an active question dialog.#### Example:
```
var answers = Conv.answers();
```### choose(id)
Chooses an option for the active question dialog#### Example:
```
Conv.choose(0);
```### emotion()
Gets the current emotion of the speaking character of the active dialog.#### Example:
```
var emotion = Conv.emotion();
```### next()
Loads the next dialog, if any.#### Example:
```
Conv.next();
```### play(id)
Initializes the conversation. Pass in an id to target a specific point of the dialog.#### Example:
```
var Conv = manDiag.get('dialog', 1);
Conv.play();
```### process(id, type)
Internal Usage. Processes the current dialog.#### Example:
```
Conv.process(id);
```### text()
Returns the formated text of the current dialog.#### Example:
```
Conv.text();
```### Actor Methods
### name()
Returns the name of the actor.#### Example:
```
var actor = Conv.actor();
actor.name(); // Returns the actors name;
```