Advertisement
osmarks

terra-useless-thing-clone

Dec 29th, 2019
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. print([[Welcome to the GTech Network Stress-Testing Utility, which hopefully does not contain much code at all from the evil Terrariolan one.]])
  2. local modem = peripheral.find "modem"
  3.  
  4. local function prompt(question, default, conversion)
  5.     local text = question
  6.     if default then text = text .. " (" .. tostring(default) .. ")" end
  7.     text = text .. ": "
  8.     while true do
  9.         write(text)
  10.         local input = read()
  11.         if input == "" then return default end
  12.         if conversion then
  13.             local value = conversion(input)
  14.             if value == nil then printError("Failed to parse input.") end
  15.             return value
  16.         else
  17.             return input
  18.         end
  19.     end
  20. end
  21.  
  22. local channel = prompt("Select channel", rednet.CHANNEL_BROADCAST, tonumber)
  23. local reply_channel = prompt("Select reply channel", rednet.CHANNEL_BROADCAST, tonumber)
  24. local message = prompt("Input thing to send (random numbers)")
  25.  
  26. while true do
  27.     local to_send = message or math.random(0, 0xFFFFFFF)
  28.     modem.transmit(channel, reply_channel, to_send)
  29.     sleep()
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement