Guest User

DETERMINATION

a guest
Nov 30th, 2015
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.55 KB | None | 0 0
  1. local health = "100"
  2. local ehealth = "100"
  3.  
  4. function eturn()
  5.  local damage = math.random(25,60)
  6.  term.clear()
  7.  term.setCursorPos(2,2)
  8.  print(damage)
  9.  local health = health-damage
  10.  sleep(1)
  11.  turn()
  12. end
  13.  
  14. function atk()
  15.  local damage = math.random(30,50)
  16.  local ehealth = ehealth-damage
  17.  term.setCursorPos(2,2)
  18.  write(damage)
  19.  write("!")
  20.  sleep(3)
  21.  eturn()
  22. end
  23.  
  24. function miss()
  25.  term.setCursorPos(2,2)
  26.  print("Miss!")
  27.  sleep(3)
  28.  eturn()
  29. end
  30.  
  31. function crit()
  32.  local damage = math.random(50,75)
  33.  local ehealth = ehealth-damage
  34.  term.setCursorPos(2,2)
  35.  write(damage)
  36.  write("!")
  37.  sleep(3)
  38.  eturn()
  39. end
  40.  
  41.  
  42. function fight()
  43.  local crit = math.random(1,5)
  44.  if crit == 1 then
  45.   atk()
  46.  elseif crit == 2 then
  47.   atk()
  48.  elseif crit == 3 then
  49.   atk()
  50.  elseif crit == 4 then
  51.   crit()
  52.  elseif crit == 5 then
  53.   miss()
  54.  end
  55. end
  56.  
  57. function turn()
  58.  term.clear()
  59.  term.setCursorPos(2,7)
  60.  write("Health:")
  61.  write(health)
  62.  term.setCursorPos(2,8)
  63.  write("Enemy Health:")
  64.  write(ehealth)
  65.  term.setCursorPos(2,10)
  66.  write("Fight")
  67.  sleep(0.2)
  68.  term.setCursorPos(8,10)
  69.  write("Act")
  70.  sleep(0.2)
  71.  term.setCursorPos(12,10)
  72.  write("Item")
  73.  sleep(0.2)
  74.  term.setCursorPos(17,10)
  75.  write("Mercy")
  76.  sleep(1)
  77.  term.setCursorPos(2,12)
  78.  print("Choose Option (Warning: Case Sensitive)")
  79.  term.setCursorPos(2,13)
  80.  local input = read()
  81.  if input == "Fight" then
  82.   fight()
  83.  elseif input == "Act" then
  84.   act()
  85.  elseif input == "Item" then
  86.   item()
  87.  elseif input == "Mercy" then
  88.   mercy()
  89.  else
  90.   turn()
  91.  end
  92. end
  93.  
  94.  
  95. while true do
  96.  turn()
  97. end
Advertisement
Add Comment
Please, Sign In to add comment