This is a modification of Conitec's material.wdl script(you don't have to use it with the templates). The point of the mod was so you could have different global material settings for each level. The major change was turning the "_mat_setup" function into an action and allowing the level designer to use the skills of the entity that action gets assigned to to influence the material values. You can still affect individual entities by using normal local materials(my.material = ???;").

Anyway, I consider this one of my most important scripts in my project, but not so much so that I can't share it. Simply replace the _mat_setup function with the action below and it's ready for use. Assign that action, and set the appropriate skills. It would probably be beneficial to DEFINE each skill to make it easier to comprehend.


Code:

//////////////////////////////////////////////////////////////////////
//title: Material Setup

action _mat_setup
{
var yes;
var color;
my.invisible = on;
my.passable = on;
//entry: Realtime material adjustment (0 = no, 1 = yes)
//help: Set this to 1 for enabling material adjustment in real time.
//help: During runtime, press [M] for adjusting default materials.
//help: The selected material and property appears below on the screen.
//help: [M] toggles the default material to adjust.
//help: Cursor up / down select different material properties.
//help: Cursor left / right change the value.
//help: [Esc] quits.
yes = 1;
if (yes) { on_m = _mat_adjust; }

//entry: Default material adjustment (0 = no, 1 = yes)
//help: Set this to 1 for overriding the default material properties
//help: by the values set below.
yes = 1;
if (!yes) { return; }

//section: Material for shaded blocks (mat_shaded) --------------------
_mat = mat_shaded;

//entry: Emissive (0..255)
//help: Adjust the emissive value to set the brightness of the material
//help: regardeless of it's environment.
color = my.skill1;
_mat_set(_mat.emissive_blue,color);

//entry: Ambient (0..255)
//help: Adjust the ambient value to set the influence of
//help: static lights and entity and camera ambient.
color = my.skill2;
_mat_set(_mat.ambient_blue,color);

//entry: Diffuse (0..255)
//help: Adjust this value to set the diffuse reflection
//help: of the sun or dynamic lights.
color = my.skill3;
_mat_set(_mat.diffuse_blue,color);

//entry: Specular (0..255)
//help: Adjust this value to set the specular reflection
//help: of the sun or dynamic lights (also influenced by Power).
//help: This can be used to create a metal or plastic look.
color = my.skill4;
vec_set(_mat.specular_blue,color);

//entry: Power (0..10)
//help: Adjust this value to set 'sharpness for specular reflections.
//help: Higher values give the material a 'plastic' look.
color = my.skill5;
_mat_set(_mat.power,color);

//entry: Albedo (0..100)
//help: Adjust this value to set the reflection of sunlight
//help: depending on the entities' static environment light.
//help: Low values disable any effect of sun light,
//help: high values enable sun light even in dark places.
color = my.skill6;
vec_set(_mat.albedo,color);

//section: Material for flat blocks (mat_flat) ------------------------
_mat = mat_flat;

//entry: Emissive (0..255)
//help: Adjust the emissive value to set the brightness of the material
//help: regardeless of it's environment.
color = my.skill7;
_mat_set(_mat.emissive_blue,color);

//entry: Ambient (0..255)
//help: Adjust the ambient value to set the influence of
//help: static lights and entity and camera ambient.
color = my.skill8;
_mat_set(_mat.ambient_blue,color);

//entry: Diffuse (0..255)
//help: Adjust this value to set the diffuse reflection
//help: of the sun or dynamic lights.
color = my.skill9;
_mat_set(_mat.diffuse_blue,color);

//entry: Specular (0..255)
//help: Adjust this value to set the specular reflection
//help: of the sun or dynamic lights (also influenced by Power).
//help: This can be used to create a metal or plastic look.
color = my.skill10;
vec_set(_mat.specular_blue,color);

//entry: Power (0..10)
//help: Adjust this value to set 'sharpness for specular reflections.
//help: Higher values give the material a 'plastic' look.
color = my.skill11;
_mat_set(_mat.power,color);

//entry: Albedo (0..100)
//help: Adjust this value to set the reflection of sunlight
//help: depending on the entities' static environment light.
//help: Low values disable any effect of sun light,
//help: high values enable sun light even in dark places.
color = my.skill12;
vec_set(_mat.albedo,color);

//section: Material for terrain (mat_terrain) -------------------------
_mat = mat_terrain;

//entry: Emissive (0..255)
//help: Adjust the emissive value to set the brightness of the material
//help: regardeless of it's environment.
color = my.skill13;
_mat_set(_mat.emissive_blue,color);

//entry: Ambient (0..255)
//help: Adjust the ambient value to set the influence of
//help: static lights and entity and camera ambient.
color = my.skill14;
_mat_set(_mat.ambient_blue,color);

//entry: Diffuse (0..255)
//help: Adjust this value to set the diffuse reflection
//help: of the sun or dynamic lights.
color = my.skill15;
_mat_set(_mat.diffuse_blue,color);

//entry: Specular (0..255)
//help: Adjust this value to set the specular reflection
//help: of the sun or dynamic lights (also influenced by Power).
//help: This can be used to create a metal or plastic look.
color = my.skill16;
vec_set(_mat.specular_blue,color);

//entry: Power (0..10)
//help: Adjust this value to set 'sharpness for specular reflections.
//help: Higher values give the material a 'plastic' look.
color = my.skill17;
_mat_set(_mat.power,color);

//entry: Albedo (0..100)
//help: Adjust this value to set the reflection of sunlight
//help: depending on the entities' static environment light.
//help: Low values disable any effect of sun light,
//help: high values enable sun light even in dark places.
color = my.skill18;
vec_set(_mat.albedo,color);

//section: Material for models (mat_model) ----------------------------
_mat = mat_model;

//entry: Emissive (0..255)
//help: Adjust the emissive value to set the brightness of the material
//help: regardeless of it's environment.
color = my.skill19;
_mat_set(_mat.emissive_blue,color);

//entry: Ambient (0..255)
//help: Adjust the ambient value to set the influence of
//help: static lights and entity and camera ambient.
color = my.skill20;
_mat_set(_mat.ambient_blue,color);

//entry: Diffuse (0..255)
//help: Adjust this value to set the diffuse reflection
//help: of the sun or dynamic lights.
color = my.skill21;
_mat_set(_mat.diffuse_blue,color);

//entry: Specular (0..255)
//help: Adjust this value to set the specular reflection
//help: of the sun or dynamic lights (also influenced by Power).
//help: This can be used to create a metal or plastic look.
color = my.skill22;
vec_set(_mat.specular_blue,color);

//entry: Power (0..10)
//help: Adjust this value to set 'sharpness for specular reflections.
//help: Higher values give the material a 'plastic' look.
color = my.skill23;
_mat_set(_mat.power,color);

//entry: Albedo (0..100)
//help: Adjust this value to set the reflection of sunlight
//help: depending on the entities' static environment light.
//help: Low values disable any effect of sun light,
//help: high values enable sun light even in dark places.
color = my.skil24;
vec_set(_mat.albedo,color);

//section: Material for sprites (mat_sprite) --------------------------
_mat = mat_sprite;

//entry: Emissive (0..255)
//help: Adjust the emissive value to set the brightness of the material
//help: regardeless of it's environment.
color = my.skil25;
_mat_set(_mat.emissive_blue,color);
_mat_set(_mat.emissive_green,color);
_mat_set(_mat.emissive_red,color);

//entry: Ambient (0..255)
//help: Adjust the ambient value to set the influence of
//help: static lights and entity and camera ambient.
color = my.skill26;
_mat_set(_mat.ambient_blue,color);

//entry: Diffuse (0..255)
//help: Adjust this value to set the diffuse reflection
//help: of the sun or dynamic lights.
color = my.skill27;
_mat_set(_mat.diffuse_blue,color);

//entry: Specular (0..255)
//help: Adjust this value to set the specular reflection
//help: of the sun or dynamic lights (also influenced by Power).
//help: This can be used to create a metal or plastic look.
color = my.skill28;
vec_set(_mat.specular_blue,color);

//entry: Power (0..10)
//help: Adjust this value to set 'sharpness for specular reflections.
//help: Higher values give the material a 'plastic' look.
color = my.skill29;
_mat_set(_mat.power,color);

//entry: Albedo (0..100)
//help: Adjust this value to set the reflection of sunlight
//help: depending on the entities' static environment light.
//help: Low values disable any effect of sun light,
//help: high values enable sun light even in dark places.
color = my.skill30;
vec_set(_mat.albedo,color);

//section: Material for metal (mat_metal) -----------------------------
_mat = mat_metal;

//entry: Emissive (0..255)
//help: Adjust the emissive value to set the brightness of the material
//help: regardeless of it's environment.
color = my.skill31;
_mat_set(_mat.emissive_blue,color);

//entry: Ambient (0..255)
//help: Adjust the ambient value to set the influence of
//help: static lights and entity and camera ambient.
color = my.skill32;
_mat_set(_mat.ambient_blue,color);

//entry: Diffuse (0..255)
//help: Adjust this value to set the diffuse reflection
//help: of the sun or dynamic lights.
color = my.skill33;
_mat_set(_mat.diffuse_blue,color);

//entry: Specular (0..255)
//help: Adjust this value to set the specular reflection
//help: of the sun or dynamic lights (also influenced by Power).
//help: This can be used to create a metal or plastic look.
color = my.skill34;
vec_set(_mat.specular_blue,color);

//entry: Power (0..10)
//help: Adjust this value to set 'sharpness for specular reflections.
//help: Higher values give the material a 'plastic' look.
color = my.skill35;
_mat_set(_mat.power,color);

//entry: Albedo (0..100)
//help: Adjust this value to set the reflection of sunlight
//help: depending on the entities' static environment light.
//help: Low values disable any effect of sun light,
//help: high values enable sun light even in dark places.
color = my.skill36;
vec_set(_mat.albedo,color);

//section: Material for dynamic shadows (mat_shadow) ------------------
_mat = mat_shadow;

//entry: Alpha (0..100)
//help: Adjust this value to set the opacity of dynamic shadows.
_mat.alpha = my.skill37;
}



Also, note that you can toggle OFF the materials panel with the "R" key instead of the ESC. This prevents the level from exiting when you want to turn it off. Simply alter the "if(key_esc)" part at the beginning of the "_mat_adjust" function with the code below:

Code:

if (key_r)
{
_matset_txt.visible = off;
freeze_mode = 0;
return;
}




My User Contributions master list - my initial post links are down but scroll down page to find list to active links