Blockland Forums > Modification Help

Whats wrong with this script?

Pages: (1/1)

Cyanian:

Well when I put it on it works fine but then as soon as I take it off it crashes me.

Why?


--- Code: ---datablock ItemData(SuperSuitItem)
{
category = "Item";  // Mission editor category

equipment = true;

//its already a member of item namespace so dont break it
//className = "Item"; // For inventory system

// Basic Item Properties
shapeFile = "./SuperSuit.dts";
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "SuperSuit";
iconName = "./SuperSuit";
doColorShift = false;
colorShiftColor = "0.200 0.200 0.200 1.000";

// Dynamic properties defined by the scripts
image = SuperSuit1Image;
canDrop = true;
};

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(SuperSuit1Image)
{
   // Basic Item properties
   shapeFile = "base/data/shapes/empty.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0.13 0.2 -0.8";
   rotation = eulerToMatrix("0 0 0");
   eyeOffset = "0.13 0.2 -0.8";
   eyeRotation = eulerToMatrix("0 0 0");

   doColorShift = true;
colorShiftColor = SuperSuitItem.colorShiftColor;
   

   // When firing from a point offset from the eye, muzzle correction
   // will adjust the muzzle vector to point to the eye LOS point.
   // Since this weapon doesn't actually fire from the muzzle point,
   // we need to turn this off. 
   correctMuzzleVector = false;

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "ToolImage";

   // Projectile && Ammo.
   item = SuperSuitItem;

   //melee particles shoot from eye node for consistancy
   melee = true;
   //raise your arm up or not
   armReady = false;

   doColorShift = true;
   colorShiftColor = SuperSuitItem.colorShiftColor; //"0.200 0.200 0.200 1.000";

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.5;
stateTransitionOnTimeout[0]       = "Ready";


stateName[1]                     = "Ready";
stateScript[1]                  = "onUse";
stateTransitionOnTriggerDown[1]  = "Fire";
stateAllowImageChange[1]         = true;


stateName[2]                    = "Fire";
stateTransitionOnTriggerUp[2] = "Ready";
stateScript[2]                  = "onFire";
};

datablock ShapeBaseImageData(SSArmor1Image)
{
   // Basic Item properties
   shapeFile = "./empty.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = 0; //"0.7 1.2 -0.5";
   rotation = eulerToMatrix("0 0 0");
   eyeRotation = eulerToMatrix("0 0 0");

   doColorShift = False;
colorShiftColor = SuperSuitItem.colorShiftColor;
   

   // When firing from a point offset from the eye, muzzle correction
   // will adjust the muzzle vector to point to the eye LOS point.
   // Since this weapon doesn't actually fire from the muzzle point,
   // we need to turn this off. 
   correctMuzzleVector = false;

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "ToolImage";

   // Projectile && Ammo.
   item = SuperSuitItem;

   //melee particles shoot from eye node for consistancy
   melee = false;
   //raise your arm up or not
   armReady = true;


   doColorShift = true;
   colorShiftColor = SuperSuitItem.colorShiftColor; //"0.200 0.200 0.200 1.000";

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.5;
stateTransitionOnTimeout[0]       = "Ready";

stateName[1]                     = "Ready";
};

datablock ShapeBaseImageData(SuperSuit2Image)
{
   // Basic Item properties
   shapeFile = "./SuperSuit.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 2;
   offset = "0 0.05 -0.5";
   rotation = eulerToMatrix("0 0 0");
   eyeOffset = "0.65 1 5.1";
   eyeRotation = eulerToMatrix("0 0 0");

   doColorShift = true;
colorShiftColor = SuperSuitItem.colorShiftColor;
   

   // When firing from a point offset from the eye, muzzle correction
   // will adjust the muzzle vector to point to the eye LOS point.
   // Since this weapon doesn't actually fire from the muzzle point,
   // we need to turn this off. 
   correctMuzzleVector = false;

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "ToolImage";

   // Projectile && Ammo.
   item = SuperSuitItem;

   //melee particles shoot from eye node for consistancy
   melee = false;
   //raise your arm up or not
   armReady = false;

   doColorShift = true;
   colorShiftColor = SuperSuitItem.colorShiftColor; //"0.200 0.200 0.200 1.000";

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.5;
stateTransitionOnTimeout[0]       = "Ready";

stateName[1]                     = "Ready";
};

//called when you click with it on.
function SuperSuit1Image::onFire(%this, %obj, %slot)
{
%client = %obj.client;
if(%client.player.SSArmoron == 0)
{
//set your datablock to parachuting
//%client.player.setDataBlock("PlayerSuperSuit");
//hide any backpack items if you are wearing them
%obj.hidenode(cape);
%obj.hidenode(pack);
%obj.hidenode(quiver);
%obj.hidenode(tank);
%obj.hidenode(armor);
%obj.hidenode(bucket);
          %obj.client.centerPrint("\c6You put on the Super Suit.",3);
//mount the Body Armor and unmount the un-Body Armoring Armor (confusing, I know)
%client.player.unmountimage(2);
%client.player.mountimage(SuperSuit2image, 2);
%client.player.SSArmoron = 1;
}else{
%client.player.SSArmoron = 0;
//reset your datablock
//if(!isObject(%client.minigame))
//{
// %client.player.setDataBlock("PlayerStandardArmor");
//}else{
// %client.player.setdatablock(%client.minigame.playerDatablock);
//}
//unmount the Armor
%client.player.unmountimage(2);
//Re-mount the FakeArmor
%client.player.mountImage(SuperSuit1Image, 2);
//and rehide this stuff here
%obj.hidenode(cape);
%obj.hidenode(pack);
%obj.hidenode(quiver);
%obj.hidenode(tank);
%obj.hidenode(armor);
%obj.hidenode(bucket);
          %obj.client.centerPrint("\c6You took off the Super Suit.",3);
}
}

//Old method
//Armor Player datablock
//datablock PlayerData(PlayerSuperSuit : PlayerStandardArmor)
//{
// canJet = 0;
//    maxDamage = 150;
// uiname = "SuperSuit Player";
//};

//mounts the Armor when you equip it
function SSArmor1image::onMount(%this,%user)
{
%user.playthread(1,root);
if(%user.SSArmoron)
{
return;
}

%user.mountimage(SuperSuit1image, 2);
%obj = %user;
%obj.hidenode(cape);
%obj.hidenode(pack);
%obj.hidenode(quiver);
%obj.hidenode(tank);
%obj.hidenode(armor);
%obj.hidenode(bucket);
}

function SuperSuit1image::onUnMount(%this,%user)
{
if(%user.SSArmoron)
{
return;
}
%user.unmountimage(2);
%user.client.applybodyparts();
}

package SSArmord
{
   function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
   {
      if(%obj.SSArmorOn)
      {
         %damage *= 0.25; //Half the damage
      }
      Parent::damage(%this, %obj, %sourceObject, %position, %damage, %damageType);
   }
};
activatePackage(SSArmord);
     
--- End code ---




Amade:

Unmounting the image within its unmount function is going to create an infinite loop.

Cyanian:


--- Quote from: Amade on July 10, 2010, 03:29:20 PM ---Unmounting the image within its unmount function is going to create an infinite loop.

--- End quote ---
Ok, which would cause the crash.

How to fix?

Munkey:

I got it working for Cyanian.

Pages: (1/1)

Go to full version