Advertisement
Guest User

arena

a guest
Apr 18th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.00 KB | None | 0 0
  1. --Areana AI
  2. --Siren
  3. --By Flashing
  4.  
  5. --Declare variables
  6. chatb = peripheral.wrap("top")
  7. gotkit = false
  8. introdone = false
  9. stoploop = true --true means loop, false means stop
  10. range = 10
  11. player = "noplayer"
  12. t = {}
  13.  
  14. function initF()
  15.   print("start")
  16.     chatb.say("Init player 1")
  17.     e,p,m = os.pullEvent("chat")
  18.     if p == "flaashing" then
  19. print(player)
  20.         if string.find(m,"!player1") then
  21.             for k,v in string.gmatch(m, "[^%s]+") do
  22.                 table.insert(t,k)
  23.             end
  24. print("blob")
  25.   print(t[2])
  26.             player = t[2]
  27. print(player)
  28.             initdone = true
  29.         end
  30.     end
  31. end
  32.  
  33.  
  34. --Declare functions
  35. function intro()
  36.             chatb.say("Siren: Welcome to Game Central Station. You are contestant #1",range)   
  37.             sleep(2)   
  38.             chatb.say("Siren: I'm Siren. I am here to help you",range) 
  39.             sleep(3)   
  40.             chatb.say("Siren: To win the match, survive and be the last man standing",range)   
  41.             sleep(3)   
  42.             chatb.say("Siren: You can select 4 classes. Choose carefully",range)   
  43.             sleep(3)   
  44.             chatb.say("Siren: Kit 1 is the Warrior. Equipped with an iron sword and iron armor.",range)
  45.             sleep(3)   
  46.             chatb.say("Siren: Kit 2 is the Ranger. Equipped with a bow and leather armor",range)   
  47.             sleep(3)   
  48.             chatb.say("Siren: Kit 3 is the Mage. Equipped with a magic wand a leather bits.",range)
  49.             sleep(3)   
  50.             chatb.say("Siren: Kit 4 is the Rogue. Equipped with a magic dagger and invisibilty.",range)
  51.             sleep(3)   
  52.             chatb.say("Siren: To choose a kit type !siren kit [number]",range) 
  53.             introdone = true
  54.             print("intro done")
  55. end
  56.  
  57. function getkit(msg)
  58.     while not gotkit do
  59.         event, player, msg = os.pullEvent("chat")
  60.         print("get msg start")
  61.         if msg == "!siren kit 1" then
  62.            rs.setBundledOutput("bottom", colors.white)
  63.            sleep(0.4)
  64.            rs.setBundledOutput("bottom", 0)
  65.            afterkit("1")
  66.         elseif msg == "!siren kit 2" then
  67.            rs.setBundledOutput("bottom", colors.black)
  68.            sleep(0.4)
  69.            rs.setBundledOutput("bottom", 0)
  70.            afterkit("1")
  71.         elseif msg == "!siren kit 3" then
  72.            rs.setBundledOutput("bottom", colors.yellow)
  73.            sleep(0.4)
  74.            rs.setBundledOutput("bottom", 0)
  75.            afterkit("1")
  76.         elseif msg == "!siren kit 4" then
  77.            rs.setBundledOutput("bottom", colors.green)
  78.            sleep(0.4)
  79.            rs.setBundledOutput("bottom", 0)
  80.            afterkit("1")
  81.         else
  82.             print("no kit")
  83.         end
  84.     end
  85. end
  86.  
  87. function afterkit(num)
  88.     print("Got kit" .. num)
  89.     gotkit = true
  90. end
  91.  
  92. function funcRestart()
  93.     if rs.getInput("left",true) then print("Restarting") sleep(2) os.reboot() end
  94. end
  95.  
  96. --Run script
  97. while stoploop do
  98.     if initdone then
  99.         --if booth is triggered then
  100.         if rs.getInput("right", true) then
  101.             --roll the into
  102.             if not introdone then
  103.                 intro()
  104.             end
  105.         end
  106.  
  107.         if introdone and not gotkit then
  108.             getkit()
  109.         elseif gotkit then
  110.             event, player, msg = os.pullEvent("chat")
  111.             if  string.match(msg, "!siren kit") then
  112.                 chatb.say("Siren: You already got your kit!", range)
  113.             end
  114.         end
  115.  
  116.         --check for reset
  117.         funcRestart()
  118.     else
  119.   print("main loop")
  120.   initF()
  121. end
  122.  
  123. sleep(2)
  124. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement