SetSearchLightEndPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(2 intermediate revisions by 2 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 end position of a [[Element/Searchlight|searchlight]] element.}}


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
searchlight setSearchLightEndPosition ( searchlight theSearchLight, float endX, float endY, float endZ )
bool setSearchLightEndPosition ( searchlight theSearchLight, float endX, float endY, float endZ )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[Element/Searchlight|SearchLight]]:setEndPosition|endPosition|getSearchLightEndPosition}}
{{OOP||[[Element/Searchlight|searchLight]]:setEndPosition|endPosition|getSearchLightEndPosition}}


===Required Arguments===
===Required Arguments===

Latest revision as of 11:12, 20 March 2019

Syntax

bool setSearchLightEndPosition ( searchlight theSearchLight, float endX, float endY, float endZ )

OOP Syntax Help! I don't understand this!

Method: searchLight:setEndPosition(...)
Variable: .endPosition
Counterpart: getSearchLightEndPosition


Required Arguments

  • theSearchLight: the searchlight to modify the property of.
  • endX: the X coordinate where the searchlight light cone will end.
  • endY: the Y coordinate where the searchlight light cone will end.
  • endZ: the Z coordinate where the searchlight light cone will end.

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 to the front of it.

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

if searchLight then
    local function updateSearchLight()
        -- Get camera position and look at point
        local sx, sy, sz, ex, ey, ez = getCameraMatrix()
        -- Set searchlight's start position to the camera position, and end position to the look at point
        setSearchLightStartPosition(searchLight, sx, sy, sz)
        setSearchLightEndPosition(searchLight, ex, ey, ez)
    end
    addEventHandler("onClientPreRender", root, updateSearchLight)
end

See also