Your browser lacks required capabilities. Please upgrade it or switch to another to continue.
Loading…
/* Display */
<div class='container'>
<div class='textbox'>
You have successfully escaped the forest maze!<br><br>
[[Return to start|Start]]
</div>
</div>/* Display */
<div class='container'>
<div class='textbox'>
You have been caught.<br><br>
[[Return to start|Start]]
</div>
</div>/* Update time */
<<update_current_time>>
<<update_world>>
/* Display */
<div class='container'>
<div class='textbox'>
Max line width:<br>
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz<br>
the quick brown fox jump the lazy dog the quick brown dog jump the lazy fox<br><br>
[[Start]]<br>
[[Refresh|Debug]]<br><br>
npcKeys: $npcKeys<br><br>
npcs:<br>
<<for _i to 0; _i lt $npcKeys.length; _i++>>
<<set _npcKey to $npcKeys[_i]>>
name: <<print setup.npc[_npcKey].name>><br>
friends: $npc[_npcKey].friends<br>
holding:
<<if checkHolding($npc[_npcKey].hold) is true>>
<<= $npc[_npcKey].hold.name>>
<<else>>
nothing
<</if>><br>
room:
<<if $npc[_npcKey].room.length gt 0>>
<<for _j to 0; _j lt $npc[_npcKey].room.length; _j++>>
<<= $npc[_npcKey].room[_j].name>>
<</for>>
<<else>>
empty
<</if>><br>
mailbox:
<<if $npc[_npcKey].mail.length gt 0>>
<<for _j to 0; _j lt $npc[_npcKey].mail.length; _j++>>
<<= $npc[_npcKey].mail[_j].name>>
<</for>>
<<else>>
empty
<</if>><br>
current site:
$npc[_npcKey].site<br><br>
<</for>>
containers:
<<for _i to 0; _i lt $containerKeys.length; _i++>>
<<set _containerKey to $containerKeys[_i]>>
name: _containerKey<br>
holding:
<<if checkHolding($container[_containerKey].hold) is true>>
<<= $container[_containerKey].hold.name>>
<<else>>
nothing
<</if>><br>
current site:
$container[_containerKey].site<br><br>
<</for>>
</div>
</div>/* Display */
<div class='container'>
<div class='textbox'>
<<print setup.map[$mapKey].name>>.<br>
/* Tree message - turn this into a widget
<<print_tree_message>> */
/* NPC message - turn this into a widget
<<print_npc_message>> */
/* Map message
<<print_map_message>><br><br> */
/* Forage - simulate hoot */
<<print_map_message>>
<<print_tree_message>>
<<print_lock>>
<<print_container>>
<<update_hoot>><br><br>
/* Links */
[[Wait|Map]]  <<print_links>>
</div>
</div>/* Update the world state */
<<update_current_time>>
<<update_world>>
/* Display */
<div class='container'>
<div class='textbox'>
[[Back|Map][$mapKey to 'home']]
</div>
</div>/* Display */
<div class='container'>
<div class='textbox'>
[[Archives|Map][$mapKey to 'archives']]<br>
[[Home|Map][$mapKey to 'mygarden']]
</div>
</div>/* Update time */
<<update_current_time>>
/* Display */
<div class='container'>
<div class='textbox'>
Forest forage<br><br>
/*$currentWeekday $currentState<br><br>
<<if Save.autosave.has()>>
<<link "Visit world">>
<<script>>Save.autosave.load()<</script>>
<</link>><br><br>
<<link [[Clear Data Forever|Start]]>>
<<script>>Save.autosave.delete()<</script>>
<</link>>
<<else>>
[[Start game|GameInit]]
<</if>>*/
[[Start game|GameInit]]
</div>
</div>/* Initialise game variables */
/* Initialise the list of NPCs */
<<set $npc to {
'catfacet': {
friends: ['kafeapple', 'tomcoffey'],
hold: {},
mail: [],
room: [{name: 'widget', last: 'unknown'}],
site: 'cafe'
},
'kafeapple': {
friends: ['catfacet', 'tomcoffey'],
hold: {},
mail: [],
room: [],
site: 'mossbridge'
},
'tomcoffey': {
friends: ['catfacet', 'kafeapple'],
hold: {name: 'widget', last: 'unknown'},
mail: [],
room: [],
site: 'secretgarden'
}
}>>
<<set $npcKeys to Object.keys($npc)>>
/* Initialise the list of containers */
<<set $container to {
'mb_box': {},
'sg_box': {name: 'secret_goodie', last: 'unknown'},
'nest': {name: 'gate_key', last: 'unknown'},
'stone_basin': {name: 'arch_key', last: 'unknown'},
'wall_rack': {name: 'paddle', last: 'unknown'}
}>>
<<set $containerKeys to Object.keys($container)>>
/* Forage - variables */
<<set $player to {
name: '',
hold: []
}>>
<<set $hoot to {
alert: false,
site: 'eyrie'
}>>
/* Display */
<div class='container'>
<div class='textbox'>
You wake up in a small wooden gazebo, deep night, with no memory of how you got here. Dark forest all around. From the gazebo steps a trail disappears among the trees. /*What is your name?*/<br><br>
/*<<textbox "$player.name" "Tommy" autofocus>><br><br>*/
[[Start|Map][$mapKey to 'gazebo']]
</div>
</div><div id="passages"></div>/* Deprecated - check for container widget
<<widget 'check_for_container'>>
<<for _i to 0; _i lt $containerKeys.length; _i++>>
<<set _containerKey to $containerKeys[_i]>>
<<if $container[_containerKey].site is $args[0]>>
<<set _isContainerPresent to true>>
<<break>>
<<else>>
<<set _isContainerPresent to false>>
<</if>>
<</for>>
<</widget>>
*/
/* Deprecated - print a message about the current zone
<<widget 'print_zone_message'>>
<<if $isRaining is true>>
Rain drips through the leaves of the <<print setup.treeList[_currentTree].name>>.
<<elseif $currentPeriod is 'Day'>>
<<if setup.treeList[_currentTree].flowers.includes($currentMonth)>>
The <<print setup.treeList[_currentTree].name>> has put out <<print setup.treeList[_currentTree].bloom>> blooms.
<<else>>
Sunlight filters through the leaves of the <<print setup.treeList[_currentTree].name>>.
<</if>>
<<else>>
You hear the <<print setup.treeList[_currentTree].name>> rustling in the breeze.
<</if>>
<</widget>>
*/
/* Check for container items */
<<widget 'print_container'>>
<<if setup.map[$mapKey].container.length gt 0>>
<<set _containerKey to either(setup.map[$mapKey].container)>>
There is a <<print setup.container[_containerKey].name>> here.
/* Anything in it? */
<<if checkHolding($container[_containerKey]) is true>>
<<set _itemKey to $container[_containerKey].name>>
<<set _itemName to setup.item[_itemKey].name>>
It holds the <<link [[_itemName|Map]]>>
<<set $player.hold.push($container[_containerKey])>>
<<set $container[_containerKey] to {}>>
<</link>>.
<<else>>
It is empty.
<</if>>
<</if>>
<</widget>>
/* Print links */
<<widget 'print_links'>>
<<if setup.map[$mapKey].link.length gt 0>>
<<for _i to 0; _i lt setup.map[$mapKey].link.length; _i++>>
<<set _linkKey to setup.map[$mapKey].link[_i]>>
<<set _linkName to setup.map[_linkKey].name>>
<<capture _linkKey>>
[[_linkName|Map][$mapKey to _linkKey]] 
<</capture>>
<</for>>
<</if>>
<</widget>>
/* Check for locks */
<<widget 'print_lock'>>
<<if checkHolding(setup.map[$mapKey].lock) is true>>
<<print setup.map[$mapKey].lock.text>>
<<if $player.hold.length gt 0>>
<<for _i to 0; _i lt $player.hold.length; _i++>>
<<if $player.hold[_i].name is setup.map[$mapKey].lock.key>>
<<set _itemName to setup.item[$player.hold[_i].name].name>>
<<set _linkKey to setup.map[$mapKey].lock.link>>
<<capture _linkKey>>
Use your [[_itemName|Map][$mapKey to _linkKey]]?
<</capture>>
<<break>>
<</if>>
<</for>>
<</if>>
<</if>>
<</widget>>
/* Print map message */
<<widget 'print_map_message'>>
<<print setup.map[$mapKey].text>>
<</widget>>
/* Print NPC message */
<<widget 'print_npc_message'>>
<<for _i to 0; _i lt $npcKeys.length; _i++>>
<<set _npcKey to $npcKeys[_i]>>
<<if $npc[_npcKey].site is $mapKey>>
<<print setup.npc[_npcKey].name>> is here.
<<if checkHolding($npc[_npcKey].hold) is true>>
<span class='capitalize'><<print setup.npc[_npcKey].pron>></span> is holding the $npc[_npcKey].hold.name.
<</if>>
<</if>>
<</for>>
<</widget>>
/* Print tree message */
<<widget 'print_tree_message'>>
<<if setup.map[$mapKey].tree.length gt 0>>
<<set _treeKey to either(setup.map[$mapKey].tree)>>
<<switch $currentState>>
<<case 'deepnight' 'evening'>>
The <<print setup.tree[_treeKey].name>> rustles in the breeze.
<<case 'morning' 'afternoon'>>
Light filters through the <<print setup.tree[_treeKey].name>>.
<<case 'raining'>>
Rain drips through the <<print setup.tree[_treeKey].name>>.
<</switch>>
<</if>>
<</widget>>
/* Update current time widget */
<<widget 'update_current_time'>>
<<set $currentDate to new Date()>>
<<set $currentDay to $currentDate.getDate()>>
/*<<set $currentHour to $currentDate.getHours()>>*/
<<set $currentHour to 23>>
<<set $currentMonth to $currentDate.getMonth()>>
<<set $currentWeekday to setup.weekday[$currentDate.getDay()]>>
<<set _roll to random(1,6)>>
<<if _roll is 6>>
<<set $currentState to 'raining'>>
<<else>>
<<if $currentHour lt setup.month[$currentMonth].sunrise>>
<<set $currentState to 'deepnight'>>
<<elseif $currentHour lt 12>>
<<set $currentState to 'morning'>>
<<elseif $currentHour lt setup.month[$currentMonth].sunset>>
<<set $currentState to 'afternoon'>>
<<else>>
<<set $currentState to 'evening'>>
<</if>>
<</if>>
<</widget>>
/* Update world state widget. At some stage this will only run once per quarter-day, which given most npc schedules will stop them from hiding and retrieving items in rapid succession */
<<widget 'update_world'>>
<<for _i to 0; _i lt $npcKeys.length; _i++>>
<<set _npcKey to $npcKeys[_i]>>
/* Check if the NPC is roaming about or at home */
<<if setup.npc[_npcKey].roams.includes($currentState)>>
<<set $npc[_npcKey].site to either(setup.npc[_npcKey].sites)>>
<<else>>
<<set $npc[_npcKey].site to 'zeroworld'>>
<</if>>
/* Is there a nearby container */
<<if setup.map[$npc[_npcKey].site].container.length gt 0>>
<<set _containerKey to either(setup.map[$npc[_npcKey].site].container)>>
/* Can the NPC store anything in this container */
<<if checkHolding($npc[_npcKey].hold) is true>>
<<if checkHolding($container[_containerKey]) is false>>
<<set $container[_containerKey] to $npc[_npcKey].hold>>
<<set $npc[_npcKey].hold to {}>>
<</if>>
/* Can the NPC take anything from this container */
<<else>>
<<if checkHolding($container[_containerKey]) is true>>
<<set $npc[_npcKey].hold to $container[_containerKey]>>
<<set $container[_containerKey] to {}>>
<</if>>
<</if>>
<</if>>
/* Move anything from the NPC mailbox into their room */
<<if $npc[_npcKey].mail.length gt 0>>
<<for _j to 0; _j lt $npc[_npcKey].mail.length; _j++>>
<<set $npc[_npcKey].room.push($npc[_npcKey].mail[_j])>>
<<set $npc[_npcKey].mail.splice(_j, 1)>>
<</for>>
<</if>>
<</for>>
<</widget>>
// Forage - enemy AI widget
<<widget "update_hoot">>
/* If the player has been seen, chase them */
<<if $hoot.alert is true>>
/* If the player escapes to a safe area, give up the chase */
<<if setup.map[$mapKey].safe is true>>
<<set $hoot.alert to false>>
<b>Something gives up the chase.</b>
/* Otherwise keep pursuing them ... */
<<else>>
<<set $hoot.site to $mapKey>>
<b><<print either('Something is pursuing you.', 'You narrowly dodge a swoop.', 'A talon grazes your ear.')>></b>
/* ... and run a gameover check */
<<set _roll to random(1,6)>>
<<if _roll is 1>>
<<goto "Gameover">>
<</if>>
<</if>>
/* Else if the player hasn't been seen, roam around the map */
<<else>>
/* If the current site can be roosted at, prefer to wait in silence */
<<if setup.map[$hoot.site].roost is true>>
<<set _roll to random(1,3)>>
/* If changing position */
<<if _roll is 1>>
<<set $hoot.site to either(setup.map[$hoot.site].link)>>
<</if>>
<<else>>
<<set $hoot.site to either(setup.map[$hoot.site].link)>>
<</if>>
/* If on the same map as the player */
<<if $hoot.site is $mapKey>>
/* If the player is safe */
<<if setup.map[$mapKey].safe is true>>
<b>Something swoops past.</b>
<<else>>
<<set $hoot.alert to true>>
<b>You hear a rapid flutter of wings.</b>
<</if>>
/* Otherwise, see if it's close by */
<<elseif setup.map[$hoot.site].link.includes($mapKey)>>
<b><<print either('You hear flapping close by.', 'Something breezes through the trees nearby.', 'You hear a faint hoot.')>></b>
<</if>>
<</if>>
<</widget>>