GetRenderTarget Error?

[lua]// we need two render targets, if you don’t want to create them yourself, you can
// use the bloom textures, they are quite low resolution though.
// render.GetBloomTex0() and render.GetBloomTex1()
local RT1 = GetRenderTarget( “l4d1” );
local RT2 = GetRenderTarget( “l4d2” );[/lua]

Im currently working on a 2011 copy of Gforts and trying to make it work, but I’ve ran into this problem, and spams me with this.

[ERROR] gamemodes/gforts/entities/entities/ball/cl_init.lua:18: bad argument #3 to ‘GetRenderTarget’ (number expected, got no value)

  1. GetRenderTarget - [C]:-1
  2. unknown - gamemodes/gforts/entities/entities/ball/cl_init.lua:18

I looked into the usage of getrendertarget, and I do not see how to add the w/h to something that never had it in the first place.

Full code if you want to look into it

[lua]ENT.Spawnable = false
ENT.AdminSpawnable = false
local MaterialBlurX = Material( “pp/blurx” );
local MaterialBlurY = Material( “pp/blury” );
local MaterialWhite = CreateMaterial( “WhiteMaterial”, “VertexLitGeneric”, {
["$basetexture"] = “color/white”,
["$vertexalpha"] = “1”,
["$model"] = “1”,
} );
local MaterialComposite = CreateMaterial( “CompositeMaterial”, “UnlitGeneric”, {
["$basetexture"] = “_rt_FullFrameFB”,
["$additive"] = “1”,
} );

// we need two render targets, if you don’t want to create them yourself, you can
// use the bloom textures, they are quite low resolution though.
// render.GetBloomTex0() and render.GetBloomTex1()
local RT1 = GetRenderTarget( “l4d1” );
local RT2 = GetRenderTarget( “l4d2” );
include( “shared.lua” )

local matBall2 = Material( “darkland/pumpkin2” )

function ENT:Initialize()

end

function ENT:Draw()

local oldRT = render.GetRenderTarget();
    render.SetRenderTarget( RT1 );
    render.Clear( 0, 0, 0, 255, true );
    render.SetRenderTarget( oldRT );


if os.time() < 1257033600 then
	local pos = self.Entity:GetPos()

	render.SetMaterial( matBall2 )
	render.DrawSprite( pos, 32, 32, Color( 255, 255, 255, 255 ) )
else
	self.Entity:DrawModel()
end

 render.SetStencilEnable( true );
render.SetStencilFailOperation( STENCILOPERATION_KEEP );
render.SetStencilZFailOperation( STENCILOPERATION_KEEP )
render.SetStencilPassOperation( STENCILOPERATION_REPLACE );
render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_ALWAYS );
render.SetStencilWriteMask( 1 );
render.SetStencilReferenceValue( 1 );
cam.IgnoreZ( true );
    render.SetBlend( 0 );
        SetMaterialOverride( MaterialWhite );
            self.Entity:DrawModel();
        SetMaterialOverride();
         
   render.SetBlend( 1 );
cam.IgnoreZ( false );
 
// don't need this for the next pass

render.SetStencilEnable( false );

local w, h = ScrW(), ScrH();


// draw into the white texture
local oldRT = render.GetRenderTarget();
render.SetRenderTarget( RT1 );
	render.SetViewPort( 0, 0, 512, 512 );
	
	cam.IgnoreZ( true );
		render.SuppressEngineLighting( true );
		local col = team.GetColor(holdingTeam)
			if (holdingTeam == 0) then
			col = Color(255,128,0)
			elseif (holdingTeam == LocalPlayer():Team()) then
			col = Color(255,0,255)
			end
			render.SetColorModulation( col.r/255, col.g/255, col.b/255);
		
			SetMaterialOverride( MaterialWhite );
				self.Entity:DrawModel();
			SetMaterialOverride();
			
		render.SetColorModulation( 1, 1, 1 );
		render.SuppressEngineLighting( false );
		
	cam.IgnoreZ( false );
	
	render.SetViewPort( 0, 0, w, h );
render.SetRenderTarget( oldRT );

MaterialBlurX:SetMaterialTexture( "$basetexture", RT1);

MaterialBlurY:SetMaterialTexture( “$basetexture”, RT2 );
MaterialBlurX:SetMaterialFloat( “$size”, 1 );
MaterialBlurY:SetMaterialFloat( “$size”, 1 );

local oldRT = render.GetRenderTarget();

// blur horizontally
render.SetRenderTarget( RT2 );
render.SetMaterial( MaterialBlurX );
render.DrawScreenQuad();

// blur vertically
render.SetRenderTarget( RT1 );
render.SetMaterial( MaterialBlurY );
render.DrawScreenQuad();

render.SetRenderTarget( oldRT );

// tell the stencil buffer we’re only going to draw
// where the player models are not.
render.SetStencilEnable( true );
render.SetStencilReferenceValue( 0 );
render.SetStencilTestMask( 1 );
render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL );
render.SetStencilPassOperation( STENCILOPERATION_REPLACE );

// composite the scene
MaterialComposite:SetMaterialTexture( "$basetexture", RT1 );
render.SetMaterial( MaterialComposite );
render.DrawScreenQuad();

// don't need this anymore

render.SetStencilEnable( false );

end[/lua]

Afaik, you also need to provide the width and height of the new rendertarget.

GetRenderTarget( string name, number width, number height, boolean additive )

And by checking the render.SetViewPort, the width and height are 512 and 512

I know, but if he never provided it before, how will I know what it’s suppose to be? I do not understand what getrendertarget does exactly.