By Joel Dies
This is not 100% documented but is on its way to being 100% documented.
Help support these efforts by becoming a Patreon
Include the script into your html page.
Required Modules:
<script src="/path/to/plugin/lodash.min.js"></script>
<script src="/path/to/plugin/phreaknation.manager.dialog.min.js"></script>
In your create of your phaser project.
game.plugins.add(PhreakNation.Plugins.DialogManager);
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;
})();
Return the plugin version.
manDiag.version();
Return a description of this plugin.
manDiag.description();
Internal Usage. Formats a text based on variables in the string.
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.'
Grabs an item from the config.
var Conv = manDiag.get(1, 'dialog');
Loads a config file.
manDiag.load(config);
TBD
// TBD
Gets the active actor.
var actor = Conv.actor();
Gets the list of answers when there is an active question dialog.
var answers = Conv.answers();
Chooses an option for the active question dialog
Conv.choose(0);
Gets the current emotion of the speaking character of the active dialog.
var emotion = Conv.emotion();
Loads the next dialog, if any.
Conv.next();
Initializes the conversation. Pass in an id to target a specific point of the dialog.
var Conv = manDiag.get('dialog', 1);
Conv.play();
Internal Usage. Processes the current dialog.
Conv.process(id);
Returns the formated text of the current dialog.
Conv.text();
Returns the name of the actor.
var actor = Conv.actor();
actor.name(); // Returns the actors name;