BazZziliuS

NetHack - НетХак

Jul 18th, 2018
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.08 KB | None | 0 0
  1. -- Console Command: nethack_menu  / Консольная команда: nethack_menu
  2. local _,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r={_="Receivers",a="SendToServer",b="AddChangeCallback",c="Create",d="DataChanged",e="DoClick"},{"Entity","Bool","Color","Angle","Bit","Data","Double","Float","Int","Normal","String","Table","Type","UInt","Vector"},{Entity={"UInt"},Bool={"Bit"},Color={"UInt","UInt","UInt","UInt"}},Color(255,255,255),Color(255,128,0),Color(128,255,64),Color(0,255,255),nil,{},{},{},{},{},{},{},{},{},nil local function s(a,...)if g then if j[a]&&!j[a].shown then return end MsgC(...)end end local function t(a,b,g)if g then h[a]=h[a]||1 k[a]={header={name=a,length=b}}end if g then q=a s(a,c,"\n\nStarted ",f,"incoming",c," net message ",e,"\""..a.."\"",c," of length ",d,b..".")else s(a,c,"\nEnded ",f,"incoming",c," net message ",e,"\""..a.."\"",c," of length ",d,b..".\n")q=nil end end local function u(a,b,g)b=b||r if!b then return end if a then i[b]=i[b]||1 l[b]={header={name=b,length=0}}else l[b].header.length=net.BytesWritten()end if a then r=b s(b,c,"\n\nStarted ",f,"outgoing",c," net message ",e,"\""..b.."\"",c,".")else s(r,c,"\nEnded ",f,"outgoing",c," net message ",e,"\""..r.."\"",c," of length ",d,length,c,". Total size: ",d,net.BytesWritten(),c,".\n")r=nil end end local function d(a,b,c)return!!1 end local function v(a,b,...)local g={...}if d(a,b,g)then if k[q]then k[q][#k[q]+1]={type=a,val=b,arg=g[1]}end if#g>0 then s(q,c,"\n\tRead ",f,tostring(a),c," of value ",e,"'"..tostring(b).."'",c," with parameters ",f,"{"..table.concat(g,", ").."}",c,".")else s(q,c,"\n\tRead ",f,tostring(a),c," of value ",e,"'"..tostring(b).."'",c,".")end end end local function d(a,b,c)return!!1 end local function w(a,b,...)local g={...}if d(a,b,g)then if l[r]then l[r][#l[r]+1]={type=a,val=b,arg=g[1]}end if#g>0 then s(r,c,"\n\tWrote ",f,tostring(a),c," of value ",e,"'"..tostring(b).."'",c," with parameters ",f,"{"..table.concat(g,", ").."}",c,".")else s(r,c,"\n\tWrote ",f,tostring(a),c," of value ",e,"'"..tostring(b).."'",c,".")end end end local function c(a,b)local c=tonumber(a)if b=="Float"&&c then return c elseif b=="Int"&&c then return math.floor(c)elseif b=="UInt"&&c then return math.abs(math.floor(c))elseif b=="Entity"then return Entity(a)elseif b=="Bool"then return a=="true"||!1 elseif b=="Angle"then local b=string.Explode("%D+",a,!!1)return Angle(unpack(b))elseif b=="Vector"then local b=string.Explode("%D+",a,!!1)return Vector(unpack(b))elseif b=="Color"then local b=string.Explode("%D+",a,!!1)return Color(unpack(b))end return a end local d,e,f,s,x,y,z={},nil,nil,nil,nil,nil,function()local a=debug.getinfo(net.Start)return(a.source:find"nethack"~=nil)end local function A()if(z()==!!1)then return end for g=1,#a do d[g]=net["Read"..a[g]]net["Read"..a[g]]=function(...)if j[q]&&j[q].sin then return end local h if#m>0 then local i=c(table.remove(m,1),a[g])if i~="NETHACK_NOVALUE"then h=i else if b[a[g]]then x=!!1 h=d[g](...)x=!1 else h=d[g](...)end end else if b[a[g]]then x=!!1 h=d[g](...)x=!1 else h=d[g](...)end end if!x then v(a[g],h,...)end return h end end for g=1,#a do d[g+#a]=net["Write"..a[g]]net["Write"..a[g]]=function(h,...)if r&&j[r]&&j[r].sout then return end if#n>0 then local i=c(table.remove(n,1),a[g])if i~="NETHACK_NOVALUE"then h=i end end if b[a[g]]then y=!!1 d[g+#a](h,...)y=!1 else d[g+#a](h,...)end if!y then w(a[g],h,...)end end end e=net.Incoming function net.Incoming(g,h)local i=net.ReadHeader()local k=util.NetworkIDToString(i)if!k then return end local i=net[_._][k:lower()]if!i then return end g=g-16 if j[k]&&j[k].sin then return end if o[k]then m=table.Copy(o[k])end t(k,g,!!1)i(g,h)t(k,g,!1)m={}end f=net.Start function net.Start(g,h)if j[g]&&j[g].sout then return end if p[g]then n=table.Copy(p[g])end u(!!1,g,h)f(g,h)end s=net[_.a]function net.SendToServer()if j[r]&&j[r].sout then return end n={}u(!1)s()end end local function b()if(z()==!1)then return end for b=1,#a do net["Read"..a[b]]=d[b]end for b=1,#a do net["Write"..a[b]]=d[b+#a]end net.Incoming=e net.Start=f net[_.a]=s end CreateConVar("nethack_enabled",1,FCVAR_UNLOGGED,"Whether nethack should be enabled")cvars[_.b]("nethack_enabled",function(a,c,d)if GetConVarNumber"nethack_enabled"==1 then A()elseif GetConVarNumber"nethack_enabled"==0 then b()end end)if GetConVarNumber"nethack_enabled"==1 then A()end CreateConVar("nethack_print",1,FCVAR_UNLOGGED,"Whether nethack messages should be printed to the console")cvars[_.b]("nethack_print",function(a,b,c)if GetConVarNumber"nethack_print"==1 then g=!!1 elseif GetConVarNumber"nethack_print"==0 then g=!1 end end)if GetConVarNumber"nethack_print"~=0 then g=!!1 end if CLIENT then concommand.Add("nethack_menu",function()local a=vgui[_.c]"DFrame"a:SetTitle"Nethack :: Configuration"a:SetSize(500,300)a:SetVisible(!!1)a:SetDraggable(!!1)a:Center()a:MakePopup()local b=vgui[_.c]("DListView",a)b:SetPos(5,25)b:SetSize(270,270)b:SetMultiSelect(!1)b:AddColumn"Message"local d,e=b:AddColumn"In",b:AddColumn"Out"d:SetFixedWidth(50)e:SetFixedWidth(50)local d,e=table.Copy(h),table.Copy(i)table.Merge(d,e)local e,f=table.GetKeys(d),{}table.sort(e,function(a,b)return a<b end)for a,d in ipairs(e)do f[d]=b:AddLine(d,h[d]||0,i[d]||0)end timer.Destroy"nethack_update"timer[_.c]("nethack_update",1,0,function()if IsValid(a)then local d,e=table.Copy(h),table.Copy(i)table.Merge(d,e)local e=table.GetKeys(d)for d=1,#e do local g=e[d]if IsValid(f[g])then f[g]:SetValue(2,h[g]||0)f[g]:SetValue(3,i[g]||0)else f[g]=b:AddLine(g,h[g]||0,i[g]||0)end end b:SortByColumn(1)end end)local d=vgui[_.c]("DPanel",a)d:SetPos(280,25)d:SetSize(215,270)d:SetBackgroundColor(Color(234,234,234,255))b.OnRowSelected=function(b,e)local f=b:GetLine(e):GetValue(1)d:Clear()local b=vgui[_.c]("DProperties",d)b:SetPos(0,0)b:SetSize(390,230)j[f]=j[f]||{shown=!!1,sin=!1,sout=!1}local e,g=j[f],b:CreateRow("General","Shown?")g:Setup"Boolean"g:SetValue(e.shown)g[_.d]=function(b,f)e.shown=f~=0 end local g=b:CreateRow("General","Suppress in?")g:Setup"Boolean"g:SetValue(e.sin)g[_.d]=function(b,f)e.sin=f~=0 end local g=b:CreateRow("General","Suppress out?")g:Setup"Boolean"g:SetValue(e.sout)g[_.d]=function(b,f)e.sout=f~=0 end local b=vgui[_.c]("DButton",d)b:SetPos(195,230)b:SetSize(20,20)b:SetText"?"b[_.e]=function()local b=vgui[_.c]"DFrame"b:SetTitle"Nethack :: Help"b:SetSize(500,300)b:SetVisible(!!1)b:SetDraggable(!!1)b:MakePopup()local e,f=a:GetPos()b:SetPos(e-500,f)local e=vgui[_.c]("DPanel",b)e:Dock(FILL)end local b=vgui[_.c]("DButton",d)b:SetPos(0,230)b:SetSize(195,20)b:SetText"Explore..."b[_.e]=function()local b,e,g,n,q,r,s=k,nil,nil,nil,{},{},!!1 local function u()if b[f]then for e=1,#b[f]do local n,r=b[f][e]if n.arg then r=g:CreateRow("General",e..". "..n.type||"<none>".." ("..n.arg..")")else r=g:CreateRow("General",e..". "..n.type||"<none>")end r:Setup("Generic",{})r[_.d]=function(e,n)r.val=n end q[#q+1]={row=r,msg=n}end end end local function v()if b[f]then for e=1,#b[f]do local g,q=b[f][e]if g.arg then q=n:CreateRow("General",e..". "..g.type||"<none>".." ("..g.arg..")")else q=n:CreateRow("General",e..". "..g.type||"<none>")end q:Setup("Generic",{})q[_.d]=function(e,g)q.val=g end r[#r+1]={row=q,msg=g}end end end local function w()if b[f]then for g=1,#b[f]do e:AddLine(b[f][g].type,b[f][g].val,b[f][g].arg)end end end local x=vgui[_.c]"DFrame"x:SetTitle("Nethack :: "..f.." :: Explore")x:SetSize(500,300)x:SetVisible(!!1)x:SetDraggable(!!1)x:MakePopup()local y,z,A,B=a:GetPos(),nil,a:GetSize()x:SetPos(y+A,z)local y=vgui[_.c]("DPropertySheet",x)y:SetPos(0,25)y:SetSize(500,275)local z=vgui[_.c]("DCheckBoxLabel",x)z:SetPos(400,25)z:SetText"In/Out Toggle"z:SetValue(1)z:SizeToContents()z.OnChange=function(q)if q:GetChecked()then b=k s=!!1 else b=l s=!1 end e:Clear()w()g:Clear()u()n:Clear()v()end local x=vgui[_.c]"DPanel"e=vgui[_.c]("DListView",x)e:Dock(FILL)e:AddColumn"Type"e:AddColumn"Value"e:AddColumn"Parameter"w()function e:DoDoubleClick(b,e)SetClipboardText(e.Columns[2]:GetValue())notification.AddLegacy("Content copied to clipboard.",NOTIFY_UNDO,3)surface.PlaySound"buttons/button15.wav"end local z=vgui[_.c]"DPanel"local A=vgui[_.c]("RichText",z)A:Dock(FILL)A:InsertColorChange(128,128,255,255)local B=net[_._][string.lower(f)]if B then local b=debug.getinfo(B)local e=b.short_src A:AppendText(e.."\n")A:InsertColorChange(0,0,0,196)local g=file.Open(e,"r","MOD")if g then local e=g:Read(g:Size())g:Close()local n,q={},1 while!!1 do local r=string.find(e,"\n",q)if r then n[#n+1]=string.sub(e,q,r-1)q=r+1 else break end end for e=1,#n do if e==b.linedefined then A:InsertColorChange(0,0,0,255)elseif e==b.lastlinedefined+1 then A:InsertColorChange(0,0,0,196)end A:AppendText(n[e].."\n")end else A:AppendText"Could not read file."end else A:AppendText"Could not read function."end local A=vgui[_.c]"DPanel"n=vgui[_.c]("DProperties",A)n:Dock(FILL)v()local B=vgui[_.c]("DPanel",A)B:SetSize(0,25)B:Dock(BOTTOM)local C=vgui[_.c]("DButton",B)C:SetText"Apply"C:SetSize(242,0)C:Dock(LEFT)C[_.e]=function()if s then o[f]={}for b=1,#r do local e,g=r[b].msg,r[b].row local e=g.val o[f][b]=e||"NETHACK_NOVALUE"end else p[f]={}for b=1,#r do local e,g=r[b].msg,r[b].row local e=g.val if type(e)=="string"then if#e==0 then e=nil end end p[f][b]=e||"NETHACK_NOVALUE"end end end local r=vgui[_.c]("DButton",B)r:SetText"Clear"r:SetSize(242,0)r:Dock(RIGHT)r[_.e]=function()n:Clear()v()if s then o[f]=nil else p[f]=nil end end local n=vgui[_.c]"DPanel"g=vgui[_.c]("DProperties",n)g:Dock(FILL)u()local g=vgui[_.c]("DButton",n)g:SetSize(0,25)g:Dock(BOTTOM)g:SetText"Spoof"g[_.e]=function()if b[f]then local e=b[f]if s then for g=1,#q do local n,r,u=e[g]||{},q[g].msg,q[g].row local r=u.val if type(r)=="string"&&#r==0 then r=nil end m[g]=r||n.val end t(f,0,!!1)net[_._][string.lower(f)]()t(f,0,!1)else net.Start(f)for g=1,#q do local n,r,u=e[g]||{},q[g].msg,q[g].row local g=u.val net["Write"..r.type](c(g||n.val,r.type),r.arg)end net[_.a]()end end end local b=y:AddSheet("View",x).Tab b[_.e]=function(b)b:GetPropertySheet():SetActiveTab(b)e:Clear()w()end y:AddSheet("Explore",z)y:AddSheet("Intercept",A)y:AddSheet("Spoof",n)end local b=vgui[_.c]("DPanel",d)b:SetPos(0,250)b:SetSize(215,20)b:SetToolTip(e.Demsgion)local e=vgui[_.c]("DLabel",b)e:SetPos(0,0)e:SetText(f)e:SetDark(1)e:SizeToContents()e:CenterHorizontal(0.5)e:CenterVertical(0.5)end end)end
Add Comment
Please, Sign In to add comment