SHOW:
|
|
- or go back to the newest paste.
1 | - | print("Welcome to the TerraInc Network Stress-Testing Utility.") |
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 | - | print("") |
2 | + | local modem = peripheral.find "modem" |
3 | - | print("Note: This product is paid software, you are free to make copies for your own use, as well as modify your own copies, but distribution is not allowed without express, written permission by the copyright holder.") |
3 | + | |
4 | - | print("") |
4 | + | local function prompt(question, default, conversion) |
5 | - | print("Supplemental Note: This product is only licensed for use against your own systems.") |
5 | + | local text = question |
6 | - | print("Press any key and/or press enter to continue.") |
6 | + | if default then text = text .. " (" .. tostring(default) .. ")" end |
7 | - | read() |
7 | + | text = text .. ": " |
8 | - | term.clear() |
8 | + | while true do |
9 | - | term.setCursorPos(1,1) |
9 | + | write(text) |
10 | local input = read() | |
11 | - | function calc() |
11 | + | if input == "" then return default end |
12 | - | msg = math.random(1000000000) |
12 | + | if conversion then |
13 | local value = conversion(input) | |
14 | if value == nil then printError("Failed to parse input.") end | |
15 | - | function target() |
15 | + | return value |
16 | - | term.clear() |
16 | + | else |
17 | - | term.setCursorPos(1,1) |
17 | + | return input |
18 | - | print("Target Channel/ID:") |
18 | + | end |
19 | - | local channel = read() |
19 | + | end |
20 | - | local channel2 = tonumber(channel) |
20 | + | |
21 | - | tonumber(channel) |
21 | + | |
22 | - | sleep(1) |
22 | + | local channel = prompt("Select channel", rednet.CHANNEL_BROADCAST, tonumber) |
23 | - | term.clear() |
23 | + | local reply_channel = prompt("Select reply channel", rednet.CHANNEL_BROADCAST, tonumber) |
24 | - | term.setCursorPos(1,1) |
24 | + | local message = prompt("Input thing to send (random numbers)") |
25 | - | print("Reply Channel:") |
25 | + | |
26 | - | local reply = read() |
26 | + | while true do |
27 | - | local reply2 = tonumber(reply) |
27 | + | local to_send = message or math.random(0, 0xFFFFFFF) |
28 | - | tonumber(reply) |
28 | + | modem.transmit(channel, reply_channel, to_send) |
29 | sleep() | |
30 | end |