GuiLabelGetColor: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Added OOP Method + Counterpart Information)
 
(13 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__
{{Client function}}
{{Client function}}
__NOTOC__
{{New feature/item|3.0132|1.3.1|4670|
This function gets the color of a label.
This function gets the color of a label.
}}


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int int int guiLabelGetColor ( element theLabel )
int int int guiLabelGetColor ( gui-element theLabel )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[Element/GUI/Text label|GuiLabel]]:getColor||guiLabelSetColor}}
===Required Arguments===  
===Required Arguments===  
*'''theLabel:''' The label to get color.
*'''theLabel:''' The label to get color.


===Returns===
===Returns===
Returns four ''int'' values, representing the amount of red, green, blue if successful. ''false'' otherwise.
Returns three ''int'' values, representing the amount of red, green, blue if successful. ''false'' otherwise.


==Example==  
==Example==
This example creates a label, set random color and when player type command /get_color_label it's return label color.
<syntaxhighlight lang="lua">local pLabel = guiCreateLabel( 0.5, 0.5, 0.5, 0.5, 'Text', true )
<section name="Client" class="client" show="true">
guiLabelSetColor( pLabel, math.random( 0, 255 ), math.random( 0, 255 ), math.random( 0, 255 ) )
<syntaxhighlight lang="lua">
local pLabel = guiCreateLabel( 0.5, 0.5, 0.5, 0.5, 'Text', true )
guiSetLabelColor( pLabel, math.random( 0, 255 ), math.random( 0, 255 ), math.random( 0, 255 ) )


addCommandHandler( 'get_color_label',  
addCommandHandler( 'get_color_label',  
     function()
     function()
         local iR, iG, iB = guiLabelGetColor( pLabel )
         local iR, iG, iB = guiLabelGetColor( pLabel )
         outputChatBox( ( 'Label color is r = %s, g = %s, b = %s' ):foramt( iR, iG, iB ) )
         outputChatBox( ( 'Label color is r = %d, g = %d, b = %d' ):format( iR, iG, iB ) )
     end
     end
)</syntaxhighlight>
)</syntaxhighlight>
</section>


==See Also==
==See Also==
{{GUI functions}}
{{GUI functions}}
{{GUI_events}}

Latest revision as of 11:40, 7 August 2019

This function gets the color of a label.

Syntax

int int int guiLabelGetColor ( gui-element theLabel )

OOP Syntax Help! I don't understand this!

Method: GuiLabel:getColor(...)
Counterpart: guiLabelSetColor


Required Arguments

  • theLabel: The label to get color.

Returns

Returns three int values, representing the amount of red, green, blue if successful. false otherwise.

Example

local pLabel = guiCreateLabel( 0.5, 0.5, 0.5, 0.5, 'Text', true )
guiLabelSetColor( pLabel, math.random( 0, 255 ), math.random( 0, 255 ), math.random( 0, 255 ) )

addCommandHandler( 'get_color_label', 
    function()
        local iR, iG, iB = guiLabelGetColor( pLabel )
        outputChatBox( ( 'Label color is r = %d, g = %d, b = %d' ):format( iR, iG, iB ) )
    end
)

See Also

General functions

Browsers

Buttons

Checkboxes

Comboboxes

Edit Boxes

Gridlists

Memos

Progressbars

Radio Buttons

Scrollbars

Scrollpanes

Static Images

Tab Panels

Tabs

Text Labels

Windows

Input

GUI