1. Post #1

    April 2011
    280 Posts
    what i am trying to do is every time a player hits the use key on the entity it changes to a different color.
    but for some reason it runs through the whole entire code and picks the color on the bottom of the code and wont change. it just stays with the color red .


    function ENT:Use ( ply )
    if self.Entity:GetColor(0,0,255,255)  then -- Blue
    print("0")
    self:SetColor(255,255,255,255) -- White
    
    end
    
    if self.Entity:GetColor(0,255,0,255)  then --Green
    print("1")
    self:SetColor(0,0,255,255) -- Blue
     
    end
    
    if self.Entity:GetColor(255,0,0,255)  then -- Red
    print("2")
    self:SetColor(0,255,0,255) -- Green
    
    end
    
    if self.Entity:GetColor(255,255,255,255)  then -- White
    print("3")
    self:SetColor(255,0,0,255) -- Red
    
    end
    
    end
    

    what i was trying to do was since i have the entity to Initialize the color white was to let it go through the code and let it pick the color starting at the bottom on up.
    white to red then red to green then green to blue then blue to white

    any ideas to make something like this to work.

  2. Post #2
    amkoc's Avatar
    January 2011
    562 Posts
    ENT.ColorNum = 1
    ENT.Colors = {Color(0,0,255,255),
    Color(0,0,255,255),
    Color(0,255,0,255),
    Color(255,0,0,255),
    Color(255,255,255,255),
    }
    function ENT:Use ( ply )
    	self.ColorNum = self.ColorNum + 1
    	if self.ColorNum > #self.Colors then self.ColorNum = 1 end
    	self.SetColor(self.Colors[self.ColorNum].r,self.Colors[self.ColorNum].g,self.Colors[self.ColorNum].b,self.Colors[self.ColorNum].a)
    end
    

    there's probably a better way to do this, but this should work unless I'm being stupid again
    Reply With Quote Edit / Delete Reply Mac United States Show Events Winner Winner x 1 (list)

  3. Post #3

    April 2011
    280 Posts
    ENT.ColorNum = 1
    ENT.Colors = {Color(0,0,255,255),
    Color(0,0,255,255),
    Color(0,255,0,255),
    Color(255,0,0,255),
    Color(255,255,255,255),
    }
    function ENT:Use ( ply )
    	self.ColorNum = self.ColorNum + 1
    	if self.ColorNum > #self.Colors then self.ColorNum = 1 end
    	self.SetColor(self.Colors[self.ColorNum].r,self.Colors[self.ColorNum].g,self.Colors[self.ColorNum].b,self.Colors[self.ColorNum].a)
    end
    

    there's probably a better way to do this, but this should work unless I'm being stupid again
    when i try it . it say

    @lua\includes\extensions\entity.lua:116] bad argument #1 to 'setColor' (Entity expected, got number)

    line:116 is

    function meta:SetColor( r, g, b, a )
    	if ( type( r ) == "table" ) then setColor( self, r.r, r.g, r.b, r.a ) return end
    	setColor( self, r, g, b, a ) --line:116
    end
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Dumb Dumb x 1 (list)

  4. Post #4

    July 2011
    222 Posts
    when i try it . it say

    @lua\includes\extensions\entity.lua:116] bad argument #1 to 'setColor' (Entity expected, got number)

    line:116 is

    function meta:SetColor( r, g, b, a )
    	if ( type( r ) == "table" ) then setColor( self, r.r, r.g, r.b, r.a ) return end
    	setColor( self, r, g, b, a ) --line:116
    end
    [

    ENT.ColorNum = 1
    ENT.Colors = {Color(0,0,255,255),
    Color(0,0,255,255),
    Color(0,255,0,255),
    Color(255,0,0,255),
    Color(255,255,255,255),
    }
    function ENT:Use ( ply )
        self.ColorNum = self.ColorNum + 1
        if self.ColorNum > #self.Colors then self.ColorNum = 1 end
        self.SetColor(self.Colors[self.ColorNum].r,self.Colors[self.ColorNum].g,self.Colors[self.ColorNum].b,self.Colors[self.ColorNum].a)
    end

    problem is right here,
    self.SetColor
    Change the . to a :
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Informative Informative x 1 (list)

  5. Post #5

    April 2011
    280 Posts
    Wow thanks guys .I got another question . ( ent.color ) is that called a meta table?

  6. Post #6
    amkoc's Avatar
    January 2011
    562 Posts
    problem is right here,
    self.SetColor
    Change the . to a :
    deerrpp

    I am just not doing good this week, sorry OP
    Reply With Quote Edit / Delete Reply Mac United States Show Events Optimistic Optimistic x 1 (list)

  7. Post #7

    April 2011
    280 Posts
    deerrpp

    I am just not doing good this week, sorry OP
    yo dont need to be sorry amkoc you helped me .and i thank you very much in taking your time effort to do so
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Dumb Dumb x 1 (list)