SetTrafficLightState: Difference between revisions
Jump to navigation
Jump to search
(Fixxed Bot Section) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool setTrafficLightState ( int state ) | bool setTrafficLightState ( int state ) | ||
</syntaxhighlight> | |||
<syntaxhighlight lang="lua"> | |||
bool setTrafficLightState ( string state ) | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="lua"> | |||
bool setTrafficLightState ( string colorNS, string colorEW ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''state''': | *'''state''': If an integer is provided, the [[Traffic_light_states|state]] you wish to use (possible values: 0-9). Else, one of the following strings: | ||
**'''auto''': Sets the traffic lights default behavior (switches the colors automatically). | |||
**'''disabled''': Turns traffic lights off. | |||
Alternatively, you can provide two string parameters ('''colorNS''' and '''colorEW''') with the colors for north-south and east-west traffic lights respectively. Valid colors are: | |||
*'''green''' | |||
*'''yellow''' | |||
*'''red''' | |||
===Returns=== | ===Returns=== | ||
Line 36: | Line 48: | ||
==See Also== | ==See Also== | ||
{{World_functions}} | {{World_functions}} | ||
Latest revision as of 08:20, 18 November 2014
Sets the current traffic light state. This state controls the traffic light colors. For instance, state 1 will cause the north and south traffic lights to be amber, and the ones left and east will turn red.
Syntax
bool setTrafficLightState ( int state )
bool setTrafficLightState ( string state )
bool setTrafficLightState ( string colorNS, string colorEW )
Required Arguments
- state: If an integer is provided, the state you wish to use (possible values: 0-9). Else, one of the following strings:
- auto: Sets the traffic lights default behavior (switches the colors automatically).
- disabled: Turns traffic lights off.
Alternatively, you can provide two string parameters (colorNS and colorEW) with the colors for north-south and east-west traffic lights respectively. Valid colors are:
- green
- yellow
- red
Returns
Returns true if the state was successfully set, false otherwise.
Example
This example causes all traffic lights to be out of order. (flashing amber)
function handleTrafficLightsOutOfOrder() -- See if the lights are currently off local lightsOff = getTrafficLightState() == 9 if lightsOff then -- If they're off, turn them on setTrafficLightState(6) else -- If they're on, turn them off setTrafficLightState(9) end end -- Repeat it every half a second setTimer(handleTrafficLightsOutOfOrder,500,0)
See Also
- areTrafficLightsLocked
- getAircraftMaxHeight
- getAircraftMaxVelocity
- getCloudsEnabled
- getFarClipDistance
- getFogDistance
- getGameSpeed
- getGravity
- getHeatHaze
- getInteriorSoundsEnabled
- getJetpackMaxHeight
- getMinuteDuration
- getMoonSize
- getOcclusionsEnabled
- getRainLevel
- getSunColor
- getSunSize
- getTime
- getTrafficLightState
- getWeather
- getWindVelocity
- getSkyGradient
- getPlayerBlurLevel
- getZoneName
- isGarageOpen
- removeWorldModel
- resetFarClipDistance
- resetFogDistance
- resetHeatHaze
- resetMoonSize
- resetRainLevel
- resetSkyGradient
- resetSunColor
- resetSunSize
- resetWindVelocity
- restoreAllWorldModels
- restoreWorldModel
- setAircraftMaxHeight
- setAircraftMaxVelocity
- setCloudsEnabled
- setFarClipDistance
- setFogDistance
- setGameSpeed
- setGarageOpen
- setGravity
- setHeatHaze
- setInteriorSoundsEnabled
- setMinuteDuration
- setMoonSize
- setOcclusionsEnabled
- setRainLevel
- setSkyGradient
- setSunColor
- setSunSize
- setTime
- setTrafficLightState
- setTrafficLightsLocked
- setWeather
- setWeatherBlended
- setWindVelocity
- setJetpackMaxHeight
- setPlayerBlurLevel