Skyline Lua API  Version 1.0
Lua Script Reference for Skyline Game Engine.
light Class Reference

#include <LUA_API_Light.h>

Public Member Functions

void setIntensity (int lightID, float intensityValue)
 Set the Intensity(Brightness) of a light. This is an accumulative effect. More...
 
void setBrightness (int lightID, float intensityValue)
 Set the absolute setBrightness of a light. More...
 
void setRange (int lightID, float rangeValue)
 Set the Range of the light, this will affect how far the light will reach.
Entities outside the range of the light will not be lit. More...
 
void setDiffuseColor (int lightID, float colR, float colG, float colB)
 Set the Diffuse Color of the light. More...
 
float3 getDiffuseColor (int lightID)
 Get the Diffuse color of a specific light and return the color to a float3. More...
 
int setSpecularColor (int lightID, float colR, float colG, float colB)
 Set the Specular Color of the light. More...
 
float3 getSpecularColor (int lightID)
 Get the Specular color of a specific light and return the color to a float3. More...
 
int spawnLight (int lightType, float posx, float posy, float posz)
 Spawns a light to the arg pos and returns the id of this light. More...
 
void enableShadows (int lightID)
 Set the enable state of this lights shadows. More...
 

Detailed Description

The following light functions can be used to control the lighting in your scene. Use as light.function()
For more information on how these functions can be used please visit the User Manual - https://home.aurasoft-skyline.co.uk

intensity={}
intensity[0] = 1.1
intensity[1] = 0.9
intensity[2] = 1.2
intensity[3] = 0.8
intensity[4] = 1.1
intensity[5] = 0.8
intensity[6] = 1.3
intensity[7] = 0.8
intensity[8] = 1.1
intensity[9] = 1.18
intensity[10] = 0.9
intensity[11] = 1.3
intensity[12] = 0.7
intensity[13] = 1.2
intensity[14] = 0.9

count = 0
firstTimer = 0

obj = 0;
function onInit( objID )


    sky.lprint("script is active");

    obj = objID
    difR,difG,difB = light.getDiffuseColor(obj)
    rand = math.random(1,100)
    firstTimer = 1
    time.startTimer( 1, obj, 100 );



    sky.lprint("init complete");
end

function onTimer( )

    sky.lprint("timer.. running");


    if(firstTimer == 0)then
        if(count == 15)then 
            count = 0
        else
            value = intensity[count]
            light.setIntensity(obj,value)
            count = count + 1
        end
    else
        time.stopTimer( 1, obj )
        firstTimer = 0
        time.startTimer( 1, obj, 100 )
    end
end

function onStop( )
    time.stopTimer( 1, obj )
    light.setDiffuseColor(obj,difR,difG,difB)
end

Member Function Documentation

void light::enableShadows ( int  lightID)

Set the enable state of this lights shadows.

Parameters
lightID: The object id of the light.

The following is a Small Example on how to use this function:

function onInit(objID)
    light.enableShadows( lightID ); 
end
float3 light::getDiffuseColor ( int  lightID)

Get the Diffuse color of a specific light and return the color to a float3.

Parameters
lightID: Set the light you wish to get the Diffuse Color from.
Returns
colR : The Red Color of the light returned.
colG : The Green Color of the light returned.
colB : The Blue Color of the light returned.

The following is a Small Example on how to use this function:

function onInit(objID)
    r,g,b = light.getDiffuseColor( entity.getEntityIDFromTag("light_1") ); 
end
float3 light::getSpecularColor ( int  lightID)

Get the Specular color of a specific light and return the color to a float3.

Parameters
lightID: Set the light you wish to get the Specular Color from.
Returns
colR : The Red Color of the light returned.
colG : The Green Color of the light returned.
colB : The Blue Color of the light returned.

The following is a Small Example on how to use this function:

function onInit(objID)
    r,g,b = light.getSpecularColor( entity.getEntityIDFromTag("light_1") ); 
end
void light::setBrightness ( int  lightID,
float  intensityValue 
)

Set the absolute setBrightness of a light.

Parameters
lightID: Set the light you wish to set the intensity of.
brightness: set the Intensity of the light. Could also be called Brightness.

Note: the Intensity value if applied twice or more will do what the value tells it to do.

For Example:

this command will set a light to a fixed value provide in the functions arg.

The following is a Small Example on how to use this function:

function onInit(objID)
    light.setBrightness( entity.getEntityIDFromTag("light_1"), 0.5 ); 
end
void light::setDiffuseColor ( int  lightID,
float  colR,
float  colG,
float  colB 
)

Set the Diffuse Color of the light.

Parameters
lightID: Set the light you wish to set the Diffuse Color to.
colR: Set the red color of the light.
colG: Set the green color of the light.
colB: Set the blue color of the light.

The following is a Small Example on how to use this function:

function onInit(objID)
    light.setDiffuseColor( entity.getEntityIDFromTag("light_1"), 1, 0, 0 ); 
end
void light::setIntensity ( int  lightID,
float  intensityValue 
)

Set the Intensity(Brightness) of a light. This is an accumulative effect.

Parameters
lightID: Set the light you wish to set the intensity of.
intensityValue: set the Intensity of the light. Could also be called Brightness.

Note: the Intensity value if applied twice or more will do what the value tells it to do.

For Example:

This command is accumulative, by continually calling this command the brightness will keep increasing
To reduce the brightness per call, pass a decimal such as 0.5
The following is a Small Example on how to use this function:

function onInit(objID)
    light.setIntensity( entity.getEntityIDFromTag("light_1"), 2 ); 
end
void light::setRange ( int  lightID,
float  rangeValue 
)

Set the Range of the light, this will affect how far the light will reach.
Entities outside the range of the light will not be lit.

Parameters
lightID: Set the light you wish to set the range of.
rangeValue: Set the Range of the light

The following is a Small Example on how to use this function:

function onInit(objID)
    light.setRange( entity.getEntityIDFromTag("LIGHT :: Point"), 10 );
end
int light::setSpecularColor ( int  lightID,
float  colR,
float  colG,
float  colB 
)

Set the Specular Color of the light.

Parameters
lightID: Set the light you wish to set the Specular Color to.
colR: Set the red color of the light.
colG: Set the green color of the light.
colB: Set the blue color of the light.

The following is a Small Example on how to use this function:

function onInit(objID)
    light.setSpecularColor( entity.getEntityIDFromTag("light_1"), 1, 0, 0 ); 
end
int light::spawnLight ( int  lightType,
float  posx,
float  posy,
float  posz 
)

Spawns a light to the arg pos and returns the id of this light.

Parameters
lightType: Set the light type 0=directional, 1=point, 2=spot
posx: position x to spawn the light.
posy: position y to spawn the light.
posz: position z to spawn the light.
Returns
lightID : The id of the spwned light.

The following is a Small Example on how to use this function:

function onInit(objID)
    light.setDiffuseColor( entity.getEntityIDFromTag("light_1"), 1, 0, 0 ); 
end

The documentation for this class was generated from the following file: