SetSearchLightStartPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Documented function introduced in 7683)
 
No edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
{{New feature/item|3.0160|1.6|7683|This function sets the start position of a [[Element/Searchlight|searchlight]] element.}}
 
This function sets the start position of a [[Element/Searchlight|searchlight]] element.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
searchlight setSearchLightStartPosition ( float startX, float startY, float startZ )
bool setSearchLightStartPosition ( searchlight theSearchLight, float startX, float startY, float startZ )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[Element/Searchlight|SearchLight]]:setStartPosition|startPosition|getSearchLightStartPosition}}
{{OOP||[[Element/Searchlight|searchLight]]:setStartPosition|startPosition|getSearchLightStartPosition}}


===Required Arguments===
===Required Arguments===
*'''theSearchLight''': the searchlight to modify the property of.
*'''startX''': the X coordinate where the searchlight light cone will start.
*'''startX''': the X coordinate where the searchlight light cone will start.
*'''startY''': the Y coordinate where the searchlight light cone will start.
*'''startY''': the Y coordinate where the searchlight light cone will start.
Line 24: Line 26:
if searchLight then
if searchLight then
     local function updateSearchLight()
     local function updateSearchLight()
        assert(searchLight, "Searchlight was deleted") -- We assume that the searchlight exists
         -- Set its start position to the camera position
         -- Set its start position to the camera position
         setSearchLightStartPosition(searchLight, getCameraMatrix())
         setSearchLightStartPosition(searchLight, getCameraMatrix())

Latest revision as of 11:12, 20 March 2019

This function sets the start position of a searchlight element.

Syntax

bool setSearchLightStartPosition ( searchlight theSearchLight, float startX, float startY, float startZ )

OOP Syntax Help! I don't understand this!

Method: searchLight:setStartPosition(...)
Variable: .startPosition
Counterpart: getSearchLightStartPosition


Required Arguments

  • theSearchLight: the searchlight to modify the property of.
  • startX: the X coordinate where the searchlight light cone will start.
  • startY: the Y coordinate where the searchlight light cone will start.
  • startZ: the Z coordinate where the searchlight light cone will start.

Returns

If every argument is correct, this function returns true. If not, it will return false plus an error message.

Example

This example creates a searchlight that originates in the camera position and targets the center of the map.

local searchLight = createSearchLight(0, 0, 0, 0, 0, 0, 0, 10)

if searchLight then
    local function updateSearchLight()
        -- Set its start position to the camera position
        setSearchLightStartPosition(searchLight, getCameraMatrix())
    end
    addEventHandler("onClientPreRender", root, updateSearchLight)
end

See also