-
Notifications
You must be signed in to change notification settings - Fork 0
custom event handler
There is an event-system in javascript but it can only be used by GUI-elements.
To create something similiar by yourself, add the following function to your code:
function PubSub() {
return {
events: {},
subscribe: function (event, handler) {
if (!this.events[event]) {
this.events[event] = [];
}
this.events[event].push(handler);
},
publish: function (event, data) {
this.events[event] && this.events[event].forEach(publishData);
function publishData(handler) {
handler(data);
};
}
};}
Then you can add this component to your objects:
class QuestManager {
constructor() { this.pubSub = PubSub(); }
questUpdated(questId) {
this.pubSub.publish("change",questId);
}
}
var mgr = new QuestManager()
mgr.pubSub.subscribe("change",function(data){alert("Quest "+data+" updated")});
What is twine and interactive fiction
Exampl. SuperSimpleStory
What are storyformats
Why snowman
Setup tweego and snowman
Switching between Tweego and Twine
Snowman template methods
Snowman markup
javascript usage
debugging your story
Common issues with template methods and scripting
Story Telling in general
General concepts for IF
Scenes & Sequels
Designing Puzzles
See here about my js-framework running in snowman:
==> problems & solutions <==