garrysmod-issues icon indicating copy to clipboard operation
garrysmod-issues copied to clipboard

lua global function Material(...) server-side srcds.exe Windows load png returns object Material [___error]

Open cj1094 opened this issue 3 years ago • 2 comments

I have a file: garrysmod/materials/a.png

I run this code server-side on Windows srcds.exe:

local mat = Material("a.png")
print(mat)

This is the output in the server's console:

Material [___error] - (X)

That code returns the correct material when ran server-side from steamapps\common\GarrysMod\hl2.exe.

This is the issue. (X)

cj1094 avatar May 25 '22 20:05 cj1094

Why do you need to create materials from .png on dedicated servers?

robotboy655 avatar May 30 '22 12:05 robotboy655

I'm using a PNG image on the server as a texture map. I'm not using a PNG anymore; Instead, I converted the PNG grayscale image to a JSON string and saved it in the data folder, then load and use it as a text file. It's 4 times the size, but it doesn't matter that much because the server only uses the JSON string as a map, and a lot of players do not need to download it.

I decided to add this as an issue only because these functions are all listed as shared on the wiki:

Material ITexture:GetColor IMaterial:GetColor

For your reference, maybe someone can edit the wiki and put that srcds.exe on Windows doesn't support the previous functions server-side for PNG files.

Thanks.

cj1094 avatar Jun 08 '22 21:06 cj1094