MTA:Eir/functions/engineCreateLight: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ 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. T...")
 
Line 25: Line 25:
light.setParent( lightFrame ); -- attaches the light to its frame, the light can now be active in the world.
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
light.addToScene(); -- activates the light object, so it illuminates its surroundings
lightFrame.setPosition( 0, 0, 10 ); -- repositions the light
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Revision as of 22:21, 6 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 or spot_soft (currently only point works)

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