Hobgoblin Data Parser
Gives a visual representation of the different hobgoblin data setup.
by Sam Fereday
HTML
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<div id="container">
<p class="lead">Display Conversations</p>
<div id="container-conversation"></div>
<p class="lead">Display Entities</p>
<div id="container-entities"></div>
</div>
CSS
/* Optional theme */
@import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin: 10px;
}
p {
margin-bottom: 0;
}
.speech {
padding: 1em;
}
span {
display: inline-block;
padding: 1em;
margin-top: 1em;
background: #333;
color: #fff;
border-radius: 6px;
}
JavaScript
// Our data so far
var conversations = [{
"id": "cnv1",
"collection": [{
"belongsTo": "triggerNpc",
"text": "Text string 1"
}, {
"belongsTo": "player",
"text": "Text string 2 (player)"
}, {
"belongsTo": "triggerNpc",
"text": "Text string 3"
}]
}, {
"id": "cnv1a",
"collection": [{
"belongsTo": "triggerNpc",
"text": "They say war is coming, I fear for my daughters safety..."
}]
}, {
"id": "cnv2a",
"collection": [{
"belongsTo": "triggerNpc",
"text": "Can you open that door for me?",
"options": {
"mode": "select",
"text": "Help the guy out?",
"yes": {
"text": "Yes",
"cnvId": "select1a"
},
"no": {
"text": "No",
"cnvId": "select2a"
}
}
}]
}, {
"id": "cnv3a",
"collection": [{
"belongsTo": "triggerNpc",
"text": "Did you get that door open yet?"
}]
}, {
"id": "cnv4a",
"collection": [{
"belongsTo": "triggerNpc",
"text": "Thanks for opening the door pal."
}]
},
{
"id": "cnv5a",
"collection": [{
"belongsTo": "triggerNpc",
"text": "I'm a busy man, leave me be."
}]
}, {
"id": "cnv6a",
"collection": [{
"belongsTo": "triggerNpc",
"text": "He said what? Sure, here's the key."
}]
}, {
"id": "cnv7a",
"collection": [{
"belongsTo": "triggerNpc",
"text": "What is it this time? You got your key now bugger off!"
}]
}, {
"id": "cnv8a",
"collection": [{
"belongsTo": "triggerNpc",
"text": "The door. Is open. Seriously, go away."
}]
},
{
"id": "select1a",
"collection": [{
"belongsTo": "triggerNpc",
"text": "Thanks buddy. Go and ask Jim for the key."
}]
}, {
"id": "select2a",
"collection": [{
"belongsTo": "triggerNpc",
"text": "Suit yourself."
}]
}, {
"id": "door1a",
...