DgsGetProperty: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Client function}} __NOTOC__ This function gets the value of a specific property of a DGS element. For a list of properties and their meaning, see the template:DGSPROPERTIE...")
 
m (DGS OOP Syntax changing)
 
(3 intermediate revisions by 2 users not shown)
Line 5: Line 5:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string dgsDxGUIGetProperty ( element dgsElement, string property )
string dgsGetProperty ( element dgsElement, string property )
</syntaxhighlight>
</syntaxhighlight>
{{DGS/OOP|
    Method = DGSElement:getProperty|
    Counterpart = dgsSetProperty
}}


===Required Arguments===
===Required Arguments===
Line 19: Line 23:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
DGS = exports.dgs
DGS = exports.dgs
button = DGS:dgsDxCreateButton(20, 200, 150, 30, "Test", false)
button = DGS:dgsCreateButton(20, 200, 150, 30, "Test", false)


addCommandHandler("togglebtn",function()
addCommandHandler("togglebtn",function()
local currentState = DGS:dgsDxGUIGetProperty(button, "enabled")
local currentState = DGS:dgsGetProperty(button, "enabled")
DGS:dgsDxGUISetProperty(button, "enabled", not currentState)
DGS:dgsSetProperty(button, "enabled", not currentState)
end)
end)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
=See Also=
{{DGSFUNCTIONS}}
 
==<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">DGS Properties</span>==
{{DGSPROPERTIES}}
 
==<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 19:37, 3 May 2021

This function gets the value of a specific property of a DGS element. For a list of properties and their meaning, see the DGS properties page.

Syntax

string dgsGetProperty ( element dgsElement, string property )

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

Method: DGSElement:getProperty(...)
Counterpart: dgsSetProperty

Required Arguments

  • dgsElement: the DGS element you wish to get a property of.
  • property: the name of of property you want the value of.

Returns

If the function succeeds, it returns a value of the property. An error will occur if failed.

Example

This example creates a button when the resource starts and defines a console command that toggles it between enabled (clickable) and disabled (not clickable).

DGS = exports.dgs
button = DGS:dgsCreateButton(20, 200, 150, 30, "Test", false)

addCommandHandler("togglebtn",function()
	local currentState = DGS:dgsGetProperty(button, "enabled")
	DGS:dgsSetProperty(button, "enabled", not currentState)
end)

See Also

DGS Properties

General Properties

Unique Properties For DGS Core Elements

Extra Properties For DGS Plugins

General Functions

General Events