Replacing textures live.

Why doesn’t this work
[lua]local mat = Material"sgtsicktextures/BANKOFAMERICASIGN"
local met = Material"evocityextrude"
mat:SetMaterialTexture("$basetexture", met:GetMaterialTexture"$basetexture")
mat:SetMaterialTexture("$bumpmap", met:GetMaterialTexture"$bumpmap" )[/lua]
to replace the Bank Of America sign in evocity when this
[lua]–[[ Replace hans with rebel hans ]]–
if SERVER then
AddCSLuaFile"autorun/hans_replace.lua"
resource.AddFile"hand_replacement.vmt"
resource.AddFile"hand_replacement.vtf"
resource.AddFile"hand_replacement_normal.vtf"
else
local mat = Material ( “models/weapons/v_hand/v_hand_sheet” )
local met = Material ( “hand_replacement” )
mat:SetMaterialTexture ( “$basetexture” , met:GetMaterialTexture( “$basetexture”))
mat:SetMaterialTexture ( “$bumpmap” , met:GetMaterialTexture( “$bumpmap” ))
end[/lua]
works fine for replacing the player’s HEV suit hands with rebel themed ones?

inb4 “you have no parentheses”, this is correct Lua syntax.

Also, is this sign a decal or an overlay? If so, it seems that those can’t be modified using this method for some reason, and I have no idea why.

As far as I know it’s a standard brush texture. Does it matter that I’m doing the first one in-game with Luapad and the second one is an autorun file?

[editline]06:58PM[/editline]

Hmm I’ll try making an autorun file.

[editline]07:06PM[/editline]

[lua]–[[ Replace sign with post sign ]]–
if SERVER then
AddCSLuaFile"autorun/sign_replace.lua"
resource.AddFile"evocityextrude.vmt"
resource.AddFile"evocityextrude.vtf"
resource.AddFile"evocityextrude_normal.vtf"
resource.AddFile"evocityintrude.vmt"
resource.AddFile"evocityintrude.vtf"
resource.AddFile"evocityintrude_normal.vtf"
else
local mat = Material “sgtsicktextures/BANKOFAMERICASIGN”
local met = Material “evocityextrude”
mat:SetMaterialTexture( “$basetexture”, met:GetMaterialTexture"$basetexture")
mat:SetMaterialTexture( “$bumpmap”, met:GetMaterialTexture"$bumpmap" )
local mat = Material “sgtsicktextures/BANKOAMERICA2”
local met = Material “evocityintrude”
mat:SetMaterialTexture( “$basetexture”, met:GetMaterialTexture"$basetexture")
mat:SetMaterialTexture( “$bumpmap”, met:GetMaterialTexture"$bumpmap" )
end[/lua]
Still no joy. Bugger.
What a waste of an afternoon. :confused:

Last time I checked, you can’t modify textures used by the map in-game. You need to copy your textures to their right folders.

Well that is odd. I just noticed that the second sign replacement actually worked.

…Well, sorta. It’s rather compressed and for some reason completely unlit, but it did work.
I did just find this in the console though.



env_cubemap used on world geometry without rebuilding map. . ignoring: sgtsicktextures/bankofamericasign
env_cubemap used on world geometry without rebuilding map. . ignoring: evocityextrude
env_cubemap used on world geometry without rebuilding map. . ignoring: evocityintrude
env_cubemap used on world geometry without rebuilding map. . ignoring: evocityintrude


[editline]08:52PM[/editline]

Ok, found out I had the material names wrong with help from the guys in this thread.
Here’s the (mostly) working code.
[lua]–[[ Replace sign with post sign ]]–
if SERVER then
AddCSLuaFile"autorun/sign_replace.lua"
resource.AddFile"evocityextrude.vmt"
resource.AddFile"evocityextrude.vtf"
resource.AddFile"evocityextrude_normal.vtf"
resource.AddFile"evocityintrude.vmt"
resource.AddFile"evocityintrude.vtf"
resource.AddFile"evocityintrude_normal.vtf"
else
local mat = Material “maps/rp_evocity_v2pdless/sgtsicktextures/bankofamericasign_-6363_-7696_137”–“SGTSICKTEXTURES/BANKOFAMERICASIGN”
local met = Material “evocityextrude”
mat:SetMaterialTexture( “$basetexture”, met:GetMaterialTexture"$basetexture")
mat:SetMaterialTexture( “$bumpmap”, met:GetMaterialTexture"$bumpmap" )

local mot = Material	      "SGTSICKTEXTURES/BANKOAMERICA2"
local mut = Material	      "evocityintrude"
mot:SetMaterialTexture(	      "$basetexture", mut:GetMaterialTexture"$basetexture")
mot:SetMaterialTexture(	      "$bumpmap",     mut:GetMaterialTexture"$bumpmap"    )
mot:SetMaterialInt(           "$normalmapalphaenvmapmask", 1					  )
mot:SetMaterialTexture(       "$envmap",      mat:GetMaterialTexture"$envmap"     )

end[/lua]

Oh could you please stop raping the lua language… please. :ohdear:

How am I raping the Lua language? I’m using it in its pure form, as it’s supposed to be used, without all the bullshit C++ stuff Garry added.

[lua]–[[ Replace sign with post sign ]]–
if SERVER then
AddCSLuaFile( “autorun/sign_replace.lua” )
resource.AddFile( “evocityextrude.vmt” )
resource.AddFile( “evocityextrude.vtf” )
resource.AddFile( “evocityextrude_normal.vtf” )
resource.AddFile( “evocityintrude.vmt” )
resource.AddFile( “evocityintrude.vtf” )
resource.AddFile( “evocityintrude_normal.vtf” )
else
local mat = Material( “maps/rp_evocity_v2pdless/sgtsicktextures/bankofamericasign_-6363_-7696_137” )
local met = Material( “evocityextrude” )
mat:SetMaterialTexture( “$basetexture”, met:GetMaterialTexture("$basetexture") )
mat:SetMaterialTexture( “$bumpmap”, met:GetMaterialTexture("$bumpmap") )

local mot = Material( "SGTSICKTEXTURES/BANKOAMERICA2" )
local mut = Material( "evocityintrude" )

mot:SetMaterialTexture( "$basetexture", mut:GetMaterialTexture("$basetexture") )
mot:SetMaterialTexture( "$bumpmap", mut:GetMaterialTexture("$bumpmap") )
mot:SetMaterialInt( "$normalmapalphaenvmapmask", 1 )
mot:SetMaterialTexture( "$envmap", mat:GetMaterialTexture( "$envmap" ) )

end[/lua]

Thats how I would set your code out, really. Looks neater and easier to read. But I suppose bad habits die hard.

Not specifying parentheses for a single string literal is a feature of the syntax. Lexic is not raping the language in any way.

How is neater. My arguments were all on the same columns as each other.
You are not taxed for whitespace, people.
Except of course in odd languages like VB or Python.

the () dum…s


(User was banned for this post ("Flaming" - mahalis))

Using it just because it’s “a feature of the syntax” seems pretty pointless to me. Especially when it only works for single literal strings and table constructor arguments. Writing extra parentheses is much more efficient and improves readability by a lot, in my opinion. Not to talk about how ugly it looks and how it makes nerds rage.

How is it much more efficient to write extra parenthesis?

I don’t use it just because it’s a feature, I use it because I like how it looks.

Calm down, everyone can code in the style they prefer.

Visual Basic does not punish you for whitespace ( at least not .Net ) - it’s just that the editor enforces it based on settings.

http://imageflock.com/img/1252350735.png

Disable pretty listing and it stops formatting your code for you.

Agreed.

Garry’s Mod isn’t “pure form” Lua… all the bullshit C++ stuff Garry added is part of its implementation. Writing Lua for Garry’s Mod isn’t writing vanilla Lua, its his customized version of it… which he… specifically designed for Garry’s Mod. See where this is going?

I suggest you read http://wiki.garrysmod.com/?title=Lua_Differences

See that big exclamation mark down there? Garry’s Mod uses a customised implementation of Lua. It is not standard Lua.

If you want to use it “as it’s supposed to be used” you shouldn’t be writing it in Garry’s Mod, because it doesn’t exist. You’re supposed to use the new syntax.

He only left the old syntax available because of the same reasons we put handicap ramps next to stairs: you know… so the retards can still manage to get up.

Kay, if I ever care, I’ll let you know.

I didn’t realize that was foszor until I reread what he said after reading Lexic’s reply.

:ohdear:

Can we get back to the OP please? I really would like to know how it is fixed :keke: