MTA:Eir/functions/engineCreateLight: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 8: Line 8:


===Arguments===
===Arguments===
*'''type:''' decides which type that light should have, can be '''point''', '''spot''' or '''spot_soft''' (currently only '''point''' works)
*'''type:''' decides which type that light should have, can be '''point''', '''spot''', '''spot_soft''', '''directional''' or '''ambient''' (currently '''spot''' and '''spot_soft''' do not work)


===Returns===
===Returns===

Revision as of 13:27, 7 January 2014

This function creates a RenderWare RpLight object. A light is an object that affects its surrouding RpAtomic instances in a certain radius and casts effects on them. The most notable effect is the pointlight, that colors its surroundings based on attenuation settings.

Syntax

rplight engineCreateLight ( string type )

Arguments

  • type: decides which type that light should have, can be point, spot, spot_soft, directional or ambient (currently spot and spot_soft do not work)

Returns

Returns the rplight object if creation was successful, false otherwise.

Example

Click to collapse [-]
Client

This snippet creates a RenderWare light object and sets it up properly.

local light = engineCreateLight( "point" ); -- creates the new point light
light.setColor(1, 1, 1, 1); -- gives the point light a bright color
light.setAttenuation(0.8, 1.4, 4); -- makes the light fade somewhat
light.setRadius(100); -- makes the light affect atomics in a 100 unit radius

local lightFrame = engineCreateFrame(); -- create a 3D transformation for the light
light.setParent( lightFrame ); -- attaches the light to its frame, the light can now be active in the world.
light.addToScene(); -- activates the light object, so it illuminates its surroundings

lightFrame.setPosition( 0, 0, 10 ); -- repositions the light