• PNG in HUDPaint help?
    11 replies, posted
So, i have the png, but when i trying place it on hud, i have a error in console: [ERROR] addons/darkrpmodification/lua/darkrp_modules/hudreplacement/cl_hudreplacement.lua:227: bad argument #1 to 'SetMaterial' (IMaterial expected, got string)   1. SetMaterial - [C]:-1    2. fn - addons/darkrpmodification/lua/darkrp_modules/hudreplacement/cl_hudreplacement.lua:227     3. unknown - addons/ulib-master/lua/ulib/shared/hook.lua:109 The structure: hudreplacement- -materials-hud-icons-logo.png -cl_hudreplacement Code: hook.Add( "HUDPaint", "PolygonTest", function()  surface.SetDrawColor( 255, 255, 255, 255 )  surface.SetMaterial( "hudreplacement/materials/hud/icons/logo.png")  surface.DrawTexturedRect( 0, 0, 93, 93 ) end)
ummm.... this is half working. Now i have a rectangle with error texture(black-violet)
check file paths, i think something's fishy with what you have now
local logoMat = Material("hud/icons/logo.png") this not working. I am cheked all variants of the patch, but no
I know why. You haven't got a init.lua (in your addon) who automatically download materials in joining the server.. here you are if SERVER then     include("")-- config file if existing     include("")-- core file          AddCSLuaFile("") -- same order     AddCSLuaFile("")-- same order          for _,v in pairs(file.Find("materials/nameofyouraddon/*", "GAME")) do         resource.AddSingleFile("materials/nameofyouraddon/"..v)     end suite else     include("")-- config file if existing     include("")-- core file end
You can try  hook.Add( "HUDPaint", "PolygonTest", function() surface.SetDrawColor( 255, 255, 255, 255 ) surface.SetMaterial( Material("hudreplacement/materials/hud/icons/logo.png", "noclamp smooth") ) surface.DrawTexturedRect( 0, 0, 93, 93 )  end)
Goodbye FPS
Material() it's precached, it's kinda the same shit than accessing a table via a string, but yeah, it's a good practice to precache it outside
Unless the time Material() returns is formatted weird it can easily start to add unnecessary overhead. 0.0007029100769885 vs 9.5145210503737e-06 0.0007029100769885 vs 7.2767966521783e-06 0.0007029100769885 vs 8.0828663071106e-06 0.0007029100769885 vs 7.9288149132554e-06 0.0007029100769885 vs 7.3606438130404e-06 0.0007029100769885 vs 7.4419329249271e-06 0.0007029100769885 vs 1.0063080441777e-05 0.0007029100769885 vs 7.8245033605897e-06 0.0007029100769885 vs 8.3892637288374e-06 0.0007029100769885 vs 7.6036584657087e-06 0.0007029100769885 vs 7.3802555218523e-06 local oMat,oTime = Material("spawnicons/models/11thdoctor/thedoctor.png", "noclamp smooth") hook.Add("DrawOverlay", "..", function() local mat,time = Material("spawnicons/models/11thdoctor/thedoctor.png", "noclamp smooth") local start = CurTime() print(oTime .. " vs " .. time) surface.SetMaterial(mat) surface.SetDrawColor(255, 255, 255, 255) surface.DrawTexturedRect(50, 50, 128, 128) end)
e-06 means 0.0000009514521... That means as it loaded in 7e-03 it's already precached when you run it every frame
Sorry, you need to Log In to post a reply to this thread.