Down below is the first Grafton example converted to WDL. Just save this code as something like "grafton1.wdl", then include it in your main script file right above your other includes, like this:

include <grafton1.wdl>;

It seems like only one entity can emit a spotlight at a time with this code, but as many entities as you need can be spotlit. You can either assign the "action Spotlight()" to your player and "action Spotlit_object()" to the entities to be spotlit, or you can do the following:

Place the following code somewhere in a while loop for the entity to emit the spotlight, like the player:

Code:
 
// send my position to shader (vecSkill1.xyzw)
mtlSpotlit.skill1 = float(my.x);
mtlSpotlit.skill2 = float(my.z); // z and y must be reversed!
mtlSpotlit.skill3 = float(my.y);
mtlSpotlit.skill4 = float(650); // spotlights range

// send my direction to shader (vecSkill2.xyzw)
vec_for_angle(temp_vec.x, vector((my.pan), my.tilt, my.roll)); //turn my angles into a dir vector
mtlSpotlit.skill5 = float(temp_vec.x);
mtlSpotlit.skill6 = float(temp_vec.z); // z and y must be reversed!
mtlSpotlit.skill7 = float(temp_vec.y);



And you can put this little code in any script linked to an entity you want spotlit:

Code:
 
my.material = mtlSpotlit;



Alternatively, you could just assign the "mtlSpotlit" material in WED to any entities you want spotlit, since many of your entites may not even have or need a C-Script.

The following is the code for the spotlight. Just use the "PP_Spot.fx" file from the Grafton example.

Code:
 
//
// By Joseph Duffey Jan 2008
// For the GameStudio Community
//
// Converted to WDL format by Reigel Seven 2008
//
// Example 1: Projective Texturing Spotlight with specular

//=======================================================================================
// VARIABLES
//=======================================================================================

var temp_vec[3]; // for temporary vectors
FONT standard_font = "Arial",1,14;

var pTexAdj[16];

//=======================================================================================
// CAMERA ACTION
//=======================================================================================

action Spectator()
{
//set(me,INVISIBLE | PASSABLE);
my.invisible = on;
my.passable = on;

// while(!player)
// {
// wait(1);
// }
vec_set(camera.x, my.x);

while(me)
{
vec_set(temp_vec,player.x);
vec_sub(temp_vec,camera.x);
vec_to_angle(camera.pan,temp_vec);
wait(1);
}
}

//=======================================================================================
// MATERIAL FOR OBJECTS LIT BY SPOTLIGHT
//=======================================================================================

MATERIAL mtlSpotlit
{
ambient_red = 12; // The ambient color - a dark grey.
ambient_green = 10;
ambient_blue = 8;
effect = "PP_Spot.fx"; // The effect file containing the vertex shader, pixel shader and technique.
}

//=======================================================================================
// SPOTLIGHT CODE
//=======================================================================================

action Spotlight()
{
//player = me;
while(1)
{
// move me with keyboard keys
// c_move(me, vector((key_w - key_s)*time_step*8,0,0), nullvector, IGNORE_PASSABLE | GLIDE);
// c_rotate(me, vector((key_cul-key_cur)*time_step*8, (key_cuu-key_cud)*time_step*8,0), IGNORE_PASSABLE );

// send my position to shader (vecSkill1.xyzw)
mtlSpotlit.skill1 = float(my.x);
mtlSpotlit.skill2 = float(my.z); // z and y must be reversed!
mtlSpotlit.skill3 = float(my.y);
mtlSpotlit.skill4 = float(650); // spotlights range

// send my direction to shader (vecSkill2.xyzw)
vec_for_angle(temp_vec.x, vector((my.pan), my.tilt, my.roll)); //turn my angles into a dir vector
mtlSpotlit.skill5 = float(temp_vec.x);
mtlSpotlit.skill6 = float(temp_vec.z); // z and y must be reversed!
mtlSpotlit.skill7 = float(temp_vec.y);

wait(1);
}
}

//=======================================================================================
// ACTION FOR OBJECTS LIT BY SPOTLIGHT
//=======================================================================================

action Spotlit_object()
{
my.material = mtlSpotlit;
}



I'm afraid I may have forgotten something, so please let me know if I did. I hope this helps somebody!

- Reigel Seven