DImage how do I reset it?

I am using DImage and I am needing to reset it once I press a button. This is the code :



	if callerType == 1 then
		b1base:SetPos(50, 43)
		b1base:SetSize(78, 91)
		b1base:SetImage("materials/healthicon.png")
	else 
		b1base:SetImage(nil)	
	end


but its not working? I dont think your supposed to put “nil” but I dont know what else to do. Please help.

Try b1base:SetImage(""), I am not sure if it works, but I think so.

Nah it doesnt, tried it earlier.
Thanks anways :smiley:

ERROR :




[ERROR] lua/vgui/dimage.lua:120: attempt to index local 'Mat' (a nil value)
  1. FixVertexLitMaterial - lua/vgui/dimage.lua:120
   2. SetImage - lua/vgui/dimage.lua:101
    3. v - addons/911call/lua/autorun/client/cl_call.lua:158
     4. unknown - lua/includes/modules/hook.lua:84



Looking at the source for DImage https://github.com/Facepunch/garrysmod/blob/master/garrysmod/lua/vgui/dimage.lua you should be able to call SetMaterial with nil to clear it out. Or even SetMaterial(false)

So what your saying @wh1t3rabbit works but not what I am putting in doesnt?? I dont know how to explain it so ill paste code :




hook.Add("Think","AutoUpHighLights",function()
		local b1base = vgui.Create("DImage", frame)
		local b2base = vgui.Create("DImage", frame)
		local b3base = vgui.Create("DImage", frame)
		local b4base = vgui.Create("DImage", frame)
		local b5base = vgui.Create("DImage", frame)
		local b6base = vgui.Create("DImage", frame)


		if callerType == 1 then
			b1base:SetPos(50, 43)
			b1base:SetSize(78, 91)
			b1base:SetImage("materials/MedicIcon.png")

			b2base:SetMaterial(false)
			b3base:SetMaterial(false)
			b4base:SetMaterial(false)
			b5base:SetMaterial(false)
			b6base:SetMaterial(false)
		end

		if callerType == 2 then
			b2base:SetPos(143, 43)
			b2base:SetSize(78, 91)
			b2base:SetImage("materials/FireIcon.png")

			b1base:SetMaterial(false)
			b3base:SetMaterial(false)
			b4base:SetMaterial(false)
			b5base:SetMaterial(false)
			b6base:SetMaterial(false)
		end

		if callerType == 3 then
			b3base:SetPos(239, 43)
			b3base:SetSize(78, 91)
			b3base:SetImage("materials/PoliceIcon.png")

			b1base:SetMaterial(false)
			b2base:SetMaterial(false)
			b4base:SetMaterial(false)
			b5base:SetMaterial(false)
			b6base:SetMaterial(false)
		end

		if callerType == 4 then
			b4base:SetPos(334, 43)
			b4base:SetSize(78, 91)
			b4base:SetImage("materials/Vehicle_AccidentIcon.png")

			b1base:SetMaterial(false)
			b2base:SetMaterial(false)
			b3base:SetMaterial(false)
			b5base:SetMaterial(false)
			b6base:SetMaterial(false)
		end

		if callerType == 5 then
			b4base:SetPos(428, 43)
			b4base:SetSize(78, 91)
			b4base:SetImage("materials/ReportIcon.png")

			b1base:SetMaterial(false)
			b2base:SetMaterial(false)
			b3base:SetMaterial(false)
			b4base:SetMaterial(false)
			b6base:SetMaterial(false)
		end

		if callerType == 6 then
			b4base:SetPos(522, 43)
			b4base:SetSize(78, 91)
			b4base:SetImage("materials/SWATIcon.png")

			b1base:SetMaterial(false)
			b2base:SetMaterial(false)
			b3base:SetMaterial(false)
			b4base:SetMaterial(false)
			b5base:SetMaterial(false)
		end
	end)



[editline]9th August 2017[/editline]

NEVERMIND, FIXED!