Building Objects in Second Life
As I have mentioned in the previous blog, a prim is a 3D shape which can be linked to form shapes either larger or smaller sizes.To start building, right click on the ground and select 'Build'. A 'Build Toolbox' will appear on screen and the mouse cursor will be turned into a magic wand so that you can click on the ground and a plywood looking shape will be created. Using this toolbox, you can move the shape, rotate (Ctrl), stretch (Ctrl+Shift) and Select face. You can also do this using the X, Y, Z coordinates found in the 'Object' tab using, 'Position (meters)', 'Size (meters)' and 'Rotation (degrees)'. The material of the object can also be chosen; whether Stone, Metal, Glass, Wood, Flesh, Plastic or Rubber. Various shapes can be chosen; such as Box, Cylinder, Prism, Sphere, Torus, Tube, Ring or Sculpted. In the 'Texture' tab, you can add texture, color, transparency and glow to the object. If you have created multiple objects and would like to join them together, you can use the 'link' tool, either from 'Build -> Link' or using (Ctrl+L).
Build Toolbox |
When scripting in second life, you always have to start with the 'default' keyword. The default word is used to specify the name of the state that the code enclised belongs to. The following is a script that is generated automatically by second life when a new script is created:
1: default
2: {
3: state_entry()
4: {
5: llSay(0, "Hello, Avatar!");
6: }
7: touch_start(integer total_number)
8: {
9: llSay(0, "Touched.");
10: }
11: }
The state_entry()
event takes place each time a new state is entered. Using llSay()
, whenever the script is saved or reset, "Hello, Avatar!" will be written in the chat pop up and "Touched" will be written in the chat pop up when touched using touch_start()
event.I modified the above code so that when the object will be touched it will be turned into one colour and when the object is touched again, it will be turned into another colour as shown in lines 1-24.
1: default
2: {
3: state_entry()
4: {
5: llSay(0, "turning on!");
6: llSetColor(<1.0, 0.0, 1.0>, ALL_SIDES);
7: }
8: touch_start(integer total_number)
9: {
10: state off;
11: }
12: }
13: state off
14: {
15: state_entry()
16: {
17: llSay(0, "turning off!");
18: llSetColor(<0.0, 1.0, 0.0>, ALL_SIDES);
19: }
20: touch_start(integer total_number)
21: {
22: state default;
23: }
24: }
In the above code, when the object is turned on, it will turn into pink from all sizes and when the object is turned off, it will turn green.Object turned off |
Object turned on |
No comments:
Post a Comment