Advertisement
ipadman123

Computercraft RPG

Mar 9th, 2013
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.24 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3.  
  4. print"Welcome to ipadman123's RPG!"
  5. print""
  6. sleep(2)
  7.  
  8. xp = 0
  9. ms = 0
  10. lvl = 1
  11. fs = 0
  12.  
  13. while true do
  14.  
  15. if xp >= 50 then
  16. print"You leveled up!"
  17. sleep(2)
  18. lvl=lvl+1
  19. print("Level: ", lvl)
  20. xp=xp-50
  21. sleep(2)
  22. term.clear()
  23. term.setCursorPos(1,1)
  24. end
  25.  
  26. print"What would you like to do?"
  27. print""
  28. print"Type help for options"
  29.  
  30. choice = read()
  31.  
  32. mine = "mine"
  33. battle = "battle"
  34. help = "help"
  35. fish = "fish"
  36.  
  37. if choice == help then
  38. term.clear()
  39. term.setCursorPos(1,1)
  40. print"The choices are:"
  41. print""
  42. print"mine"
  43. print"battle"
  44. print"help"
  45. print"fish"
  46. print""
  47. end
  48.  
  49. random = math.random(1, 100)
  50.  
  51. if choice == mine then
  52. term.clear()
  53. term.setCursorPos(1,1)
  54. print"You go mining"
  55. sleep(2)
  56. print"You find..."
  57. sleep(2)
  58. if random < 31 then
  59. print"Nothing."
  60. sleep(1)
  61. term.clear()
  62. term.setCursorPos(1,1)
  63. end
  64.  
  65. if random < 51 and random > 30 then
  66. print"Coal!"
  67. sleep(1)
  68. print"Mining skill increased by 1!"
  69. ms=ms+1
  70. sleep(1)
  71. print("Mining skill: ", ms)
  72. sleep(1)
  73. xp=xp+1
  74. print("Total xp: ", xp)
  75. sleep(2)
  76. term.clear()
  77. term.setCursorPos(1,1)
  78. end
  79.  
  80. if random < 66 and random > 50 then
  81. print"Iron!"
  82. sleep(1)
  83. print"Mining skill increased by 3!"
  84. ms=ms+3
  85. sleep(1)
  86. print("Mining skill: ", ms)
  87. sleep(1)
  88. xp=xp+3
  89. print("Total xp: ", xp)
  90. sleep(2)
  91. term.clear()
  92. term.setCursorPos(1,1)
  93. end
  94.  
  95. if random < 81 and random > 65 then
  96. print"Gold!"
  97. sleep(1)
  98. print"Mining skill increased by 5!"
  99. sleep(1)
  100. ms=ms+5
  101. print("Mining skill: ", ms)
  102. sleep(1)
  103. xp=xp+5
  104. print("Total xp: ", xp)
  105. sleep(2)
  106. term.clear()
  107. term.setCursorPos(1,1)
  108. end
  109.  
  110. if random < 91 and random > 80 then
  111. print"Redstone!"
  112. sleep(1)
  113. print"Mining skill increased by 7!"
  114. sleep(1)
  115. ms=ms+7
  116. print("Mining skill: ", ms)
  117. sleep(1)
  118. xp=xp+7
  119. print("Total xp: ", xp)
  120. sleep(2)
  121. term.clear()
  122. term.setCursorPos(1,1)
  123. end
  124.  
  125. if random < 101 and random > 90 then
  126. print"Diamond!"
  127. sleep(1)
  128. print"Mining skill increased by 10!"
  129. sleep(1)
  130. ms=ms+10
  131. print("Mining skill: ", ms)
  132. sleep(1)
  133. xp=xp+10
  134. print("Total xp: ", xp)
  135. sleep(2)
  136. term.clear()
  137. term.setCursorPos(1,1)
  138. end
  139. end
  140.  
  141. if choice == battle then
  142. term.clear()
  143. term.setCursorPos(1,1)
  144. print"You step into the arena"
  145. sleep(2)
  146.  
  147. mob = math.random(1, 5)
  148.  
  149. if mob == 1 then
  150. print"A zombie approaches you!"
  151. mob = "zombie"
  152. end
  153.  
  154. if mob == 2 then
  155. print"A skeleton approaches you!"
  156. mob = "skeleton"
  157. end
  158.  
  159. if mob == 3 then
  160. print"A spider approaches you!"
  161. mob = "spider"
  162. end
  163.  
  164. if mob == 4 then
  165. print"A creeper approaches you!"
  166. mob = "creeper"
  167. end
  168.  
  169. if mob == 5 then
  170. print"A enderman approaches you!"
  171. mob = "enderman"
  172. end
  173.  
  174. x = 1
  175. mhp = 20
  176. php = 20
  177. st = 0
  178. mobheal = 0
  179.  
  180. while x == 1 do
  181. print("Current Health: ", php ,"/20")
  182. print("Enemy Health: ", mhp ,"/20")
  183. print"What do you do?"
  184. sleep(1)
  185. print"(leave, stun, punch, slice, jab, heal)"
  186. action = read()
  187.  
  188. leave = "leave"
  189. slice = "slice"
  190. jab = "jab"
  191. heal = "heal"
  192. punch = "punch"
  193. stun = "stun"
  194.  
  195. if action == leave then
  196. print"You cowardly leave the fight"
  197. print""
  198. sleep(2)
  199. x=x+1
  200. term.clear()
  201. term.setCursorPos(1,1)
  202. end
  203.  
  204. if action == punch then
  205. print("You punch the ", mob," in the face!")
  206. sleep(1)
  207. print("The ", mob ," takes 2 damage!")
  208. sleep(2)
  209. mhp=mhp-2
  210. term.clear()
  211. term.setCursorPos(1,1)
  212. end
  213.  
  214. if action == slice then
  215. print("You slice at the ", mob)
  216. sleep(2)
  217. luck = math.random(1, 2)
  218.  
  219. if luck == 1 then
  220. print"Your slice succeded!"
  221. sleep(1)
  222. print("The ", mob ," takes 5 damage!")
  223. sleep(1)
  224. mhp=mhp-5
  225. print(mob,"'s health: ", mhp)
  226. sleep(2)
  227. term.clear()
  228. term.setCursorPos(1,1)
  229. else
  230. print"Your slice failed!"
  231. sleep(2)
  232. term.clear()
  233. term.setCursorPos(1,1)
  234. end
  235. end
  236.  
  237. if action == jab then
  238. print("You jab at the ", mob)
  239. sleep(2)
  240. luck = math.random(1, 5)
  241.  
  242. if luck == 1 then
  243. print"Your jab succeeded!"
  244. sleep(2)
  245. print("The ", mob ," takes 12 damage!")
  246. sleep(2)
  247. mhp=mhp-12
  248. print(mob,"'s health: ", mhp)
  249. sleep(2)
  250. term.clear()
  251. term.setCursorPos(1,1)
  252. else
  253. print"Your jab failed!"
  254. sleep(2)
  255. term.clear()
  256. term.setCursorPos(1,1)
  257. end
  258. end
  259.  
  260. if action == heal then
  261. print"You attempt to heal yourself!"
  262. sleep(1)
  263.  
  264. if php <= 20 then
  265.  
  266. luck = math.random(1, 8)
  267.  
  268. if luck >= 2 then
  269. print"Your heal is successful!"
  270. sleep(1)
  271. print"You heal 10 points!"
  272. php=php+10
  273. sleep(2)
  274. term.clear()
  275. term.setCursorPos(1,1)
  276.  
  277. if php > 20 then
  278. php = 20
  279. end
  280. else
  281. print"Your heal failed!"
  282. sleep(2)
  283. term.clear()
  284. term.setCursorPos(1,1)
  285. end
  286. end
  287. end
  288.  
  289. if action == stun then
  290. print("You try to stun the ", mob)
  291. sleep(2)
  292. luck = math.random(1, 2)
  293.  
  294.  
  295. if luck == 1 then
  296. print"Your stun succeeded!"
  297. sleep(1)
  298. print("The ", mob ," can't attack for 2 turns!")
  299. sleep(2)
  300. st=st+2
  301. term.clear()
  302. term.setCursorPos(1,1)
  303. else
  304. print"Your stun failed!"
  305. sleep(2)
  306. term.clear()
  307. term.setCursorPos(1,1)
  308. end
  309. end
  310. if mhp <= 0 then
  311. print"You have defeated the enemy!"
  312. sleep(1)
  313. x=x+1
  314. sleep(2)
  315. print"You gain 35 xp!"
  316. xp=xp+35
  317. sleep(1)
  318. print("Current xp: ", xp)
  319. sleep(2)
  320. term.clear()
  321. term.setCursorPos(1,1)
  322. end
  323.  
  324. if mhp <= 5 and st == 0 then
  325. print("The ", mob ," attempts to heal itself!")
  326. sleep(1)
  327. mh = math.random(1, 2)
  328. mobheal=mobheal+1
  329.  
  330. if mh == 1 then
  331. print("The ", mob ," successfully healed itself!")
  332. sleep(1)
  333. print"It heals 5 points!"
  334. mhp=mhp+5
  335. sleep(2)
  336. term.clear()
  337. term.setCursorPos(1,1)
  338. else
  339. print("The ", mob ," failed to heal itself!")
  340. sleep(2)
  341. term.clear()
  342. term.setCursorPos(1,1)
  343. end
  344. end
  345.  
  346.  
  347. if x == 1 and st == 0 and mobheal == 0 then
  348. dmg = math.random(1, 4)
  349. print("The ", mob ," attacks!")
  350. sleep(1)
  351.  
  352. if dmg == 1 then
  353. print"The attack deals 3 damage!"
  354. sleep(1)
  355. php=php-3
  356. sleep(2)
  357. term.clear()
  358. term.setCursorPos(1,1)
  359. end
  360.  
  361. if dmg == 2 then
  362. print"The attack deals 4 damage!"
  363. sleep(1)
  364. php=php-4
  365. sleep(2)
  366. term.clear()
  367. term.setCursorPos(1,1)
  368. end
  369.  
  370. if dmg == 3 then
  371. print"The attack deals 5 damage!"
  372. sleep(1)
  373. php=php-5
  374. sleep(2)
  375. term.clear()
  376. term.setCursorPos(1,1)
  377. end
  378.  
  379. if dmg == 4 then
  380. print("The ", mob, "'s attack misses!")
  381. sleep(2)
  382. term.clear()
  383. term.setCursorPos(1,1)
  384. end
  385. end
  386.  
  387. if st > 0 then
  388. st=st-1
  389. end
  390.  
  391. if mobheal > 0 then
  392. mobheal=mobheal-1
  393. end
  394.  
  395. if php <= 0 then
  396. term.clear()
  397. term.setCursorPos(1,1)
  398. print"You have lost the battle!"
  399. sleep(2)
  400. x=x+1
  401. term.clear()
  402. term.setCursorPos(1,1)
  403. end
  404. end
  405. end
  406.  
  407.  
  408.  
  409. if choice == fish then
  410. term.clear()
  411. term.setCursorPos(1,1)
  412. print"You go Fishing"
  413. sleep(2)
  414. print"You catch..."
  415. sleep(2)
  416. if random < 31 then
  417. print"Nothing."
  418. sleep(1)
  419. term.clear()
  420. term.setCursorPos(1,1)
  421. end
  422.  
  423. if random < 51 and random > 30 then
  424. print"Flounder!"
  425. sleep(1)
  426. print"Fishing skill increased by 1!"
  427. fs=fs+1
  428. sleep(1)
  429. print("Fishing skill: ", fs)
  430. sleep(1)
  431. xp=xp+1
  432. print("Total xp: ", xp)
  433. sleep(2)
  434. term.clear()
  435. term.setCursorPos(1,1)
  436. end
  437.  
  438. if random < 66 and random > 50 then
  439. print"Cod!"
  440. sleep(1)
  441. print"Fishing skill increased by 3!"
  442. fs=fs+3
  443. sleep(1)
  444. print("Fishing skill: ", fs)
  445. sleep(1)
  446. xp=xp+3
  447. print("Total xp: ", xp)
  448. sleep(2)
  449. term.clear()
  450. term.setCursorPos(1,1)
  451. end
  452.  
  453. if random < 81 and random > 65 then
  454. print"Bass!"
  455. sleep(1)
  456. print"Fishing skill increased by 5!"
  457. sleep(1)
  458. fs=fs+5
  459. print("Fishing skill: ", fs)
  460. sleep(1)
  461. xp=xp+5
  462. print("Total xp: ", xp)
  463. sleep(2)
  464. term.clear()
  465. term.setCursorPos(1,1)
  466. end
  467.  
  468. if random < 91 and random > 80 then
  469. print"Salmon!"
  470. sleep(1)
  471. print"Fishing skill increased by 7!"
  472. sleep(1)
  473. fs=fs+7
  474. print("Fishing skill: ", fs)
  475. sleep(1)
  476. xp=xp+7
  477. print("Total xp: ", xp)
  478. sleep(2)
  479. term.clear()
  480. term.setCursorPos(1,1)
  481. end
  482.  
  483. if random < 101 and random > 90 then
  484. print"Marlin!"
  485. sleep(1)
  486. print"Fishing skill increased by 10!"
  487. sleep(1)
  488. fs=fs+10
  489. print("Fishing skill: ", fs)
  490. sleep(1)
  491. xp=xp+10
  492. print("Total xp: ", xp)
  493. sleep(2)
  494. term.clear()
  495. term.setCursorPos(1,1)
  496. end
  497. end
  498. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement