1
0

story.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. var Story = function(player, messager) {
  2. var tickEvents = [ {
  3. "tickvalue" : 1,
  4. "eventcall" : "blank"
  5. }, {
  6. "tickvalue" : 30,
  7. "eventcall" : "greet1"
  8. }, {
  9. "tickvalue" : 38,
  10. "eventcall" : "greet2"
  11. }, {
  12. "tickvalue" : 45,
  13. "eventcall" : "greet3"
  14. }, {
  15. "tickvalue" : 48,
  16. "eventcall" : "greet4"
  17. } ];
  18. this.update = function() {
  19. var ticks = Math.floor((new Date().getTime() - player.getData('started')) / 1000) || 0;
  20. for ( var index in tickEvents) {
  21. var event = tickEvents[index];
  22. if (event.tickvalue == ticks) {
  23. var eventcall = this[event.eventcall];
  24. eventcall();
  25. }
  26. }
  27. };
  28. this.blank = function() {
  29. document.getElementById("travel").style.visibility = "hidden";
  30. };
  31. this.greet1 = function() {
  32. messager.transmission("Transmission: Hello, is anyone there?");
  33. };
  34. this.greet2 = function() {
  35. messager.transmission(
  36. "Transmission: You seem to be having a bit of trouble.");
  37. };
  38. this.greet4 = function() {
  39. messager.transmission(
  40. "Transmission: There's a station not too far from you.");
  41. document.getElementById("travel").style.visibility = "visible";
  42. };
  43. this.greet3 = function() {
  44. messager.transmission(
  45. "Transmission: You'll have to repair and fuel up, but");
  46. };
  47. };
  48. var story = new Story(player, messager);