Browse Source

Fixes #101

tags/v0.1.2^2
Big Bad Waffle 7 years ago
parent
commit
0823ee5a75
3 changed files with 84 additions and 3 deletions
  1. +5
    -0
      src/client/ui/templates/talk/talk.js
  2. +32
    -2
      src/server/components/dialogue.js
  3. +47
    -1
      src/server/config/maps/tutorial/dialogues.js

+ 5
- 0
src/client/ui/templates/talk/talk.js View File

@@ -18,6 +18,11 @@ define([

postRender: function() {
this.onEvent('onGetTalk', this.onGetTalk.bind(this));
this.onEvent('onRezone', this.onRezone.bind(this));
},

onRezone: function() {
this.hide();
},

onGetTalk: function(dialogue) {


+ 32
- 2
src/server/components/dialogue.js View File

@@ -95,8 +95,18 @@ define([

if (stateConfig.cpn) {
var cpn = sourceObj[stateConfig.cpn];
cpn[stateConfig.method].apply(cpn, stateConfig.args);
return;
var newArgs = extend(true, [], stateConfig.args);
newArgs.push(this.obj);
var result = cpn[stateConfig.method].apply(cpn, newArgs);

if (stateConfig.goto) {
if (result)
return this.getState(sourceObj, stateConfig.goto.success);
else
return this.getState(sourceObj, stateConfig.goto.failure);
}
else
return null;
}

var result = {
@@ -158,6 +168,26 @@ define([
return {
type: 'dialogue'
};
},

//These don't belong here, but I can't figure out where to put them right now
//They are actions that can be performed while chatting with someone
teleport: function(msg) {
this.obj.syncer.set(true, 'dialogue', 'state', null);

var portal = extend(true, {}, require('./components/portal'), msg);
portal.collisionEnter(this.obj);
},

getItem: function(msg, source) {
var inventory = this.obj.inventory;
var exists = inventory.items.find(i => (i.name == msg.item.name));
if (!exists) {
inventory.getItem(msg.item);
return true;
}
else
return false;
}
};
});

+ 47
- 1
src/server/config/maps/tutorial/dialogues.js View File

@@ -3,7 +3,7 @@ module.exports = {
'1': {
msg: [{
msg: `What? Oh...what are you doing here?`,
options: [1.1, 1.2, 1.3, 1.4, 1.5]
options: [1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7]
}],
options: {
'1.1': {
@@ -25,6 +25,14 @@ module.exports = {
'1.5': {
msg: `I changed my mind, I want to buy something back.`,
goto: 'tradeBuyback'
},
'1.6': {
msg: `Send me to the big city.`,
goto: 'portalCity'
},
'1.7': {
msg: `Gimme`,
goto: 'getItem'
}
}
},
@@ -85,6 +93,18 @@ module.exports = {
}
}
},
'4': {
msg: `There you go!`,
options: {
}
},
'5': {
msg: `You already have that!`,
options: {
}
},
tradeBuy: {
cpn: 'trade',
method: 'startBuy',
@@ -105,6 +125,32 @@ module.exports = {
args: [{
targetName: 'hermit'
}]
},
portalCity: {
cpn: 'dialogue',
method: 'teleport',
args: [{
toZone: 'city',
toPos: {
x: 136,
y: 216
}
}]
},
getItem: {
cpn: 'dialogue',
method: 'getItem',
args: [{
item: {
name: 'fancy feather',
quest: true,
sprite: [0, 0]
}
}],
goto: {
success: 4,
failure: 5
}
}
}
};

Loading…
Cancel
Save