195 lines
4.7 KiB
Plaintext
195 lines
4.7 KiB
Plaintext
:: Start
|
|
[[krowbar-start]]
|
|
|
|
:: Set Globals [script]
|
|
try {
|
|
macros['SetGlobals'] =
|
|
{
|
|
handler: function(place, macroName, params, parser)
|
|
{
|
|
},
|
|
|
|
var gVars = state.history[0].variables;
|
|
gVars.items = {};
|
|
gVars.items['gold'] = 0;
|
|
gVars.events = {};
|
|
gVars.stats = {};
|
|
gVars.stats['health'] = 10;
|
|
gVars.stats['health_max'] = 10;
|
|
gVars.stats['strength'] = 1;
|
|
gVars.skills = {};
|
|
gVars.skills['adventuring'] = 2;
|
|
} catch(e) {
|
|
console.log("Error during Globals setup: " + e.message);
|
|
}
|
|
|
|
:: krowbar-start [start inv]
|
|
<<if visited("krowbar-start") is 1>>Welcome to the adventure!<<endif>>
|
|
There is a door on the wall.
|
|
<<if not visited("Get McGuffin")>>You see a McGuffin<<endif>>
|
|
<<if not visited("Get Coins")>>You see a few coins on the floor<<endif>>
|
|
<<actions "Get McGuffin" "Get Coins">>\
|
|
<<if $items['McGuffin'] is true>><<actions "Use McGuffin on door">><<endif>>\
|
|
<<if visited("Use McGuffin on door")>>[[Go through door|Room2]]<<endif>>
|
|
[[PlayerProfile]]
|
|
|
|
:: Get McGuffin
|
|
You pick up the McGuffin.
|
|
<<set $items['McGuffin'] to true>>
|
|
[[Return|previous()]]
|
|
|
|
:: Get Coins
|
|
You pick up the coins.
|
|
<<set $items['gold'] += 3>>
|
|
[[Return|previous()]]
|
|
|
|
:: Use McGuffin on door
|
|
You use the McGuffin on the door.
|
|
The McGuffin crumbles and the door opens.
|
|
<<set $items['McGuffin'] to false>>
|
|
[[Return|previous()]]
|
|
|
|
:: Room2 [inv]
|
|
This is room2. There is a cake on the ground.
|
|
The door ahead is blocked.
|
|
<<actions "Eat cake">>
|
|
<<if $stats['strength'] gte 3>>[[Break through the door|Room3]]
|
|
<<else>>You are not strong enough to break this door.<<endif>>
|
|
|
|
::Eat cake
|
|
You feel incredibly stronger!
|
|
Strength increased to <<$stats['strength'] += 3>>
|
|
[[Return|previous()]]
|
|
|
|
:: Room3 [inv]
|
|
Seriously, nothing here.
|
|
Return to [[the start|Start]]
|
|
|
|
:: Inventory
|
|
<br>
|
|
<strong>Inventory:</strong>
|
|
<<Inventory>>
|
|
|
|
:: ShowInventory [script]
|
|
try {
|
|
version.extensions['Inventory'] = {
|
|
major:0, minor:1, revision:0
|
|
};
|
|
macros['Inventory'] =
|
|
{
|
|
handler: function(place, macroName, params, parser)
|
|
{
|
|
var msg = "";
|
|
var items = state.history[0].variables.items;
|
|
if (items == undefined) {
|
|
new Wikifier(place, "nothing");
|
|
return;
|
|
}
|
|
for(var name in items) {
|
|
if(!isNaN(parseFloat(items[name])) && isFinite(items[name])) {
|
|
msg += name + "(" + items[name] + "), ";
|
|
}
|
|
else if(items[name] != false) {
|
|
msg += name + ", ";
|
|
}
|
|
};
|
|
new Wikifier(place, msg.slice(0,-2));
|
|
},
|
|
init: function() { },
|
|
};
|
|
} catch(e) {
|
|
throwError(place,"Inventory Setup Error: " + e.message);
|
|
}
|
|
|
|
:: PlayerStats
|
|
<br>
|
|
<strong>Player Stats:</strong>
|
|
<<PlayerStats>>
|
|
|
|
:: ShowPlayerStats [script]
|
|
try {
|
|
version.extensions['PlayerStats'] = {
|
|
major:0, minor:1, revision:0
|
|
};
|
|
macros['PlayerStats'] =
|
|
{
|
|
handler: function(place, macroName, params, parser)
|
|
{
|
|
var msg = "";
|
|
var stats = state.history[0].variables.stats;
|
|
if (stats == undefined) {
|
|
new Wikifier(place, "no stats");
|
|
return;
|
|
}
|
|
for(var stat in stats) {
|
|
if(stat.slice(-4) == "_max") {
|
|
continue;
|
|
}
|
|
msg += stat + ": " + stats[stat];
|
|
if(stats[stat+"_max"] != undefined) {
|
|
msg += " / " + stats[stat+"_max"];
|
|
}
|
|
msg += "<br>";
|
|
}
|
|
new Wikifier(place, msg);
|
|
},
|
|
init: function() { },
|
|
};
|
|
} catch(e) {
|
|
throwError(place,"PlayerStats Setup Error: " + e.message);
|
|
}
|
|
|
|
:: PlayerSkills
|
|
<br>
|
|
<strong>Player Skills:</strong>
|
|
<<PlayerSkills>>
|
|
|
|
:: ShowPlayerSkills [script]
|
|
try {
|
|
version.extensions['PlayerSkills'] = {
|
|
major:0, minor:1, revision:0
|
|
};
|
|
macros['PlayerSkills'] =
|
|
{
|
|
handler: function(place, macroName, params, parser)
|
|
{
|
|
var msg = "";
|
|
var stats = state.history[0].variables.skills;
|
|
if (stats == undefined) {
|
|
new Wikifier(place, "no skills");
|
|
return;
|
|
}
|
|
for(var stat in stats) {
|
|
msg += stat + ": " + stats[stat]+"<br>";
|
|
}
|
|
new Wikifier(place, msg);
|
|
},
|
|
init: function() { },
|
|
};
|
|
} catch(e) {
|
|
throwError(place,"PlayerSkills Setup Error: " + e.message);
|
|
}
|
|
|
|
:: PlayerProfile
|
|
[[Return|previous()]]
|
|
-~-~-~-~-~-
|
|
<<display PlayerStats>>
|
|
<<display PlayerSkills>>
|
|
<<display Inventory>>
|
|
|
|
:: postrender [script]
|
|
postrender.tagInventory = function(place) {
|
|
var inv = tale.get("Inventory");
|
|
if (inv.id !== undefined && ~this.tags.indexOf("inv")) {
|
|
new Wikifier(place, inv.processText());
|
|
};
|
|
var stats = tale.get("PlayerStats");
|
|
if(stats.id !== undefined && ~this.tags.indexOf("stats")) {
|
|
new Wikifier(place, stats.processText());
|
|
};
|
|
var skills = tale.get("PlayerSkills");
|
|
if(skills.id !== undefined && ~this.tags.indexOf("skills")) {
|
|
new Wikifier(place, skills.processText());
|
|
};
|
|
}
|