lost_RD

ComputerCraft basic commands Simplified

Apr 25th, 2015
667
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.99 KB | None | 0 0
  1. -- Credit to Pepijn96 for the original scripts, I just compiled them into one
  2.  
  3. -- Requirements:
  4. -- Rain Detector
  5. -- Daylight sensor
  6. -- Bundled Cable
  7. -- Insulated wire (different colors, minimum is 3)
  8.  
  9. c = peripheral.wrap("left") -- This wraps the chatbox, change variable and side to whatever you use.
  10. s = peripheral.wrap("right") -- This wraps the speaker, change variable and side to whatever you use.
  11. range = 100000
  12. lang = "en"
  13. name = "Jacklin" -- Name/Prefix used for the chat messages, if it doesn't work check your config!
  14.  
  15. events = {}
  16.  
  17. -- Config
  18. events[".weather"] = function() -- Command to get weather data, requires daylight sensor and rain detector
  19.   if redstone.testBundledInput("back",rainDetector) then -- Change side to wherever the bundled cable with the rain detector is located. Note that this expects a positive output when it's raining.
  20.    c.say("It's raining, how depressing :(",range,false,name)
  21.    s.speak("It's raining, how depressing :(",range,lang)
  22.   elseif redstone.testBundledInput("back",dayLightDetector) then
  23.    c.say("The sun is shining :)!",range,false,name)
  24.    s.speak("The sun is shining :)!",range,lang)
  25.   else
  26.    c.say("The skies are clear!",range,false,name)
  27.    s.speak("The skies are clear!",range,lang)
  28.   end
  29. end
  30.  
  31. events[".output1 on"] = function() -- Command to enable a redstone output. Change the command to whatever you enable.
  32.   redstone.setBundledOutput("back",colors.combine(redstone.getBundledOutput("back"),output1))
  33.   c.say("Output 1 Enabled!",range,false,name) -- Change message to whatever
  34.   s.speak("Output 1 Enabled!",range,lang)
  35. end
  36.  
  37. events[".output1 off"] = function() -- Command to disable a redstone output.
  38.   redstone.setBundledOutput("back",colors.subtract(redstone.getBundledOutput("back"),output1))
  39.   c.say("Output 1 Disabled!",range,false,name) -- Change message to whatever
  40.   s.speak("Output 1 Disabled!",range,lang)
  41. end
  42.  
  43. events[".time"] = function() -- for giving the time in your minecraft world
  44.   local time = os.time()
  45.   local formattedTime = textutils.formatTime(time, false) -- This is to convert the time into something that makes more sense
  46.   c.say("It is "..formattedTime,range,false,name)
  47.   s.speak("It is "..formattedTime,range,lang)
  48. end
  49.  
  50. events[".played"] = function() -- for giving the amount of ingame days you have played in your world
  51.   day = os.day()
  52.    if day == 1 then
  53.     c.say("You have only been playing for 1 day and you already made me. Good job!",range,false,name)
  54.     s.speak("You have only been playing for 1 day and you already made me. Good job!",range,lang)
  55.    elseif day == 7 then
  56.     c.say("You have been playing for 1 week now!",range,false,name)
  57.     s.speak("You have been playing for 1 week now!",range,false,name)
  58.    elseif day == 365 then
  59.     c.say("You have been playing for 1 year?! You are truly amazing!",range,false,name)
  60.     s.speak("You have been playing for 1 year?! You are truly amazing!",range,false,name)
  61.    else
  62.     c.say("You have been playing for "..day.." days",range,false,name)
  63.     s.speak("You have been playing for "..day.." days",range,lang)
  64.    end
  65. end
  66.  
  67. events[".exit"] = function() -- Not really necessary, this will terminate the main loop. Can be useful if you wish to terminate the program from a distance.
  68.   c.say("Shutting Down",range,false,name)
  69.   s.speak("Shutting Down",range,lang)
  70.   do return end
  71. end
  72.  
  73. events[".trigger"] = function() -- Listens for a trigger then for a response as separate messages and saves them to temporary memory
  74.   local e1,player1,msg1 = os.pullEvent("chat")
  75.   local e2,player2,msg2 = os.pullEvent("chat")
  76.   events[msg1] = function()
  77.    c.say(msg2,range,false,name)
  78.    s.speak(msg2,range,lang)
  79.   end
  80. end
  81.  
  82. -- Create more output commands when needed
  83. rainDetector = colors.white -- Check http://computercraft.info/wiki/Colors_%28API%29 for the name of each color
  84. dayLightDetector = colors.orange
  85. ouput1 = colors.magenta
  86.  
  87. while true do
  88.  
  89.  e,player,msg = os.pullEvent("chat")
  90.  
  91.  local f = events[msg] and events[msg] or function() end
  92.  f()
  93.  
  94. end
Advertisement
Add Comment
Please, Sign In to add comment