ULX

Author Topic: Lua brush entity material not showing up  (Read 1534 times)

0 Members and 1 Guest are viewing this topic.

Offline dbhvk

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Lua brush entity material not showing up
« on: January 11, 2016, 11:07:42 AM »
Disclaimer: I also posted this on the Facepunch forums, but they haven't replied yet  :(

Hello and thanks for taking your time to read about my issue:
I'm making a gamemode and I wanted people to easily be able to create maps without worrying about Lua at all. I wanted to be able to create a brush entity in Hammer and detect it via lua to apply the corresponding logic. I got pretty far on my own but my materials (defined with Hammer's texture tool) are not showing up.

I've created a simple entity setting ENT.Base to "base_brush" and ENT.Type to "brush". I've also defined the entity as a @SolidClass in my fgd file. To check that everything works I've made it so that a message is shown when ENT:StartTouch(). Everything seems fine, but I can't get the material defined in Hammer to show up.

Printing self:GetMaterials()[1] returns the correct material (maps/gmodmap/dev/dev_blendmeasure_wvt_patch) but even when I try to self:SetMaterial() I can't get it to work.

I also get the following error: Requesting texture value from var "$dummyvar" which is not a texture value (material: NULL material)

Code: [Select]
ENT = {}

ENT.Base = "base_brush"
ENT.Type = "brush"
   
function ENT:Initialize( key, value )
    print(self:GetMaterials()[1])
    self:SetMaterial(self:GetMaterials()[1], true)
end

function ENT:KeyValue( key, value )

    if !self.keyvalues then
        self.keyvalues = {}
    end
    print(key, value)
    self.keyvalues[key] = value

end

if ENT.Type then
    scripted_ents.Register( _G.ENT, "start_line" )
end

function ENT:StartTouch( entity )
    if entity:IsPlayer() and entity:IsValid() then
        for _, v in pairs(player.GetAll()) do
            v:PrintMessage(HUD_PRINTTALK, entity:GetName().. " touched it OMG.")
        end
    end
end


ENT = nil

I swear that code is just for quick testing purposes, I'll write it in a cleaner way once I figure out all the details  :P

Thanks for the help
« Last Edit: January 11, 2016, 11:54:29 AM by dbhvk »