Evocity retexture addon doesn't work right

Hello. Im working on a Evocity retexture addon for Gmod. I need to know, how to get custom textures working. I tryed to make the same paths like the original texture files have and just replaced the textures. It worked, but only one time. After i close Gmod or load a new addon into my gmod, my custom textures will not work anymore and i need to subscribe my addon again to get them work. So i think my problem is: I cant overwrite the textures, just add new and get them work with a lua script. I found something here on the forum and tryed it. But i get a lua error if i join my map.

This is my lua script i made, to replace a texture:

local mat = Material"hall_brick/brick01a"
local met = Material"dvm/dbrick01a"
mat:SetMaterialTexture("$basetexture", met:GetMaterialTexture"$basetexture")

Can someone help me making this texture addon?


Well, whats the error?

[ERROR] LuaCmd:1: ‘=’ expected near ‘<eof>’

  1. unknown - LuaCmd:0

Edit: ok i know now i need to change something, so i can run it.
My problem is, i have no idea how i write something with lua.
I just know how to texture and replace them.

Would be great if someone can write some lua script for my darkrp server, so i can add the script serverside.
Thats what i want to do :slight_smile:

You should probably be putting your code in an actual file so it automatically runs on start.

I did. I put the lua into my darkrp server: DarkRP\garrysmod\addons\darkville\lua\autorun\darkville.lua

[editline]17th September 2017[/editline]

I really have no idea abouth lua scripting. Thats why it wont work :smiley: I think i need a few lua files to get this working.

And you got the error you got above???

You shouldn’t need multiple files for it.

Now it don’t even load at startup. Only if i use this script in singleplayer. I will try it in singleplayer again.

Add me on steam http://steamcommunity.com/id/MelonShooter/

I’ll be able to help you better.

I did thx :slight_smile:

Btw thats the lua error i get:

[dvbrick] lua/autorun/darkville.lua:3: attempt to call method ‘GetMaterialTexture’ (a nil value)

  1. unknown - lua/autorun/darkville.lua:3

Alright, that was easy. Just make sure you read the date of facepunch threads before copying stuff lol. Also, use code tags next time so it’s easier to read.

Completely off-topic:
That looks like a pretty cool addon though, very nicely done

also in case peope are finding the thread later on:

GetMaterialTexture was replaced in Gmod 13 with GetTexture.
so for Gmod13 it should be among this lines:
[lua] local mat = Material( “hall_brick/brick01a” )
local met = Material( “dvm/dbrick01a” )
mat:SetTexture("$basetexture", met:GetTexture("$basetexture"))

@GalaxyBeatzz thx :slight_smile:

Thx. Yes i know now its a lua from the old gmod. MelonShooter told me that. :slight_smile:
Btw. i got it working with replacing the original files. The issue with my textures are material addons from other evocity maps (all evocitymaps use the same base materials). I need to test the textures for new joining players.