User talk:Daman

From Data Realms Wiki

Revision as of 15:10, 1 July 2010 by Petethegoat (Talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Questions

Could I have permission to change the images displayed on the front page? Mainly the Lua image, which is hideously scaled, and perhaps also the Cortex Command 'C'. Thanks. -Petethegoat 17:23, 4 June 2010 (UTC)

Also, is there anywhere suitable for general discussion and questions about the wiki? Ex: Is there an easy method of flagging up a page for deletion? -Petethegoat 18:46, 4 June 2010 (UTC)

  • You can talk about the wiki on the forum. General discussion or feedback or even OT is good. Add a talk section to the main page about what you think needs to be replaced and your proposed replacements, I'd like to see. Pages can be marked for deletion using
    {{MarkDelete}}

also now my fanclub is gone :( Sysop Daman 19:20, 4 June 2010 (UTC)

Thanks for my unblocking. I continue to fill Russian section. Ximximik 16:24 5 June 2010 (UTC)


Well, I got around to adding some suggestions/questions to the main talk page the other day, and I'd like to know your thoughts on my thoughts. -Petethegoat 01:18, 10 June 2010 (UTC)

Spam and your signature.

Well, as the title says, your sig seems to be attracting some spam that can evade the filters. I'd lock it, but you haven't given me the power yet. (that is some super-subtle hinting going on there) -Petethegoat 23:06, 13 June 2010 (UTC)

drlwiki.thebunny.info

I assume you're able to merge any changes made to this back into the old wiki? -Petethegoat 15:08, 1 July 2010 (UTC)

Enormous Block of Lua.

  1. require("bass")
  2.  
  3. include('shared.lua')
  4.  
  5. SetupBrowserMat(ENT, "chrome/radio", 720, 480, 0.075)
  6.  
  7. local zerovec = Vector(0,0,0)
  8. local MaxNameLength = 32
  9.  
  10. hook.Add("CanMousePress", "DisableRadio", function()
  11.        
  12.         for _, v in pairs( ents.FindByClass( "gmt_radio" ) ) do
  13.                 if v.Browser && v.MouseRayInteresct && v:MouseRayInteresct() then
  14.                         return false
  15.                 end
  16.         end
  17.        
  18. end )
  19.  
  20. usermessage.Hook("ShowRadioSelect", function(umsg)
  21.         local ent = umsg:ReadEntity()
  22.        
  23.         if !BASS || !chrome then
  24.                 GtowerMessages:AddNewItem( GetTranslation("PleaseFullGtowerPack") )
  25.                 return
  26.         end
  27.  
  28.         if ent.Browser then
  29.                 ent.DrawTranslucent = ent.BrowserDraw
  30.                 return
  31.         end
  32.  
  33.         ent:InitBrowser(ent:GetTable())
  34.         ent.Browser:LoadURL("http://www.gmodtower.org/gmtonline/radio/")
  35.         ent.DrawTranslucent = ent.BrowserDraw
  36.         ent.CursorOut = 0
  37. end)
  38.  
  39. local GreenBox  = Color(0, 255, 0, 50)
  40. local RedBox    = Color(255, 0, 0, 50)
  41.  
  42. ENT.RenderGroup = RENDERGROUP_BOTH
  43.  
  44. function ENT:OpeningURL(url)
  45.         self:ForcePlaySelect()
  46.         print("opening", url)
  47.  
  48.                 return          
  49.         end
  50.  
  51.         self:RemoveBrowser()
  52.         self.DrawTranslucent = self.MessageDraw
  53. end
  54.  
  55. function ENT:FinishLoading()
  56.         self:ForcePlaySelect()
  57. end
  58.  
  59. function ENT:OnEnterBrowser()
  60.         self.CursorOut = 0
  61. end
  62.  
  63. function ENT:OnLeaveBrowser()
  64.         self.CursorOut = CurTime() + 2
  65. end
  66.  
  67. function ENT:Initialize()
  68.         self.BoxColor = RedBox
  69.         self.DrawTranslucent = self.MessageDraw
  70.  
  71.         if BASS == nil then
  72.                 self.DrawMessage = GetTranslation("PleaseFullGtowerPack")
  73.                 return
  74.         end
  75.  
  76.         self.DrawMessage = GetTranslation("RadioTurnedOff")
  77.         self.CurStation = ""
  78.         self.radiostream = nil
  79.        
  80.         self.NextCalcName = 0
  81.         self.TextWidth, self.TextHeight = 150, 20
  82.         self.CurName = ""
  83.         self.ShouldDrawName = false
  84.        
  85.         self.TextOffset = 0
  86.         self.TargetTextOffset = 0
  87.        
  88.         self:SetNetworkedVarProxy("CurChan", self.ChannelChanged )
  89.  
  90.         self:SetLargeBounds()
  91.         self.CursorOut = 0
  92. end
  93.  
  94. function ENT:StopRadio()
  95.         if self.radiostream then
  96.                 self.radiostream:stop()
  97.         end
  98.  
  99.         self.BoxColor = RedBox
  100.         self.DrawMessage = GetTranslation("RadioTurnedOff")
  101.  
  102.         if !self.Browser then
  103.                 self.DrawTranslucent = self.MessageDraw
  104.         end
  105.  
  106.         self.ShouldDrawName = false
  107.         self.radiostream = nil
  108. end
  109.  
  110. function ENT:CalculateEarShot()
  111.         if !GTowerLocation then
  112.                 self.InEarShot = true
  113.                 return
  114.         end
  115.  
  116.         local radioloc = GTowerLocation:FindPlacePos(self:GetPos())
  117.         local plyloc = GTowerLocation:FindPlacePos(LocalPlayer():GetPos())
  118.        
  119.         self.InEarShot = radioloc != nil && plyloc != nil && (plyloc == radioloc)
  120. end
  121.  
  122. function ENT:StartRadio( stream )
  123.         if !stream || #stream == 0 then return end
  124.  
  125.         self.BoxColor = GreenBox
  126.         self.DrawTranslucent = self.RadioDraw
  127.        
  128.         self:RemoveBrowser()
  129.  
  130.         BASS.StreamFileURL(stream, 0, function(basschannel, error)
  131.                 if self.DrawTranslucent != self.RadioDraw then
  132.                         return // this means we stopped it between the startradio and this callback
  133.                 end
  134.  
  135.                 self:CalculateEarShot()
  136.  
  137.                 print("Ready to play", self.InEarShot)
  138.                 if !self.InEarShot then
  139.                         self:StopRadio()
  140.                         return
  141.                 end
  142.  
  143.                 if !basschannel then
  144.                         print("Error streaming file", error)
  145.                         if error == 40 || error == 2 then
  146.                                 self.DrawMessage = GetTranslation("RadioTimeout")
  147.                         elseif error == 41 then
  148.                                 self.DrawMessage = GetTranslation("RadioUnsupportedFormat")
  149.                         elseif error == 8 then
  150.                                 self.DrawMessage = GetTranslation("RadioBASSInitError")
  151.                         else
  152.                                 self.DrawMessage = GetTranslation("RadioUnknown") .. " " .. tostring(error)
  153.                         end
  154.                         self.BoxColor = RedBox
  155.                         self.DrawTranslucent = self.MessageDraw
  156.  
  157.                         return
  158.                 end
  159.  
  160.                 self.radiostream = basschannel
  161.                 self.radiostream:set3dposition(self:GetPos(), zerovec, zerovec)
  162.  
  163.                 self.radiostream:play()
  164.  
  165.                 self.NextCalcName = 0
  166.         end)
  167. end
  168.  
  169. function ENT:ChannelChanged( name, oldval, nwc )
  170.        
  171.         if nwc == self.CurStation then return end
  172.        
  173.         self.CurStation = nwc
  174.        
  175.         if #nwc == 0 && self.StopRadio then
  176.                 self:StopRadio()
  177.                 return
  178.         end
  179.        
  180.         if !self.StartRadio then return end
  181.  
  182.         print("station", self.Stream)
  183.  
  184.         self:CalculateEarShot()
  185.         if !self.InEarShot then return end
  186.  
  187.         self:StartRadio(self.Stream)
  188. end
  189.  
  190. function ENT:OnRemove( )
  191.         self:RemoveBrowser()
  192.         self:StopRadio()
  193. end
  194.  
  195. function ENT:BaseDraw()
  196.         local EntPos = self:GetPos() + ( self:GetForward() * 4 ) + self:GetUp() * -5
  197.         local PlyDistance = EntPos:Distance( LocalPlayer():GetPos() )
  198.        
  199.        
  200.         if PlyDistance > 350 then
  201.                 return
  202.         end
  203.        
  204.         local ang = self:GetAngles()
  205.  
  206.  
  207.         if (LocalPlayer():GetPos() - EntPos ):DotProduct( ang:Forward() ) < 0 then
  208.                 return
  209.         end
  210.        
  211.         local AlphaRatio = 1.0
  212.        
  213.         if PlyDistance > 128 then
  214.                 AlphaRatio = 1 - (PlyDistance - 128) / 222
  215.                
  216.                 self.BoxColor.a = AlphaRatio * 50
  217.                
  218.         else
  219.                 self.BoxColor.a = 50
  220.         end
  221.        
  222.         ang:RotateAroundAxis(ang:Right(),       -90 )
  223.         ang:RotateAroundAxis(ang:Up(),          90 )
  224.  
  225.         cam.Start3D2D( EntPos , ang, 0.1)
  226.        
  227.         return AlphaRatio
  228. end
  229.  
  230. function ENT:MessageDraw()
  231.         local AlphaRatio = self:BaseDraw()
  232.        
  233.         if AlphaRatio == nil then return end
  234.        
  235.         self:DrawMyText( self.DrawMessage, AlphaRatio )
  236.        
  237.         cam.End3D2D()
  238. end
  239.  
  240.  
  241. function ENT:Draw()
  242.         self:DrawModel()
  243. end
  244.  
  245. function ENT:GetPosBrowser()
  246.         return self:GetPos() + (self:GetForward() * 4)
  247. end
  248.  
  249. function ENT:DrawBrowser()
  250.         surface.SetDrawColor(255, 255, 255, 255)
  251.         surface.SetTexture(self.TexId)
  252.         surface.DrawTexturedRect(0,0, self.TexWidth, self.TexHeight)
  253.  
  254.         if self.CursorOut > 0 then
  255.                 surface.SetDrawColor(100, 100, 100, 150)
  256.                 surface.DrawRect(0, 0, self.Width, self.Height)
  257.         end
  258. end
  259.  
  260. function ENT:BrowserDraw()
  261.         if !self.Browser then
  262.                 self.DrawTranslucent = self.MessageDraw
  263.                 return
  264.         end
  265.  
  266.         self:BaseBrowserDraw()
  267. end
  268.  
  269. function ENT:RadioDraw()
  270.         if self.radiostream && !self.radiostream:getplaying() then
  271.                 self:StopRadio()
  272.                 return
  273.         end
  274.  
  275.         local AlphaRatio = self:BaseDraw()
  276.  
  277.         if AlphaRatio == nil then return end
  278.        
  279.         if self.radiostream && self.ShouldDrawName then
  280.                 self:DrawMyText( GetTranslation("RadioPlaying") .. ": " .. self.CurName, AlphaRatio )
  281.         else
  282.                 self:DrawMyText( GetTranslation("RadioLoading"), AlphaRatio )
  283.         end
  284.  
  285.         self:DrawSpectrumAnalyzer()
  286.  
  287.         cam.End3D2D()
  288.  
  289. end
  290.  
  291. function ENT:DrawMyText( text, AlphaRatio )
  292.  
  293.         surface.SetFont( "ChatFont" )
  294.  
  295.         local w,h = surface.GetTextSize( text )
  296.  
  297.         draw.RoundedBox(4, -100 , -145, w + 16, h + 8 , self.BoxColor )
  298.  
  299.         surface.SetTextColor( 255, 255, 255, 255 * AlphaRatio)
  300.         surface.SetTextPos( -100 + 8 , -145 + 4 )      
  301.         surface.DrawText(text)
  302.        
  303. end
  304.  
  305. local SPECHEIGHT= 64
  306. local SPECWIDTH = 300
  307. local BANDS     = 28
  308. local ox, oy    = -100, -45
  309.  
  310. function ENT:DrawSpectrumAnalyzer()
  311.         local chan = self.radiostream
  312.         if !chan then return end
  313.  
  314.         local fft = chan:fft2048()
  315.         local b0 = 0
  316.  
  317.         surface.SetDrawColor(0, 0, 255, 255)
  318.  
  319.         for x = 0, BANDS-2 do
  320.                 local sum = 0
  321.                 local sc = 0
  322.                 local b1 = math.pow(2,x*10.0/(BANDS-1))
  323.  
  324.                 if (b1>1023) then b1=1023 end
  325.                 if (b1<=b0) then b1=b0+1 end
  326.                 sc=10+b1-b0;
  327.                 while b0 < b1 do
  328.                         sum = sum + fft[2+b0]
  329.                         b0 = b0 + 1
  330.                 end
  331.                 y = (math.sqrt(sum/math.log10(sc))*1.7*SPECHEIGHT)-4
  332.                 y = math.Clamp(y, 0, SPECHEIGHT)
  333.  
  334.                 surface.DrawRect(ox + (x*(SPECWIDTH/BANDS)), oy - y - 1, (SPECWIDTH/BANDS) - 2, y + 1)
  335.         end
  336. end
  337.  
  338. function ENT:Think()
  339.         if self.Browser then
  340.                 self:MouseThink()
  341.                 if self.CursorOut > 0 && CurTime() > self.CursorOut then
  342.                         self:RemoveBrowser()
  343.                         self.DrawTranslucent = self.MessageDraw
  344.                 end
  345.         end
  346.         if self.radiostream then self:RadioThink() end
  347. end
  348.  
  349. function ENT:RadioThink()
  350.         local pos = self:GetPos()
  351.         pos.z = -pos.z
  352.  
  353.         self.radiostream:set3dposition(pos, zerovec, zerovec)
  354. end
  355.  
  356. hook.Add("Location", "PlayerLeaveRoomRadio", function(ply, location)
  357.         if ply != LocalPlayer() || !BASS then return end
  358.        
  359.         for k, v in ipairs(ents.FindByClass("gmt_radio")) do
  360.                 if v.CalculateEarShot then
  361.                         v:CalculateEarShot()
  362.  
  363.                         if !v.InEarShot && v.radiostream then
  364.                                 v:StopRadio()
  365.                         elseif v.InEarShot && !v.radiostream then
  366.                                 v:StartRadio(v.Stream)
  367.                         end
  368.                 end
  369.         end
  370. end)
  371.  
  372. local function BassThink()
  373.         local ply = LocalPlayer()
  374.  
  375.         local eyepos = ply:EyePos()
  376.         eyepos.z = -eyepos.z
  377.  
  378.         local vel = ply:GetVelocity()
  379.  
  380.         local eyeangles = ply:GetAimVector():Angle()
  381.  
  382.         // threshold, 89 exact is backwards accord to BASS
  383.         eyeangles.p = math.Clamp(eyeangles.p, -89, 88.9)
  384.  
  385.         local forward = eyeangles:Forward()
  386.         local up = eyeangles:Up() * -1
  387.  
  388.         BASS.SetPosition(eyepos, vel * 0.005, forward, up)
  389. end
  390.  
  391. if BASS then
  392.         hook.Add("Think", "UpdateBassPosition", BassThink )
  393. end
Personal tools