Advertisement
Guest User

WirelessChatv.0.0.2

a guest
Apr 7th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. --Making os.pullEvent the same as os.pullEventRaw,
  2. --allowing to prevent the user from using CTRL+T.
  3. os.pullEvent = os.pullEventRaw
  4.  
  5. --Main part of the program that handles EVERYTHING (Apart from attatching the peripheral :P)
  6. function Main()
  7.   while true do
  8. --Whatever you are typing goes here
  9.     text = io.read()
  10. -------------------------------------------------
  11. --Clear Function
  12.     if (text) == "/clear" then
  13.       sn.send("smartHelmet"," ")
  14.       sn.send("smartHelmet"," ")
  15.       sn.send("smartHelmet"," ")
  16.       sn.send("smartHelmet"," ")
  17.       sn.send("smartHelmet"," ")
  18. -------------------------------------------------      
  19.    elseif (text) == "/help" then
  20.       print("HELP SYSTEM:")
  21.       print("Commands:")
  22.       print("/clear - CURRENTLY clears the OTHER person's text log, being worked on. Soon will clear YOURS, hopefully :3")
  23.       print("/help - Shows this screen")
  24.       print("/changelog - shows the change log of THIS version")
  25. -------------------------------------------------
  26. --The /changelog command for 0.0.2
  27.     elseif (text) == "/changelog" then
  28.       print("+Added the /help command")
  29.       print("+Added the /changelog command")
  30.       print("+Added support for the peripheral being on any side without needing to change any code.")
  31.       print("*Fixed the CTRL+T sending 'Terminated' Bug")
  32. -------------------------------------------------
  33. --Sending the text to the helmet, unless its a command  
  34.   else  
  35.      sn.send("smartHelmet",text)
  36.   end
  37. end
  38. end
  39. -------------------------------------------------
  40. --Detecting the peripheral's side :)
  41. function getSideOfPeripheral()
  42.   for k,v in pairs(rs.getSides()) do
  43.    -- print(v)
  44.     if (peripheral.getType(v)) == "smNetSender" then
  45.       sn = peripheral.wrap(v)
  46.       Main()
  47.     end
  48.   end
  49. end
  50. -------------------------------------------------
  51. --Calling the attatchPeripheral() function, then, if sucsessful, calls the Main() function.
  52. function setup()
  53.   getSideOfPeripheral()
  54. end
  55. setup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement