Advertisement
Guest User

New command prompt!

a guest
Oct 31st, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.12 KB | None | 0 0
  1. -- Torje's user (user1)
  2. local input = read()
  3. function resetScreen()
  4. term.clear ()
  5. term.setCursorPos ( 1,1 )
  6. end
  7. function keyBoard()
  8. print ( "RUN> ")
  9. end
  10. resetScreen()
  11. -- Commands
  12.  
  13. --[[
  14. Previous command variables
  15.  
  16. local cmd1 = "battleship"
  17. local cmd2 = "chillis"
  18. local cmd3 = "changeInventory"
  19. local cmd4 = "help"
  20. local help = "?"
  21. local cmd5 =
  22. local cmd6 =
  23. local cmd7 =
  24. local cmd8 =
  25. local cmd9 =
  26. local cmd10 =
  27. local cmd11 =
  28. local cmd12 =
  29. local cmd13 =
  30. local cmd14 =
  31. local cmd15 =
  32. local cmd16 =
  33. local cmd17 =
  34. --]]
  35.  
  36. -- New commands variable thanks to Direwolf20! <3
  37.  
  38. local cmds = { "battleship", "chillis", "changeInventory", "help"}
  39.  
  40. -- Command functions
  41. function checkCMD()
  42. keyBoard()
  43. -- Command 1: Battleship host/join
  44. if input = cmds[1] then
  45.   input2 = read ()
  46.   if input2 = "host" then
  47.     shell.run ( "fg battleship host" )
  48.   end
  49.   if input2 = "join" then
  50.     shell.run ( "fg battleship join" )
  51.   end
  52.   if ( input2 ~= "host" ) and ( input2 ~= "join" ) then
  53.     term.setTextColor ( colors.red )
  54.     print ( "Invalid parameters" )
  55.     sleep(1.5)
  56.     shell.run ( "test" )
  57.   end
  58. end
  59.  
  60. -- Command 2: Chilli shower
  61. if input = cmds[2] then
  62.   textutils.slowPrint ( "Chilli shower activated!", 30)
  63.   rs.setOutput ( "back", true )
  64.   sleep(1.5)
  65.   rs.setOutput ( "back", false )
  66.   shell.run ( "test" )
  67. end
  68.  
  69. -- Change inventory between places!
  70. if input = cmds[3] then
  71.   rednet.open ( "left" )
  72.  
  73.   while true do
  74.     term.clear ()
  75.     term.setCursorPos ( 1, 1 )
  76.     term.write ( "Inventory: " )
  77.     command = read ()
  78.     rednet.broadcast ( command )
  79.     while true do
  80.       textutils.slowPrint ( "Press E when done loading/unloading...", 30 )
  81.     local event, key = os.pullEvent ( "key" )
  82.         if key == keys.e then
  83.           rednet.broadcast ( "stop" )
  84.        
  85.           break
  86.         end
  87.       end
  88.     end
  89.   end
  90.  
  91. -- Help program
  92. if input == (cmds[4]) or "?" then
  93.   textutils.slowPrint ( "Command list: " )
  94.   for i = 1, 4 do
  95.     textutils.slowPrint ( cmds[i] )
  96.   end
  97. end
  98. if input ~= (cmds[i]) then
  99. textutils.slowPrint ( "Unrecognized command...", 35 )
  100. end
  101. end -- Function ends here
  102. checkCMD()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement