vsTASKER 7 User Manual
×
Menu
Index

Lamp

 
A Lamp is a textured or not Sprite that can change color or texture according to various states.
The states are user controlled from the code.
 
 
On the HMI grid, add a Lamp:
or
 
 
Give it a name, then open the property window.
 
Select the Visual Aspect button and then Textures
 
Let's give to our lamp the pb_off.tga and pb_on.tga textures located in /Data/Hmi/Electrical
 
Now, time to connect the rotator to an entity speed.
 
In Initialization panel, RESET, put:
entity = S:findEntity("ac");
Vt_Entity* entity; is already defined in Vt_Base and Vt_Sprite inherit from Vt_Base, so, needless to redefine it locally.
 
In the Runtime panel, put the following code:
 if (entity->getSpeed()>100) set(1);  // select texture id 1, pb_on.tga
 else set(0);                         // select texture id 0, pb_off.tga
 
Back in the Terrain scenario, add one entity, name it "ac", compile run.
During the runtime, set the entity speed to "140" m/s (using the hook window) and see the lamp changing from Off to On.
 
 
In this example, we will not use texture but we will paint our lamp from the code.
To process, to the above but do not load any texture.
Change the shape from Rectangle to Circle.
 
In the Runtime panel, put the following code:
 if (entity->getSpeed()>10) paint(clBlue);
 else paint(clRed);
 
And at runtime, you will get the following:
changing to when entity speed get greater than 10 m/s.