Advertisement
Cavitt

Untitled

May 25th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. local config = {
  2.     deposit = true,
  3.     capToDeposit = 400
  4. }
  5.  
  6. local talkState = 1
  7. function onInput(c, msg)
  8.     c:SendYellowMessage(Self.Name(), msg)  
  9.     if(talkState == 0)then -- denied configure earlier
  10.         if(msg == "configure")then
  11.             c:SendOrangeMessage("", "Would you like to configure the script?")  
  12.             talkState = 1
  13.         end
  14.     elseif(talkState == 1)then -- prompted for configure
  15.         if(msg == "yes")then
  16.             c:SendOrangeMessage("", "Do you want the depositer on or off?")  
  17.             talkState = 2
  18.         elseif(msg == "no")then
  19.             c:SendOrangeMessage("", "If you would like to set up the script later, just type 'configure'.")  
  20.             talkState = 0
  21.         else
  22.             c:SendOrangeMessage("", "Please say either 'yes' or 'no'.")  
  23.         end
  24.     elseif(talkState == 2)then -- prompted for configure
  25.         if(msg == "on")then
  26.             print("Depositer: enabled")
  27.             c:SendOrangeMessage("", "At what capacity would you like to deposit?")  
  28.             config.deposit = true
  29.             talkState = 3
  30.         elseif(msg == "off")then
  31.             print("Depositer: disabled")
  32.             c:SendOrangeMessage("", "At what capacity would you like to deposit?")  
  33.             config.deposit = false
  34.             talkState = 3
  35.         else
  36.             c:SendOrangeMessage("", "Please say either 'on' or 'off'.")  
  37.         end
  38.     elseif(talkState == 3)then -- prompted for configure
  39.         if(tonumber(msg))then
  40.             print("Cap to Deposit: " .. msg)
  41.             config.capToDeposit = tonumber(msg)
  42.             c:SendOrangeMessage("", "Configuration complete. Say 'configure' to set the script up again.")
  43.             talkState = 0
  44.         else
  45.             c:SendOrangeMessage("", "Please enter a valid number.")  
  46.         end
  47.     end
  48. end
  49.  
  50. function onClose(c)
  51.     print("%s closed.", c:Name())
  52. end
  53.  
  54. commander = Channel.Open("Console", onInput, onClose)
  55. commander:SendOrangeMessage("", "Would you like to configure the script?")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement