DgsSetAlpha: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(fix type in the syntax)
 
(5 intermediate revisions by 2 users not shown)
Line 6: Line 6:
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd -->
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool dgsDxGUISetAlpha ( element guielement, float alpha )
bool dgsSetAlpha ( element theElement, float alpha )
</syntaxhighlight>  
</syntaxhighlight>
{{DGS/OOP|
    Note = DGSElement:setAlpha|
    Variable = alpha|
    Counterpart = dgsGetAlpha
}}


===Required Arguments===  
===Required Arguments===  
*'''guiElement:''' the DGS element whose visibility is to be changed
*'''guiElement:''' the DGS element whose visibility is to be changed
*'''alpha:''' The visibility/transparency of the DGS element. Ranges from 0 (fully transparent) to 1 (fully opaque). Default value is 0.80.
*'''alpha:''' The visibility/transparency of the DGS element. Ranges from 0 (fully transparent) to 1 (fully opaque). Default value is 1.


===Returns===
===Returns===
Line 20: Line 25:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
DGS = exports.dgs
DGS = exports.dgs
myWindow = DGS:dgsDxCreateWindow ( 0.30, 0.10, 0.5, 0.60, "DGS window title", true )
myWindow = DGS:dgsCreateWindow ( 0.30, 0.10, 0.5, 0.60, "DGS window title", true )


--Add a command handler to change the alpha of the DGS window.
--Add a command handler to change the alpha of the DGS window.
Line 26: Line 31:
function changeAlpha ( commandName, alphaAmount )
function changeAlpha ( commandName, alphaAmount )
alphaAmount = tonumber(alphaAmount)
alphaAmount = tonumber(alphaAmount)
DGS:dgsDxGUISetAlpha ( myWindow, alphaAmount )
DGS:dgsSetAlpha ( myWindow, alphaAmount )
end
end
addCommandHandler ( "alpha", changeAlpha )
addCommandHandler ( "alpha", changeAlpha )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
=See Also=
{{DGSFUNCTIONS}}
 
==<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Functions</span>==
{{DGS General Functions}}
 
==<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Events</span>==
{{DGS Events/General}}

Latest revision as of 15:14, 12 March 2023

This changes the alpha level (the visibleness/transparency) of a DGS element

Syntax

bool dgsSetAlpha ( element theElement, float alpha )

DGS OOP Syntax Help! I don't understand this!

Note: DGSElement:setAlpha
Variable: .alpha
Counterpart: dgsGetAlpha

Required Arguments

  • guiElement: the DGS element whose visibility is to be changed
  • alpha: The visibility/transparency of the DGS element. Ranges from 0 (fully transparent) to 1 (fully opaque). Default value is 1.

Returns

Returns true if the dgs element's alpha was successfully changed, false otherwise.

Example

This creates a DGS window and allows a player to change it's alpha (the visibleness/transparency) value with a command.

DGS = exports.dgs
myWindow = DGS:dgsCreateWindow ( 0.30, 0.10, 0.5, 0.60, "DGS window title", true )

--Add a command handler to change the alpha of the DGS window.
--Usage example: '/alpha 0.8', where 0.8 is stored as alphaAmount
function changeAlpha ( commandName, alphaAmount )
	alphaAmount = tonumber(alphaAmount)
	DGS:dgsSetAlpha ( myWindow, alphaAmount )
end
addCommandHandler ( "alpha", changeAlpha )

See Also

General Functions

General Events