Advertisement
Guest User

test.lua

a guest
Apr 8th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. local component = require "component"
  2. local cb = component.chat_box
  3. local probe = component.ElnProbe
  4. local event = require "event"
  5. local modem = component.modem
  6. modem.open(1)
  7.  
  8. local function split(inputstr, sep)
  9.   if sep == nil then
  10.     sep = "%s"
  11.   end
  12.   local t={}
  13.   for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  14.     table.insert(t, str)
  15.   end
  16.   return t
  17. end
  18.  
  19. while true do
  20.   local event, uuid, player, message = event.pull("chat_message")
  21.  
  22.   if message:match("^TWMS ") then
  23.     local commands = split(message)
  24.  
  25. print(1,"TWMS_" .. commands[2])
  26.     modem.broadcast(1, "TWMS" .. commands[1])
  27.     os.sleep(0.2)
  28.   end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement