SetLightRadius: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (anywhere else "light" start from lowercase letter)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
{{Needs_Example}}
 


{{New feature/item|3.0150|1.5.0|7048|
{{New feature/item|3.0150|1.5.0|7048|
Line 9: Line 9:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setLightRadius ( Light theLight, float radius )
bool setLightRadius ( light theLight, float radius )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[light]]:setRadius|radius|getLightRadius}}
{{OOP||[[light]]:setRadius|radius|getLightRadius}}
Line 20: Line 20:


===Example===
===Example===
<syntaxhighlight lang="lua">[Lua]
<syntaxhighlight lang="lua">
local light = createLight(0, 2, 3, 4)
local light = createLight(0, 2, 3, 4)
addCommandHandler("setradiusoflight",
addCommandHandler("setradiusoflight",

Latest revision as of 20:28, 15 February 2021


This function sets the radius for a light element.

Syntax

bool setLightRadius ( light theLight, float radius )

OOP Syntax Help! I don't understand this!

Method: light:setRadius(...)
Variable: .radius
Counterpart: getLightRadius


Required Arguments

  • theLight: The light that you wish to set the radius of.

Returns

Returns true if the function was successful, false otherwise.

Example

local light = createLight(0, 2, 3, 4)
addCommandHandler("setradiusoflight",
	function(cmd, radius)
		if radius then
			if tonumber(radius) > 0 then
				setLightRadius(light, tonumber(radius))
			else
				outputChatBox("Radius must be greater than 0.")
			end
		else
			outputChatBox("You must specify a radius.")
		end
	end
)

See also