include('shared.lua')
local matScreen = Material( "models/scroller/screen" )
// GetRenderTarget returns the texture if it exists, or creates it if it doesn't
local RTTexture = GetRenderTarget( "scrollx", 1024, 1024 )
surface.CreateFont( "coolvetica", 128, 500, false, false, "scrollt" )
local function DrawScrollingText( text, y, texwide )
surface.SetDrawColor( 0, 0, 0, 255 )
surface.DrawRect( 0, 0, 1024, 1024)
w,h=surface.GetTextSize(text)
h = h + 1024
local x = math.fmod( CurTime()*150, w ) * -1;
while ( x < texwide ) do
surface.SetTextColor( 255, 255, 255, 255 )
surface.SetTextPos( x, y )
surface.DrawText( text )
x = x + w
end
end
function ENT:Draw()
local NewRT = RTTexture
self.Entity:DrawModel()
matScreen:SetMaterialTexture( "$basetexture", NewRT )
local OldRT = render.GetRenderTarget();
cam.Start2D()
render.SetRenderTarget( NewRT )
surface.SetFont( "scrollt" )
DrawScrollingText( self.Entity:GetNetworkedString("text"), 256, 1024 )
cam.End2D()
render.SetRenderTarget( OldRT )
end