Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.38 KB | None | 0 0
  1. //#CLIENTSIDE
  2.  
  3. // The Characters Present in the Game
  4. function onCreated(){
  5. this.a = {"A","B","C","D","E","F","G","H","I","J","K",
  6. "L","M","N","O","P","Q","R","S","T","U","V",
  7. "W","X","Y","Z","1","2","3","4","5","6","7",
  8. "8","9","0"};
  9. this.td = 1;
  10. }
  11.  
  12. // Activation of the Game
  13. function onPlayerChats(){
  14. if(player.chat == "/speedtyper"){
  15. if(!(SpeedTyper_Window.visible)){
  16. Open_Game();
  17. player.chat = "";
  18. }
  19. }
  20. }
  21.  
  22. // The Start Menu
  23. function Open_Game(){
  24. Instructions_Window.hide();
  25. Difficulty_Window.hide();
  26. new GuiWindowCtrl("SpeedTyper_Window"){
  27. profile = GuiBlueWindowProfile;
  28. x = GraalControl.width / 2.35;
  29. y = GraalControl.height / 2.5;
  30. width = 200;
  31. height = 270;
  32. text = "SpeedTyper";
  33. canclose = false;
  34. canmove = true;
  35. destroyonhide = true;
  36. canresize = false;
  37. canmaximize = false;
  38. canminimize = false;
  39.  
  40. new GuiScrollCtrl("Instructions"){
  41. profile = GuiBlueScrollProfile;
  42. x = 15;
  43. y = 30;
  44. width = 170;
  45. height = 130;
  46. hScrollBar = "alwaysOff";
  47. vScrollBar = "dynamic";
  48.  
  49. new GuiMLTextCtrl("Ins_Writing"){
  50. profile = GuiBlueMLTextProfile;
  51. x = 0;
  52. y = 0;
  53. width = 165;
  54. height = 20;
  55. text = "<just:center><b><i><font size=24>SpeedTyper</font></i></b>" NL""NL "<just:center><font size=14><b>Do you think your fingers are fast enough? Start the game to find out!</b></font>" NL "" NL "<just:center><font size=14><i>Scripted By: Kavan<i></font>";
  56. }
  57. }
  58. new GuiButtonCtrl("Start_Button"){
  59. profile = GuiBlueButtonProfile;
  60. x = 15;
  61. y = 165;
  62. width = 170;
  63. height = 20;
  64. text = "Start Game";
  65. }
  66. new GuiButtonCtrl("Instructions_Button"){
  67. profile = GuiBlueButtonProfile;
  68. x = 15;
  69. y = 189;
  70. width = 170;
  71. height = 20;
  72. text = "Instructions";
  73. }
  74. new GuiButtonCtrl("Difficulty_Button"){
  75. profile = GuiBlueButtonProfile;
  76. x = 15;
  77. y = 213;
  78. width = 170;
  79. height = 20;
  80. text = "Difficulty Settings";
  81. }
  82. new GuiButtonCtrl("Quit_Button"){
  83. profile = GuiBlueButtonProfile;
  84. x = 15;
  85. y = 237;
  86. width = 170;
  87. height = 20;
  88. text = "Quit Game";
  89. }
  90. }
  91. }
  92. function Start_Button.onAction(){
  93. if(!(Game_Window.visible)){
  94. this.score = 0;
  95. Start_Game();
  96. }
  97. }
  98. function Instructions_Button.onAction(){
  99. if(!(Instructions_Window.visible)){
  100. Open_Instructions();
  101. }
  102. }
  103. function Difficulty_Button.onAction(){
  104. if(!(Difficulty_Window.visible)){
  105. Open_Difficulty();
  106. }
  107. }
  108. function Quit_Button.onAction(){
  109. SpeedTyper_Window.hide();
  110. }
  111.  
  112. // The Instructions Menu
  113. function Open_Instructions(){
  114. SpeedTyper_Window.hide();
  115. new GuiWindowCtrl("Instructions_Window"){
  116. profile = GuiBlueWindowProfile;
  117. x = GraalControl.width / 2.35;
  118. y = GraalControl.height / 2.5;
  119. width = 200;
  120. height = 270;
  121. text = "Instructions";
  122. canclose = true;
  123. canmove = true;
  124. destroyonhide = true;
  125. canresize = false;
  126. canmaximize = false;
  127. canminimize = false;
  128.  
  129. new GuiScrollCtrl("Border"){
  130. profile = GuiBlueScrollProfile;
  131. x = 15;
  132. y = 30;
  133. width = 170;
  134. height = 200;
  135. hScrollBar = "alwaysOff";
  136. vScrollBar = "dynamic";
  137.  
  138. new GuiMLTextCtrl("Words"){
  139. profile = GuiBlueMLTextProfile;
  140. x = 0;
  141. y = 0;
  142. width = 150;
  143. height = 20;
  144. text = "<just:center><b><i><font size=24>Instructions</font></i></b>" NL""NL "<just:center><font size=14><b>-When the game starts, you must enter the symbols displayed in the box into the text box below it, inside the time limit." NL""NL "-Once you have entered it in, press Enter to confirm." NL""NL "-For each round passed, you gain 1 point." NL""NL "-If you do not enter the symbols into the text box in time, the game is over." NL "" NL "<i>~Good luck!~</i></b></font>";
  145. }
  146. }
  147. new GuiButtonCtrl("Back_Button"){
  148. profile = GuiBlueButtonProfile;
  149. x = 15;
  150. y = 237;
  151. width = 170;
  152. height = 20;
  153. text = "Back";
  154. }
  155. }
  156. }
  157. function Back_Button.onAction(){
  158. if(!(SpeedTyper_Window.visible)){
  159. Open_Game();
  160. }
  161. }
  162.  
  163. // The Difficulty Menu
  164. function Open_Difficulty(){
  165. SpeedTyper_Window.hide();
  166. new GuiWindowCtrl("Difficulty_Window"){
  167. profile = GuiBlueWindowProfile;
  168. x = GraalControl.width / 2.35;
  169. y = GraalControl.height / 2.5;
  170. width = 200;
  171. height = 270;
  172. text = "Difficulty";
  173. canclose = false;
  174. canmove = true;
  175. destroyonhide = true;
  176. canresize = false;
  177. canmaximize = false;
  178. canminimize = false;
  179.  
  180. new GuiScrollCtrl("Diff_Encase"){
  181. profile = GuiBlueScrollProfile;
  182. x = 15;
  183. y = 30;
  184. width = 170;
  185. height = 100;
  186. hScrollBar = "alwaysOff";
  187. vScrollBar = "dynamic";
  188.  
  189. new GuiMLTextCtrl("Diff_Teller"){
  190. profile = GuiBlueMLTextProfile;
  191. x = 0;
  192. y = 0;
  193. width = 150;
  194. height = 20;
  195. text = "<just:center><font size=24><b><i>Difficulty</i></b></font>" NL""NL "<just:center><font size=14><b>Difficulty: Easy</b></font>";
  196. }
  197. new GuiMLTextCtrl("Diff_Description"){
  198. profile = GuiBlueMLTextProfile;
  199. x = 0;
  200. y = 65;
  201. width = 150;
  202. height = 20;
  203. text = "<just:center><font size=14><i>For those who are uncomfortable with the keyboard layout.</i></font>";
  204. }
  205. }
  206. new GuiButtonCtrl("Easy"){
  207. profile = GuiBlueButtonProfile;
  208. x = 15;
  209. y = 135;
  210. width = 170;
  211. height = 20;
  212. text = "Easy";
  213. }
  214. new GuiButtonCtrl("Regular"){
  215. profile = GuiBlueButtonProfile;
  216. x = 15;
  217. y = 159;
  218. width = 170;
  219. height = 20;
  220. text = "Regular";
  221. }
  222. new GuiButtonCtrl("Hard"){
  223. profile = GuiBlueButtonProfile;
  224. x = 15;
  225. y = 183;
  226. width = 170;
  227. height = 20;
  228. text = "Hard";
  229. }
  230. new GuiButtonCtrl("Extreme"){
  231. profile = GuiBlueButtonProfile;
  232. x = 15;
  233. y = 207;
  234. width = 170;
  235. height = 20;
  236. text = "Extreme";
  237. }
  238. new GuiButtonCtrl("Return_Button"){
  239. profile = GuiBlueButtonProfile;
  240. x = 15;
  241. y = 237;
  242. width = 170;
  243. height = 20;
  244. text = "Back";
  245. }
  246. }
  247. Assign();
  248. }
  249. // Assigned on Opening
  250. function Assign(){
  251. if(this.td == 2){
  252. Easy();
  253. }
  254. if(this.td == 1){
  255. Regular();
  256. }
  257. if(this.td == 0.5){
  258. Hard();
  259. }
  260. if(this.td == 0.3){
  261. Extreme();
  262. }
  263. }
  264. // Assignments on Buttons Pressed
  265. function Easy.onAction(){
  266. this.td = 2;
  267. Easy();
  268. }
  269. function Regular.onAction(){
  270. this.td = 1;
  271. Regular();
  272. }
  273. function Hard.onAction(){
  274. this.td = 0.5;
  275. Hard();
  276. }
  277. function Extreme.onAction(){
  278. this.td = 0.3;
  279. Extreme();
  280. }
  281. // Descriptions
  282. function Easy(){
  283. Diff_Teller.settext("<just:center><font size=24><b><i>Difficulty</i></b></font>" NL""NL "<just:center><font size=14><b>Difficulty: Easy</b></font>");
  284. Diff_Description.settext("<just:center><font size=14><i>For those who are uncomfortable with the keyboard layout.</i></font>");
  285. }
  286. function Regular(){
  287. Diff_Teller.settext("<just:center><font size=24><b><i>Difficulty</i></b></font>" NL""NL "<just:center><font size=14><b>Difficulty: Regular</b></font>");
  288. Diff_Description.settext("<just:center><font size=14><i>For those who know the keyboard layout fairly well and can type fluently.</i></font>");
  289. }
  290. function Hard(){
  291. Diff_Teller.settext("<just:center><font size=24><b><i>Difficulty</i></b></font>" NL""NL "<just:center><font size=14><b>Difficulty: Hard</b></font>");
  292. Diff_Description.settext("<just:center><font size=14><i>For those who want a typing challenge and arthritic fingers by the end of it.</i></font>");
  293. }
  294. function Extreme(){
  295. Diff_Teller.settext("<just:center><font size=24><b><i>Difficulty</i></b></font>" NL""NL "<just:center><font size=14><b>Difficulty: Extreme</b></font>");
  296. Diff_Description.settext("<just:center><font size=14><i>Your fingers will not survive this typing challenge on this difficulty.</i></font>");
  297. }
  298. function Return_Button.onAction(){
  299. if(!(SpeedTyper_Window.visible)){
  300. Open_Game();
  301. }
  302. }
  303.  
  304. // The Game Menu
  305. function Start_Game(){
  306. SpeedTyper_Window.hide();
  307. this.countdown = 3;
  308. new GuiWindowCtrl("Game_Window"){
  309. profile = GuiBlueWindowProfile;
  310. x = GraalControl.width / 2.45;
  311. y = GraalControl.height / 2.5;
  312. width = 250;
  313. height = 225;
  314. text = "SpeedTyper";
  315. canclose = true;
  316. destroyonhide = true;
  317. canmove = true;
  318. canresize = false;
  319. canmaximize = false;
  320. canminimize = false;
  321.  
  322. new GuiTextCtrl("Time_Teller"){
  323. profile = GuiBlueTextProfile;
  324. x = 16;
  325. y = 25;
  326. text = "Time Left:";
  327. }
  328. new GuiProgressCtrl("Time_Bar"){
  329. profile = GuiBlueProgressProfile;
  330. x = 15;
  331. y = 45;
  332. width = 220;
  333. height = 30;
  334. }
  335. new GuiTextCtrl("Symbols_Chosen"){
  336. profile = GuiBlueTextProfile;
  337. x = 16;
  338. y = 80;
  339. text = "Symbols Chosen:";
  340. }
  341. new GuiScrollCtrl("Words_Encasing"){
  342. profile = GuiBlueScrollProfile;
  343. x = 15;
  344. y = 100;
  345. width = 220;
  346. height = 70;
  347. hScrollBar = "alwaysOff";
  348. vScrollBar = "dynamic";
  349.  
  350. new GuiMLTextCtrl("Symbols"){
  351. profile = GuiBlueMLTextProfile;
  352. x = 0;
  353. y = 22;
  354. width = 210;
  355. height = 30;
  356. }
  357. }
  358. new GuiTextCtrl("Your_Symbols"){
  359. profile = GuiBlueTextProfile;
  360. x = 16;
  361. y = 171;
  362. text = "Type symbols here:";
  363. }
  364. new GuiTextEditCtrl("Enter_Symbols"){
  365. profile = GuiBlueTextEditProfile;
  366. x = 15;
  367. y = 190;
  368. width = 220;
  369. height = 20;
  370. }
  371. }
  372. sleep(1);
  373. Start_CountDown();
  374. }
  375.  
  376. // The Functions of the Game
  377. function Start_CountDown(){
  378. Enter_Symbols.text = "";
  379. Time_Bar.progress = 1;
  380. Symbols.settext("<just:center><font size=20><b>Starting in: 3</b></font>");
  381. sleep(1);
  382. Symbols.settext("<just:center><font size=20><b>Starting in: 2</b></font>");
  383. sleep(1);
  384. Symbols.settext("<just:center><font size=20><b>Starting in: 1</b></font>");
  385. sleep(1);
  386. Symbols.settext("<just:center><font size=20><b>Starting!...</b></font>");
  387. sleep(1);
  388. Set_Symbols();
  389. }
  390. function Set_Symbols(){
  391. this.tmode = 1;
  392. this.t = 1;
  393. setTimer(".05");
  394. Symbols.settext("<just:center><font size=20><b>"@this.a[int(random(0,37))]@this.a[int(random(0,37))]@this.a[int(random(0,37))]@this.a[int(random(0,37))]@this.a[int(random(0,37))]@this.a[int(random(0,37))]@this.a[int(random(0,37))]@this.a[int(random(0,37))]@this.a[int(random(0,37))]@this.a[int(random(0,37))]@"</b></font>");
  395. this.sym = Symbols.text;
  396. }
  397. function Confirm_Answer.onAction(){
  398. Reset();
  399. }
  400. function Enter_Symbols.onAction(){
  401. Reset();
  402. }
  403. function Reset(){
  404. if(this.tmode == 1){
  405. this.ans = "<just:center><font size=20><b>"@Enter_Symbols.text@"</b></font>";
  406. if(this.ans.upper() == this.sym){
  407. if(this.td == 2){
  408. this.score ++;
  409. }
  410. if(this.td == 1){
  411. this.score += 2;
  412. }
  413. if(this.td == 0.5){
  414. this.score += 3;
  415. }
  416. if(this.td == 0.3){
  417. this.score += 4;
  418. }
  419. this.tmode = 0;
  420. Symbols.text = "<just:center><font size=20><b>Correct!</b></font>";
  421. sleep(2);
  422. Symbols.settext("<just:center><font size=20><b>Score: "@this.score@"</b></font>");
  423. sleep(2);
  424. Start_CountDown();
  425. }
  426. else {
  427. this.tmode = 2;
  428. Symbols.settext("<just:center><font size=20><b>Incorrect!</b></font>");
  429. sleep(1);
  430. setTimer("0.05");
  431. Symbols.settext(this.sym);
  432. this.tmode = 1;
  433. }
  434. }
  435. }
  436.  
  437. // Time Control
  438. function onTimeout(){
  439. if(this.tmode == 1){
  440. if(this.t != 0){
  441. Time_Bar.progress = this.t;
  442. this.t -= 0.05;
  443. }
  444. else {
  445. this.tmode = 2;
  446. Symbols.settext("<just:center><font size=20><b>Game Over!</b></font>");
  447. Confirm_Answer.hide();
  448. sleep(2);
  449. Symbols.settext("<just:center><font size=20><b>Final Score: "@this.score@"</b></font>");
  450. sleep(2);
  451. Game_Window.hide();
  452. }
  453. }
  454. setTimer(this.td);
  455. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement