HaodongMo / ArcCW

57 stars 35 forks source link

sh_0_ttt.lua: don't override existing SWEP.Icon #143

Open RalphORama opened 1 year ago

RalphORama commented 1 year ago

I ran into an issue while recreating the default TTT SWEPs with ArcCW: the current code overrides SWEP.Icon no matter what.

In my use case, I had copied over SWEP.Icon = "vgui/ttt/icon_silenced", but this was being overwritten to wep.Icon = "arccw/hud/arccw_bird.png" since icon_silenced didn't match the SWEP ClassName of weapon_ttt_sipistol.

I think this solution is the most elegant - only attempt to automatically override the icon if it isn't already set. We check isstring() first because Material() requires a string for an argument (if we pass nil we get an error).