Skip to content

Instantly share code, notes, and snippets.

@UlisseMini
Last active November 7, 2018 20:45
Show Gist options
  • Save UlisseMini/c572cc28b3d784a13b2097f05906e13e to your computer and use it in GitHub Desktop.
Save UlisseMini/c572cc28b3d784a13b2097f05906e13e to your computer and use it in GitHub Desktop.
local a=[[
Usage: ncat <option>
options are:
replay - prompt repeating coms with custom message & sender ids
fuzz - make everyone have a bad time (WIP NOT DONE YET)
listen - just listen and display comunications
]]local b={...}if#b~=1 then print("Usage: ncat <option>")return end;local c=require("math")local d={}local e=65535;local f;local g;local h;local i;local j={}for k,l in ipairs(peripheral.getNames())do if peripheral.getType(l)=="modem"then i=peripheral.wrap(l)end end;if not i then error("Failed to find modem.")end;local function m(n)if type(n)~="table"then return false end;if n.message and type(n.nMessageID)=="number"and not j[n.nMessageID]then return true end;if n.nMessageID==nil then return false end;if type(n.nMessageID)=="number"and not j[n.nMessageID]then return true end;return false end;local function o()while true do local p,p,p,q,n=os.pullEvent("modem_message")if m(n)then return q,n end end end;local function r(s)io.write(s)return io.read()end;function d.fuzz()local t,n=o()end;function d.listen()while true do local e,n=o()print(textutils.serialise(n))end end;function d.replay()while true do local u,n=o()print(textutils.serialise(n))f=r("replay (y/n/q): ")if f=="y"then g=r("New message: ")if g~=""then n.message=g end;h=r("Sender id: ")h=tonumber(h)if not h then print("yeah who cares what they say")h=u end;local v=c.random(1,2147483647)j[v]=true;n.nMessageID=v;i.transmit(e,h,n)print("Sent! (i hope this breaks something :D)")elseif f=="q"then print("cmon we're stopping already.. we were having fun!")error()end end end;if not d[b[1]]then print(a)return end;i.open(e)d[b[1]]()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment