Facepunch / garrysmod-issues

Garry's Mod issue tracker
147 stars 56 forks source link

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

Open cj1094 opened 2 years ago

cj1094 commented 2 years ago

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)

robotboy655 commented 2 years ago

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

cj1094 commented 2 years ago

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.