• CreateMaterial creates a blank material from a .png
    0 replies, posted
Hello, I've tried looking at this thread in order to apply a .png material from my /data/ folder onto a model. (In my case, it takes a direct image URL (value) and writes it into the data folder, then takes that downloaded picture and uses it as a material) However, whenever I rejoin my server (dedicated server or singleplayer doesn't matter, both cause the same issue) the created material becomes a missing texture, and the only way to fix it is to restart the game. I tried following the advice at the end of the thread to change material:GetName() to material:GetTexture("$basetexture"), but doing so causes the applied material to just be a blank, white material. It's confusing, since the wiki says it does not accept ITexture values, hence the GetName(), however GetName() and GetTexture("$basetexture"):GetName() yield the same missing texture result. I seemed to have reached a dead end here. Here is my code: http.Fetch(value, function(body, size)     if !file.Exists("matdata", "DATA") then file.CreateDir("matdata") end     file.Write(("matdata/"..ply:SteamID64()..".png"), body)      local newmat = Material("data/matdata/"..ply:SteamID64()..".png") local newmatmodelskin = CreateMaterial(("httpmat"..ply:SteamID64()), "VertexLitGeneric", {     ["$basetexture"] = newmat:GetTexture("$basetexture"),     ["$alphatest"] = 1,     ["$halflambert"] = 1,     ["$nocull"] = 1,     ["$nodecal"] = 1, ["$model"] = 1, }) ply:SetMaterial(("!httpmat"..ply:SteamID64()), true) end, function() end) Writing pictures to the data folder works flawlessly, but the CreateMaterial() is what I'm having issues with. I apologize in the event the issue sticks out like a sore thumb here, I'm relatively new to this part of lua programming. Any advice or fixes would definitely be appreciated.
Sorry, you need to Log In to post a reply to this thread.