From c4d80f00389b7f98222729e7350c5d64ce423a40 Mon Sep 17 00:00:00 2001 From: Russell Date: Tue, 6 Jan 2015 18:33:01 +0000 Subject: [PATCH] Changes to twine files --- ttitt/items.twee | 5 +++ ttitt/krowbar.twee | 72 ++++++++++++++++++++++++++++++++- ttitt/macros.twee | 54 +++++++++++++++++++++---- ttitt/twineGuidelines.txt | 84 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 207 insertions(+), 8 deletions(-) create mode 100644 ttitt/items.twee create mode 100644 ttitt/twineGuidelines.txt diff --git a/ttitt/items.twee b/ttitt/items.twee new file mode 100644 index 0000000..946e30a --- /dev/null +++ b/ttitt/items.twee @@ -0,0 +1,5 @@ +:: cleaver-itemDescription [item] +This is a rusty old cleaver. It won't help you in a fight, but it could be useful + +:: crowbar-itemDescription [item] +It feels like this crowbar has a history behind it... diff --git a/ttitt/krowbar.twee b/ttitt/krowbar.twee index 5cf67da..67c475a 100644 --- a/ttitt/krowbar.twee +++ b/ttitt/krowbar.twee @@ -1,5 +1,75 @@ +:: krowbar-init [init] +<> +<> + +:: krowbar-startDescription +Set in the wall, you see a large portal, twice your height, shining with a malevolent, pulsating, purple glow. +Despite its omnious aura, you feel a strange impulse that compels you to [[enter the portal|krowbar-start]]. + :: krowbar-start [start inv] -<> +[[The Portal|krowbar-ExaminePortal]] you stepped through is in a forest of [[tropical trees|krowbar-ExamineTrees]]. +The heat and humidity hit you in contrast to the cool, dry environment of the Hub. +As you listen, you hear the sounds of gunfire and muffled explosions in the distance. +There is [[a dirt path leading downward|krowbar-FollowPath1]]. +<>[[Enter the portal|Start]]<> +[[Player Profile|PlayerProfile]] + +:: krowbar-ExaminePortal +<>The portal is now the same purple color as when you first entered +<>You examine the portal and note that it has lost the swirling purple luster that it had when you first came through. +<> +[[Return|previous()]] + +:: krowbar-ExamineTrees +Upon closer examination, you find that these trees have strange orange bark and blue-tinted leaves. +You also notice small burn pock-marks on several of the trees. +How curious! +[[Return|previous()]] + +:: krowbar-FollowPath1 [inv] +You are on a dirt path on a hill. +[[The path up|krowbar-start]] leads to the Portal. +The path [[continues downward|krowbar-FollowPath2]]. +<>You see a button on the ground +[[Press Button|krowbar-PressButton]]<> + +:: krowbar-PressButton +After you press the button, you hear a 'click' and feel a thrum in the air. +[[Return|previous()]] +<> + +:: krowbar-FollowPath2 [inv] +You find yourself in a small clearing. In the center, you see [[a small, thatched-roof cottage|krowbar-EnterCottage]]. +You see three dirt paths. One [[leads upwards|krowbar-FollowPath1]], one leads [[toward a lake|krowbar-FollowPath3]], and one leads [[toward rubble|krowbar-FollowPath4]] +[[Examine cottage|krowbar-ExamineCottage]] + +:: krowbar-ExamineCottage +This cottage appears to be made from the native trees. +[[Enter cottage|krowbar-EnterCottage]] +[[Return|previous()]] + +:: krowbar-EnterCottage [inv] +There is a thick layer of dust on everything within the cottage. Very little light is able to make its way inward. +<>The [[wooded window blinds|krowbar-CottageOpenWindows]] are closed. +<>The windows are now letting in enough light to let you see [[some cubbards|krowbar-CottageSearchCubbards]]. +<> +[[Leave cottage|krowbar-FollowPath2]] + +:: krowbar-CottageOpenWindows +After a few moments of effort, you manage to yank open the old blinds. +[[Return|previous()]] + +:: krowbar-CottageSearchCubbards +<> +After rummaging around the cubbards, you find a rusty cleaver and <<$krowbar_temp1 to random(2,5)>> coins. +[[Return|previous()]] +<> +<> +<>You don't find anything else of value in the cubbards. +[[Return|previous()]] +<> + +:: oldstart <>Welcome to the adventure!<> There is a sealed door on the wall. <>You see a McGuffin
<>\ diff --git a/ttitt/macros.twee b/ttitt/macros.twee index 001529e..de8a4b6 100644 --- a/ttitt/macros.twee +++ b/ttitt/macros.twee @@ -20,10 +20,20 @@ try { } for(var name in items) { if(!isNaN(parseFloat(items[name])) && isFinite(items[name])) { - msg += name + "(" + items[name] + "), "; + if(tale.passages[name+"-itemDescription"]) { + msg += "[["+name+"|"+name+"-itemDescription]](" + items[name] + "), "; + } + else { + msg += name + "(" + items[name] + "), "; + } } else if(items[name] != false) { - msg += name + ", "; + if(tale.passages[name+"-itemDescription"]) { + msg += "[["+name+"|"+name+"-itemDescription]], "; + } + else { + msg += name + ", "; + } } }; new Wikifier(place, msg.slice(0,-2)); @@ -103,8 +113,35 @@ try { throwError(place,"PlayerSkills Setup Error: " + e.message); } +:: GetPreviousNonItem [script] +try { + version.extensions['PreviousNonItem'] = { + major:0, minor:1, revision:0 + }; + macros['PreviousNonItem'] = + { + handler: function(place, macroName, params, parser) + { + var msg = ""; + for(var h in state.history) { + if(state.history[h].passage.title == "PlayerProfile" || + state.history[h].passage.title.slice(-16) == "-itemDescription") + continue; //skip all the inventory items + + msg += state.history[h].passage.title; + break; //we only want the first instance of a non-item passage + + } + new Wikifier(place, "[[Return|" + msg + "]]"); + }, + init: function() { }, + }; +} catch(e) { + throwError(place,"PreviousNonItem Setup Error: " + e.message); +} + :: PlayerProfile -[[Return|previous()]] +<> -~-~-~-~-~- <> <> @@ -124,6 +161,9 @@ postrender.tagInventory = function(place) { if(skills.id !== undefined && ~this.tags.indexOf("skills")) { new Wikifier(place, skills.processText()); }; + if(~this.tags.indexOf("item")) { + new Wikifier(place, "\n[[Return|previous()]]"); + }; } :: core-init @@ -135,10 +175,7 @@ postrender.tagInventory = function(place) { <> <> <> -<> -<> <> -<> <> <> @@ -152,10 +189,13 @@ try { handler: function(place, macroName, params, parser) { var msg = "<><>"; + msg += "<>"; //manually add core-init first + console.log("Initializing core-init"); for(var p in tale.passages) { /%if(~tale.passages[p].tags.indexOf("init")) {%/ - if(p.slice(-5) == "-init") { + if(p.slice(-5) == "-init" && p != "core-init") { msg += "<>"; + console.log("Initializing " + p); } } msg += "<><>"; diff --git a/ttitt/twineGuidelines.txt b/ttitt/twineGuidelines.txt new file mode 100644 index 0000000..17904e2 --- /dev/null +++ b/ttitt/twineGuidelines.txt @@ -0,0 +1,84 @@ +Tilde.town shared Twine story guidelines +Written by ~krowbar, managed by ~jumblesale + +## Reserved Passages ## +* These passages are reserved for use by the core shared system +:: Start - Acts as the core hub +:: core-init - Initializes core variables +:: GetInit - Provides the <> macro used by core +:: Inventory - Displays the player inventory +:: ShowInventory - Provides the <> macro +:: PlayerStats - Displays the player stats +:: ShowPlayerStats - Provides the <> macro +:: PlayerSkills - Displays the player skills +:: ShowPlayerSkills - Provides the <> macro +:: PlayerProfile - Displays player stats, skills, and inventory +:: postrender - adds macros to tagged passages + +## Magic Passages ## +* Some passages are automatically used to display information about your story +* or items. +:: NAME-start - the start page for your story +:: NAME-startDescription - an optional description for your story start + (~jumblesale todo) +:: NAME-init - initialize any values for your story +:: ITEM-itemDescription [item] - provide a description for your item + +## Magic Tags ## +* Some tags have been set up to provide story writers with quick access to +* certain features +[inv] - will show ":: Inventory" at the bottom of the passage +[stats] - will show ":: PlayerStats" at the bottom of the passage +[skills] - will show ":: PlayerSkills" at the bottom of the passage +[playerProfile] - will show ":: PlayerProfile" at the bottom of the passage +[item] - will append a "[[Return|previous()]]" to the passage + + +## The Player ## +* Global objects are provided for $items, $events, $stats, and $skills that any + story can reference or modify + +## Player Inventory ## +* The player has a global inventory of items that can be accessed in any story +* One way to pick up an item is to use <> +* To check if a player has already retrieved an item, either check the +* $items['ITEM'] value or check "visited("Get NAME")" +* An item can be added to the global items hash with the following + $items['ITEM'] = VALUE +* A unique item, like "gearbox" or "sword", will have VALUE of true +* When a unique items is used up or destroyed, set its value to false +* Generic items that the player can have many of, like "gold" or "smallKey", + will have a numerical value + +## Player Stats and Skills ## +* Are persistant between stories +* Are stored as + $stat['STAT'] = VALUE + $skill['SKILL'] = VALUE +* Skills and stats can be modified by events. +* eg "You eat the cake and feel much stronger! Strength increased to + <<$stat['strength'] += 2>>!" +* Skills checks can be made by checking the value against your threshold +* eg "<>You hit the target!<>" + +## The Hub ## +* Has links to all user stories +* Should heal the player (~jumblesale todo) +* Should be able to tell the player their stats/skills (~jumblesale todo) + +## General Guidelines ## +* It is recomended (but not mandatory) to have separate .twee files +USERNAME.twee - contains all your core story passages +macros.twee - contains any macros and *-init passages you write +items.twee - contains *-itemDescription passages + - optionally contains item getting passages + +## Story-telling Guidelines ## +* All stories should have a path that leads back to the Hub +** This path does not have to be made immediately upon entering, but should become available fairly soon +* Stories can NOT kill the player +** Alternately, we could allow player death to 'port them to the Hub +* Stories should not cause the player to lose or use up global objects that +* were not acquired in that story +** An exception to this could be gold or money +* Should not decrease a stat or skill