2006.11.18, 11:18 AM
I need some help using code but i searched on google and all i got was tips on how to buy some book anyway if there is anyone who will help me i'd really appriciate( if thats how you spell it) it.
.//this is a comment after the double slash, comments do nothing
var number; //this creates a variable called number
function construct(obj) //this is a function, whenever you write construct(obj); it will do the follwowing script until the end bracket of the function
{ //this says that the function has started
number=3 //this makes number = 3
if (number==3) { //this says that if number = 3 then do the following
//code goes here for what should be done
} //end if, this is the closing bracket of the code
if (number!=3) { //this means if number does not = 3 then do the following
//foo
} //closing bracket
} //this bracket shows the end of the functionobj.motionVector.turnToPlayer();
.//
// events
//
function event(obj,mainEvent,subEvent,id,tick)
{
switch (mainEvent) {
case DIM3_EVENT_CONSTRUCT:
fyConstruct(obj);
return;
case DIM3_EVENT_SPAWN:
fySpawn(obj);
return;
case DIM3_EVENT_DIE:
fyDie(obj);
return;
case DIM3_EVENT_FALL:
fyFall(obj);
return;
case DIM3_EVENT_LAND:
fyHeightDeath(obj);
return;
case DIM3_EVENT_COLLIDE:
fyCollide(obj);
return;
case DIM3_EVENT_DAMAGE:
fyDamage(obj);
return;
}
} case DIM3_EVENT_DAMAGE: //if the object gets damaged
fyDamage(obj); //go to the fyDamage function
return; //end obj.model.on=true;
obj.model.name='FY Trooper';
obj.model.lit=DIM3_MODEL_LIT_VERTEX;
obj.model.shadow.on=true;
obj.setting.openDoors=false;
obj.setting.damage=true;
obj.setting.ignorePickUpItems=true; // don't pickup the weapons/ammo
obj.setting.hitBox=true;
obj.size.x=1768;
obj.size.z=875;
obj.size.y=3754;
obj.size.weight=230;
obj.health.maximum=15;
obj.health.start=15;
obj.setting.pushable=true;
obj.health.fallDamageMinimumHeight=2000;
obj.health.fallDamageFactor=1;
// setup weapon
obj.weapon.add('HL Launcher');
obj.weapon.add('HL Launcher alt');
.
function event(obj,mainEvent,subEvent,id,tick)
{
switch (mainEvent) {
case DIM3_EVENT_CONSTRUCT:
treeConstruct(obj);
return;
case DIM3_EVENT_SPAWN:
treeSpawn(obj);
return;
}
}function event(obj,mainEvent,subEvent,id,tick)
{
//Currently there is nothing in this function.
}function event(obj,mainEvent,subEvent,id,tick)
{
switch (mainEvent) {
case DIM3_EVENT_CONSTRUCT:
treeConstruct(obj); //Executes this
return; //And this etc
case DIM3_EVENT_SPAWN:
treeSpawn(obj);
return;
}
}default:
//functions, etc here
return;function treeConstruct(obj)
{
obj.model.on=true; //Makes the model visible
obj.model.name="Tree"; //Assigns the physical model to show -- make sure this model exists!
obj.model.lit=DIM3_MODEL_LIT_FLAT; //Assigns the method the engine uses to light the model
obj.model.shadow.on=true; //Tells whether the model has a shadow or not
obj.setting.suspend=true;
}function treeConstruct(obj)function treeSpawn(obj)
{
obj.size.x=3000; // force the tree to be smaller, need to do it here after model has been loaded
obj.size.z=3000;
obj.size.y=10000;
obj.model.animation.start("Idle"); //Tells the model to play its animation "Idle" which is assigned in the animator
}
Data/Scripts/Objects/Tree.js