Include 2 ClientSide Files

I was wondering how can I connect 2 client side files.
Example: I have 2 files called cl_1 and cl_2
In cl_1 I have a DFrame and other things on the frame.
In cl_2 I have a few button and when you press one of them will color the frame which is located in cl_1
I was thinking if I have to add like include(‘cl_1’) at the top of cl_2 so I can use certain variables that will color the DFrame.

Yeah, you’re doing it right if you’re just trying to get the variables Just put:
[lua]
include(‘cl_1.lua’)
[/lua]

I tried that a few hours ago but it didn’t worked.
Here is the error and the code.

Error
[lua]
[ERROR] lua/includes/modules/draw.lua:198: attempt to index local ‘color’ (a nil value)

  1. RoundedBox - lua/includes/modules/draw.lua:198
  2. unknown - gamemodes/bmdeathrun/gamemode/client/cl_scoreboard.lua:13

[/lua]
First Client Side

[lua]
local bgcolor = Color(37,37,37,255)
local plcolor = Color(200,200,200,255)
local pllistcolor = Color(0,0,0,25)

function help()
local ply = LocalPlayer()

if ply:GetNWString("usergroup") == "superadmin" then

// Start Chose Background Color
bgcol = vgui.Create(“DFrame”)
bgcol:SetPos(ScrW()/2-250,ScrH()/2-325)
bgcol:SetSize(500,450)
bgcol:SetTitle("")
bgcol:MakePopup()
bgcol:SetDraggable(false)
bgcol.Paint = function()
draw.RoundedBox(0,0,0,bgcol:GetWide(),bgcol:GetTall(),Color(37,37,37,255))
end
bgcol.btnClose:SetVisible(true)
bgcol.btnMinim:SetVisible(false)
bgcol.btnMaxim:SetVisible(false)

bgorange = vgui.Create("DButton",bgcol)
	bgorange:SetPos(5,5)
	bgorange:SetSize(15,15)
	bgorange:SetText("")
	bgorange.Paint = function()
		draw.RoundedBox(0,0,0,bgorange:GetWide(),bgorange:GetTall(),Color(244,179,0,255))
	end
	bgorange.DoClick = function()
		bgcolor = Color(244,179,0,255)
		plcolor = Color(37,37,37,255)
		pllistcolor = Color(128,128,128,25)
		bgorange:SetSize(15,20)//
		bggreen:SetSize(15,15)
		bgblue:SetSize(15,15)
		bglred:SetSize(15,15)
		bgdblue:SetSize(15,15)
		bgbrown:SetSize(15,15)
		bgpurple:SetSize(15,15)
		bgcyan:SetSize(15,15)
	end	

bggreen = vgui.Create("DButton",bgcol)
	bggreen:SetPos(30,5)
	bggreen:SetSize(15,15)
	bggreen:SetText("")
	bggreen.Paint = function()
		draw.RoundedBox(0,0,0,bggreen:GetWide(),bggreen:GetTall(),Color(118,182,0,255))
	end
	bggreen.DoClick = function()
		bgcolor = Color(118,182,0,255)
		plcolor = Color(37,37,37,255)	
		pllistcolor = Color(128,128,128,25)
		bggreen:SetSize(15,20)//
		bgorange:SetSize(15,15)
		bgblue:SetSize(15,15)
		bglred:SetSize(15,15)
		bgdblue:SetSize(15,15)
		bgbrown:SetSize(15,15)
		bgpurple:SetSize(15,15)
		bgcyan:SetSize(15,15)
	end	
	
bgblue = vgui.Create("DButton",bgcol)
	bgblue:SetPos(55,5)
	bgblue:SetSize(15,15)
	bgblue:SetText("")
	bgblue.Paint = function()
		draw.RoundedBox(0,0,0,bgblue:GetWide(),bgblue:GetTall(),Color(38,115,236,255))
	end
	bgblue.DoClick = function()
		bgcolor = Color(38,115,236,255)
		plcolor = Color(37,37,37,255)
		pllistcolor = Color(128,128,128,25)
		bgblue:SetSize(15,20)//
		bgorange:SetSize(15,15)
		bggreen:SetSize(15,15)
		bglred:SetSize(15,15)
		bgdblue:SetSize(15,15)
		bgbrown:SetSize(15,15)
		bgpurple:SetSize(15,15)
		bgcyan:SetSize(15,15)
	end	

// End Background Color
end
end
[/lua]

Second Client Side

[lua]
include( ‘client/cl_info.lua’ )

function GM:ScoreboardShow()
gui.EnableScreenClicker(true)

bg = vgui.Create("DFrame")
	bg:SetPos(ScrW()/2-300,ScrH()/2-300)
	bg:SetSize(600,500)
	bg:SetTitle("")
	bg:SetDraggable(false)
	bg:MakePopup()
	bg.Paint = function()
		draw.RoundedBox(0,0,0,bg:GetWide(),bg:GetTall(),bgcolor)
	end
bg.btnClose:SetVisible(false)
bg.btnMinim:SetVisible(false)
bg.btnMaxim:SetVisible(false)

end

function GM:ScoreboardHide()
gui.EnableScreenClicker(false)

	bg:Close()

end
[/lua]

As you can see the bgcolor it’s in the First Client Side file but it’s also used in the Second Client side file.

[editline]28th May 2013[/editline]

And it also says that
[lua]
Couldn’t include file ‘client\cl_info.lua’ (File not found) (@gamemodes/bmdeathrun/gamemode/client/cl_scoreboard.lua (line 1))
[/lua]

[lua]
Couldn’t include file ‘client\cl_info.lua’ (File not found) (@gamemodes/bmdeathrun/gamemode/client/cl_scoreboard.lua (line 1))[/lua]

Are you sure ‘client\cl_info.lua’ is the right file path that your including?

Make sure you added AddCSLuaFile(“filename.lua”) in your init.lua. Also, not completely sure, but I think local variables won’t be transferred between files, so make them globals.

I had to include(‘cl_info.lua’) not include(‘client/cl_info.lua’)