Author Topic: Making armor script ; please help.  (Read 911 times)

My apologies, I am incredibly new to scripting and modding or whatever you want to call it.
Anyway I am attempting to make an Add-On for myself, or if it works anyone who is interested.
The concept of the script is to fetch your players health, and the negated amount of damage taken, I already know that in it's current state that wouldn't happen, and I would appreciate some help from the community, on getting this to work. Most of the formatting is probably utter stuff but whatever I'm very new to this (3 days). Thanks.

Code: [Select]
{
   $protec::using = 0
}

datablock ItemData(protecItem)
{
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system

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

//gui stuff
uiName = "Armor";
iconName = "./protec";
doColorShift = false;

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

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

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

   className = "WeaponImage";
   item = protecItem;

   //raise your arm up or not
   armReady = true;

   doColorShift = false;

   // Initial start up state
stateName[0]                     = "Ready";
stateTransitionOnTriggerDown[0]  = "Fire";
stateAllowImageChange[0]         = true;

stateName[1]                     = "Fire";
stateTransitionOnTimeout[1]      = "Ready";
stateAllowImageChange[1]         = true;
stateScript[1]                   = "onFire";
stateTimeoutValue[1]   = 1;
};

function %client::onFire(%this,%obj,%client)
{
  %client = %obj.client;
  %player = %obj;
  if $protec::using == 0
  {
  %obj.unhideNode ("Armor");
  $protec::using set = 1

  }

    else
  {
      %obj.hidenode ("Armor");
      $protec::using set = 1
    }
  }
}

function $protec::using if == 1(%this,%obj,%client)
{
 %client = %obj.client;
    %player = %obj;
if(%obj.getDamageLevel() <= 100)

{
%obj.addHealth = (%obj.getDamageLevel())
}
}
« Last Edit: September 18, 2012, 01:27:36 PM by Peggworth the Pirate »

Syntax errors everywhere, my eyes were burned out of my skull.

I suggest you start with something simpler until you get the hang of the syntax.

Syntax errors everywhere, my eyes were burned out of my skull.

I suggest you start with something simpler until you get the hang of the syntax.

I said I sucked. Can you help at all?

I said I sucked. Can you help at all?
I suggest you start with something simpler until you get the hang of the syntax.


function $protec::using if == 1(%this,%obj,%client)
???

I'll try and help, but some of these things I'm not sure what you're even trying to do.

Assuming this part isn't the end of a function declaration or something:
Code: [Select]
{
   $protec::using = 0
}
Delete that part, or if you're trying to just define a global variable, delete the brackets



Code: [Select]
function %client::onFire(%this,%obj,%client)
{
  %client = %obj.client;
  %player = %obj;
  if $protec::using == 0
  {
  %obj.unhideNode ("Armor");
  $protec::using set = 1

  }

    else
  {
      %obj.hidenode ("Armor");
      $protec::using set = 1
    }
  }
}

function $protec::using if == 1(%this,%obj,%client)
{
  %client = %obj.client;
    %player = %obj;
if(%obj.getDamageLevel() <= 100)

{
%obj.addHealth = (%obj.getDamageLevel())
}
}

First function:
In the function name: %client
If you're trying to make a client method, that should be GameConnection.
But onFire is a weaponImage (I believe) method, so that should be protecImage, and I believe the argments are this obj and slot, so the first line should be:
function protecImage::onFire(%this,%obj,%slot)

There's nothing wrong with %player = %obj; but since you're not using %player, defining it is pointless

For the if and else blocks, there's too many things for me to type step by step instructions:
Code: [Select]
if(%obj.isUsingProtec)
{
%obj.hideNode("Armor");
%obj.isUsingProtec = 0;
}
else
{
%obj.unhidenode("Armor");
%obj.isUsingProtec = 1;
}

I have no idea at all what you're trying to do with the second function.


function $protec::using if == 1(%this,%obj,%client)
???
I don't really know what I'm doing here, I was just following the format of the other function. its calling to see if the variable "using" is 1 than the function is enabled. Once again I suck and I am willing to take criticism, as long as you actually help me get something accomplished, and you aren't just a troll.

I don't really know what I'm doing here, I was just following the format of the other function. its calling to see if the variable "using" is 1 than the function is enabled. Once again I suck and I am willing to take criticism, as long as you actually help me get something accomplished, and you aren't just a troll.
Then you'd do something like this:

Code: [Select]
function exampleFunction()
{
if(!$exampleVar)
return;

echo("Hello!");
}

if $exampleVar is set to 0, the function will quit; any other value, it will say "Hello!" in the console

Then you'd do something like this:

Code: [Select]
function exampleFunction()
{
if(!$exampleVar)
return;

echo("Hello!");
}

if $exampleVar is set to 0, the function will quit; any other value, it will say "Hello!" in the console

Thank you very much, I'll come back with some kind of result hopefully. Sorry again, I don't know much about torque,   so this is pretty hard to me. I really appreciate it.