Advertisement
Agent_Silence

Demo

Sep 3rd, 2015
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.74 KB | None | 0 0
  1.  
  2. local function centerPrint(text,yPos)
  3.         w, h = term.getSize()
  4.     term.setCursorPos(math.floor(w - #text)/2, yPos)
  5.         term.write(text)
  6. end
  7.  
  8. local function slowcenterPrint(text,yPos,speed)
  9.         w, h = term.getSize()
  10.     term.setCursorPos(math.floor(w - #text)/2, yPos)
  11.         textutils.slowWrite(text,speed)
  12. end
  13.  
  14. term.setBackgroundColor(colors.white)
  15. term.setTextColor(colors.black)
  16. term.clear()
  17. os.pullEvent()
  18. slowcenterPrint("Hello",3,20)
  19. slowcenterPrint("This is the Mimic terminal",4,100)
  20. term.setTextColor(colors.red)
  21. centerPrint("Press any key to continue", 14)
  22. os.pullEvent()
  23. term.setBackgroundColor(colors.white)
  24. term.setTextColor(colors.black)
  25. term.clear()
  26. centerPrint("This is a demo of what the Mimic terminal",3)
  27. centerPrint("can do",4)
  28. sleep(0.4)
  29. term.setTextColor(colors.red)
  30. centerPrint("Press any key to continue", 14)
  31. os.pullEvent()
  32. term.setBackgroundColor(colors.white)
  33. term.setTextColor(colors.black)
  34. term.clear()
  35. centerPrint("To start off,",3)
  36. centerPrint("Mimic is a programmable website",4)
  37. centerPrint("that uses the coding language Lua",5)
  38. -- Copy this
  39. sleep(0.4)
  40. term.setTextColor(colors.red)
  41. centerPrint("Press any key to continue", 14)
  42. os.pullEvent()
  43. term.setBackgroundColor(colors.white)
  44. term.setTextColor(colors.black)
  45. term.clear()
  46. -- Copy this
  47. centerPrint("In Mimic, you can do things like change",3)
  48. term.setTextColor(colors.blue)
  49. centerPrint("the color of text",4)
  50. term.setTextColor(colors.black)
  51. centerPrint("You can also change",5)
  52. term.setBackgroundColor(colors.lime)
  53. centerPrint("the color of the background",6)
  54. sleep(0.4)
  55. term.setTextColor(colors.red)
  56. term.setBackgroundColor(colors.white)
  57. centerPrint("Press any key to continue", 14)
  58. os.pullEvent()
  59. term.setBackgroundColor(colors.white)
  60. term.setTextColor(colors.black)
  61. term.clear()
  62. centerPrint("You can also do complex mathematical functions",3)
  63. centerPrint("such as sine, cosine, and tangent",4)
  64. sleep(0.4)
  65. term.setTextColor(colors.red)
  66. term.setBackgroundColor(colors.white)
  67. centerPrint("Press any key to continue", 14)
  68. os.pullEvent()
  69. term.setBackgroundColor(colors.white)
  70. term.setTextColor(colors.black)
  71. term.clear()
  72. centerPrint("There are 5 values in Lua",3)
  73. centerPrint("Booleans, Strings, Numbers, Tables and Functions",4)
  74. centerPrint("A boolean is a true or false value",6)
  75. centerPrint("A string is a text value",8)
  76. centerPrint("A number is well a number value",10)
  77. centerPrint("A table is a set of values",12)
  78. centerPrint("A function is a keyword that runs code",14)
  79. sleep(0.4)
  80. term.setTextColor(colors.red)
  81. term.setBackgroundColor(colors.white)
  82. centerPrint("Press any key to continue", 17)
  83. os.pullEvent()
  84. term.setBackgroundColor(colors.white)
  85. term.setTextColor(colors.black)
  86. term.clear()
  87. centerPrint("Lets start off with some vocabulary",2)
  88. centerPrint("library : a large table filled with functions",4)
  89. centerPrint("Typically, a library is called an API",5)
  90. centerPrint("execute : to run one or more lines of code",7)
  91. centerPrint("arguments/parameters : info given to a function",9)
  92. centerPrint("Say you wanted a computer to write something",10)
  93. centerPrint("You would have to tell it what to write",11)
  94. centerPrint("That is what an argument or parameter is",12)
  95. centerPrint("It is commonly abbreviated as arg/param",13)
  96. sleep(0.4)
  97. term.setTextColor(colors.red)
  98. term.setBackgroundColor(colors.white)
  99. centerPrint("Press any key to continue", 15)
  100. os.pullEvent()
  101. term.setBackgroundColor(colors.white)
  102. term.setTextColor(colors.black)
  103. term.clear()
  104. centerPrint("This isn't a full lesson",3)
  105. centerPrint("Rather, it is a demonstration",4)
  106. centerPrint("So I will just get on with the demonstration",5)
  107. centerPrint("of what Mimic can do",6)
  108. sleep(0.4)
  109. term.setTextColor(colors.red)
  110. term.setBackgroundColor(colors.white)
  111. centerPrint("Press any key to continue", 15)
  112. os.pullEvent()
  113. term.setBackgroundColor(colors.white)
  114. term.setTextColor(colors.black)
  115. term.clear()
  116. paintutils.drawLine(2,3,50,3,colors.lightGray)
  117. term.setCursorPos(2,3)
  118. term.setTextColor(colors.black)
  119. term.setCursorPos(2,3)
  120. local text = read()
  121. repeat
  122.   term.setCursorPos(math.random(1,51-#text),math.random(1,19))
  123.   term.setBackgroundColor(2^math.random(1,15))
  124.   term.setTextColor(2^math.random(1,15))
  125.   term.write(text)
  126.   os.startTimer(0.1)
  127.   local event = os.pullEvent()
  128. until event ~= "timer"
  129. term.setBackgroundColor(colors.white)
  130. term.clear()
  131. term.setCursorPos(1,1)
  132. -- Rain prog starts here
  133. sleep(0.3)
  134. local rain = {}
  135. local maxX, maxY = term.getSize()
  136. function newrain()
  137.   local axis = math.random(1,2) == 1 and true or false
  138.   local template = {
  139.   x = axis == true and math.random(1,maxX) or maxX,
  140.   y = axis == false and math.random(1,maxY) or 1,
  141.   color = colors.blue,
  142.   velo = math.random(1,4) == 4 and 2 or 1
  143.   }
  144.   table.insert(rain,template)
  145. end
  146.  
  147. function redraw(bool)
  148.   term.setBackgroundColor(bool == true and colors.white or colors.black)
  149.   term.clear()
  150.   for i,v in ipairs(rain) do
  151.     term.setCursorPos(v.x,v.y)
  152.     term.setTextColor(v.color)
  153.     term.write("/")
  154.     v.x = v.x - v.velo
  155.     v.y = v.y + v.velo
  156.     if v.y > maxX or v.x < 1 then
  157.       table.remove(rain,i)
  158.     end
  159.   end
  160. end
  161.  
  162. local boolean
  163. local light = 0
  164. repeat
  165.     for i=1,3 do
  166.         newrain()
  167.     end
  168.     if boolean == true then
  169.         light = light + 1
  170.         if light == 5 then -- Display lightning for 5 ticks
  171.             boolean = false
  172.             light = 0
  173.         end
  174.     else
  175.         boolean = math.random(1,100) == 1 and true or false -- If the number 1 gets chosen, it sets "boolean" to true
  176.         if boolean == true and commands then
  177.             commands.exec("playsound ambient.weather.thunder"..math.random(1,3).." @p")
  178.         end
  179.     end
  180.     redraw(boolean)
  181.     os.startTimer(0.01)
  182.     if commands then
  183.         commands.exec("playsound ambient.weather.rain @p")
  184.     end
  185.     local event = os.pullEvent()
  186. until event ~= "timer"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement