Back to Index Page generated: Dec 20, 2024, 7:22:10 AM

Expansion Cup of Tea

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Buy a tea making machine. This will brew a lovely cup of tea in 15 seconds. Enjoy! Buy a tea making machine. This will brew a lovely cup of tea in 15 seconds. Enjoy!
Identifier oolite.oxp.smivs.cup_of_tea oolite.oxp.smivs.cup_of_tea
Title Cup of Tea Cup of Tea
Category Ambience Ambience
Author Smivs Smivs
Version 1.2 1.2
Tags ambience ambience
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL n/a
Download URL https://wiki.alioth.net/img_auth.php/4/42/Cup_of_Tea-v1.2.oxz
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1610873283

Documentation

Also read http://wiki.alioth.net/index.php/Cup%20of%20Tea

readme.rtf

Cup of Tea OXP V1.2

This OXP adds a cockpit Tea Maker for your ship.  

You can buy a Tea maker anywhere for just 100Cr. The Tea Maker is supplied with 25 'T-pods'. A 'T-pod' is a disposable mug containing all the ingredients for your cup of tea. The Tea Maker then boils water, adds it to your tea and brews it.
Your Tea maker is primable equipment - 'Shift-n' to prime, and 'n' to activate. Console messages will tell you how your tea is progressing, and a gong will alert you when it is ready.
Your Tea Maker will warn you when you have only five 'T-pods' remaining and you will also be told when you are using your last 'T-pod'. You can buy more 'T-pods' from the ship Outfitters when there are five or less left in the machine. The Tea Maker will not work once these are all gone.
Choose between Tea, Tea with Milk, Tea with Sugar and Tea with Milk and Sugar. 25 'T-pods' will cost 10Cr.
The Express Tea Maker can be fitted in the cockpit of your ship where it is unlikely to suffer damage, and only takes five minutes to install. It is fully portable and you can move it to any new ship you buy.

License:-
This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.

Author:-
The OXP was developed by Smivs.





Equipment

Name Visible Cost [deci-credits] Tech-Level
Express Tea Maker yes 1000 1+
Express Tea Maker yes 0 17+
Tea 'T-Pods' no 100 1+
Tea with Milk 'T-Pods' no 100 1+
Tea with Sugar 'T-Pods' no 100 1+
Tea with Milk and Sugar 'T-Pods' no 100 1+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Scripts/TeaMakerScript.js
/*jslint white: true, undef: true, eqeqeq: true, bitwise: true, regexp: true, newcap: true, immed: true */

"use strict";

// Standard attributes 
this.name           = "TeaMakerScript.js"; 
this.author         = "Smivs"; 
this.copyright      = "(C) Smivs"
this.licence        = "Creative Commons Attribution - Non-Commercial - Share Alike 4.0"
this.version        = "1.2"; 
this.description    = "Script to operate tea-maker and control refills."; 

this.missionScreenOpportunity = function()
// update old TEA_MAKER version to new TEAPOT version for existing users
{
if (player.ship.docked && player.ship.equipmentStatus("EQ_TEA_MAKER") == "EQUIPMENT_DAMAGED")
  {
    return;
  }
if (player.ship.docked && player.ship.equipmentStatus("EQ_TEA_MAKER") == "EQUIPMENT_OK")
  {
    mission.runScreen({title: "!!! Software Update !!!", messageKey: "teaPotUpdate"});
    player.ship.removeEquipment("EQ_TEA_MAKER");
    player.ship.awardEquipment("EQ_TEAPOT");
// clean up old status variable from previous versions...
      {
        if(missionVariables.teaRefill)
          {
            delete missionVariables.teaRefill;
          }
      }
// ...and set new variable
    missionVariables.teaRefill_status = "OK";
// clean up old counter variable from previous versions...
      {
        if(missionVariables.teaRefillCounter)
          {
            delete missionVariables.teaRefillCounter;
          }
      }
// then set new counter variable
    missionVariables.teaRefill_counter = 25;
  }
}
this.playerBoughtEquipment = function(equipment)
// set variables upon purchase
{
  if (equipment == "EQ_TEAPOT")
    {
      missionVariables.teaRefill_status = "OK";
       {
// setup variable (counter) to control refill availability
         if (!missionVariables.teaRefill_counter)
	  {
	    missionVariables.teaRefill_counter = 25;
	  }
        }
    }
// when buying refills reset variable and add 25 'T-pods' to tally
  else if (equipment == "EQ_TEA_REFILL_1" || "EQ_TEA_REFILL_2" || "EQ_TEA_REFILL_3" || "EQ_TEA_REFILL_3")
    {
      missionVariables.teaRefill_status = "OK";
      missionVariables.teaRefill_counter += 25;
    }
}
this.allowAwardEquipment = function(equipment, ship, context)
// condition scripting for 'T-pods' to control availability
{
  if (equipment == "EQ_TEA_REFILL_1" || "EQ_TEA_REFILL_2" || "EQ_TEA_REFILL_3" || "EQ_TEA_REFILL_3")
    {
      if (context == "purchase" && player.ship.equipmentStatus("EQ_TEAPOT") == "EQUIPMENT_OK" && missionVariables.teaRefill_status != "OK")
	{
	  return true;
	}
    }
}
this.activated = function()
{ 
// make un-available if no T-pods left
  if(missionVariables.teaRefill_status === "RUN_OUT")
    {
      player.consoleMessage("Tea Maker un-available - Please re-supply.",5);
      return;
    }
// run teamaker
  if(missionVariables.teaRefill_status != "RUN_OUT")
    {  
      this.boilWaterTimer = new Timer(this, this.$boilWater,1); // timer to boil water
      this.brewTeaTimer = new Timer(this, this.$brewTea,8); // timer to brew tea after 8 seconds
      this.teaReadyTimer = new Timer(this, this.$teaReady,15); // timer to confirm tea is ready
// we count off the 'T-Pods' as they are used
	{
	  missionVariables.teaRefill_counter--;
	}
// ...until we reach 5 left.
      if (missionVariables.teaRefill_counter === 5)
	{
// warn player that only 5 remain - more can now be bought
        player.consoleMessage("After this cup you only have five 'T-pods' left. You can buy some when you next dock.",5);			
        missionVariables.teaRefill_status = "BUYABLE";
        }
// ...then when we reach 1 left.
      if (missionVariables.teaRefill_counter === 0)
	{
// Then require more 'T-Pods', disable Tea Maker, add 'T-Pods' to F3 screen and reset counter.
        player.consoleMessage("This is your last 'T-Pod' - you must buy some more.",5);
        missionVariables.teaRefill_status = "RUN_OUT";

	}
    }
}
this.$boilWater = function()
{
			this.boilSound = new SoundSource; 
			this.boilSound.sound = "boiling.ogg";
			this.boilSound.loop = false;
			this.boilSound.play();
  player.consoleMessage("The water is boiling...",5);
}
this.$brewTea = function()
{
			this.boilSound.stop();
			this.brewSound = new SoundSource; 
			this.brewSound.sound = "brewing.ogg";
			this.brewSound.loop = false;
			this.brewSound.play();
  player.consoleMessage("Your tea is now brewing...",5);
}	
this.$teaReady = function()
{
			this.brewSound.stop();
			this.teaSound = new SoundSource; 
			this.teaSound.sound = "teaSound.ogg";
			this.teaSound.loop = false;
			this.teaSound.play();
  player.consoleMessage("Your tea is now ready. Enjoy!",6);
  this.$teaTimerStop ();
}

this.$teaTimerStop = function()
// stop timers
{
  if(this.boilWaterTimer)
    {
      if (this.boilWaterTimer.isRunning) 
        {
          this.boilWaterTimer.stop();
          delete this.boilWaterTimer;
        }
     }
  if(this.brewTeaTimer)
     {
       if (this.brewTeaTimer.isRunning) 
         {
           this.brewTeaTimer.stop();
           delete this.brewTeaTimer;
         }
     }
  if(this.teaReadyTimer)
     {
       if (this.teaReadyTimer.isRunning) 
         {
           this.teaReadyTimer.stop();
           delete this.teaReadyTimer;
         }
      }
}