:: StoryTitle Space Exploration in Snowman :: UserScript[script] // Create a global setup object window.setup = window.setup || {}; // Add 'variables' object to setup window.setup.variables = {}; var _vars = window.setup.variables; _vars.health = 20; _vars.fuel = 4; _vars.system = []; _vars.numberOfJumpsLeft = 10; // Create global functions window.setup.functions = {}; var _functions = window.setup.functions; _functions.redOutcome = function() { var _vars = window.setup.variables; var _percentage = _.random(1, 10); var response = ""; if( _percentage >= 6) { var _foundHealth = _.random( 1, 5); var _foundFuel = _.random( 1, 3); response = "The hostile environment damaged the ship, but extra fuel was found. -" + _foundHealth + " to health and +" + _foundFuel + " to fuel."; _vars.health -= _foundHealth; _vars.fuel += _foundFuel; } else { if( _percentage <= 3) { var _foundHealth = _.random(2, 7); response = "A hostile ship attacked. -" + _foundHealth + " to health"; _vars.health -= _foundHealth; } else { response = "Nothing happened." } } return response; }; _functions.greenOutcome = function() { var _vars = window.setup.variables; var _percentage = _.random(1, 10); var response = ""; if( _percentage == 1) { var _foundFuel = _.random( 1, 2); response = "Fuel was found in some wreckage. + " + _foundFuel + "to fuel"; _vars.fuel += _foundFuel; } else { if( _percentage >= 6) { var _foundHealth = _.random(1, 3); response = "During a brief pause, the ship was able to be repaired. +" + _foundHealth + " to health"; _vars.health += _foundHealth; } else { response = "Nothing happened." } } return response; }; :: UserStylesheet[stylesheet] :: Start [[Explore Space|Explore Space 1]] :: Explore Space 1
<% var _vars = window.setup.variables; %> <% _vars.fuel-- %> <% _vars.numberOfJumpsLeft-- %> [[ Hyperjump |Explore Space 2]]
<%= window.story.render("HUD") %>
<%= window.story.render("Generate System") %>
<%= window.story.render("Display System") %> <%= window.story.render("Check Status") %>
:: Explore Space 2
<% var _vars = window.setup.variables; %> <% _vars.fuel-- %> <% _vars.numberOfJumpsLeft-- %> [[ Hyperjump |Explore Space 1]]
<%= window.story.render("HUD") %>
<%= window.story.render("Generate System") %>
<%= window.story.render("Display System") %> <%= window.story.render("Check Status") %>
:: Generate System :: Display System :: Show Outcome - Red <%= window.setup.functions.redOutcome() %> <% $("#HUD").html(window.story.render("HUD")) %> <%= window.story.render("Check Status") %> :: Show Outcome - Green <%= window.setup.functions.greenOutcome() %> <% $("#HUD").html(window.story.render("HUD")) %> <%= window.story.render("Check Status") %> :: HUD Health: <%= window.setup.variables.health %>
Fuel: <%= window.setup.variables.fuel %>
Number of Jumps Left: <%= setup.variables.numberOfJumpsLeft %>
:: Destroyed The ship exploded in flight.

Game Over

:: Lost in space Without fuel, the ship tumbled and spun in the endless black.

Game Over

:: Safe After 10 hyperjumps, the ship left the hazardous area and called for help.

Success!

:: Check Status