Author Topic: Tumble on Explosion  (Read 3360 times)

What exactly did you try? Do you have a description.txt? Is there a syntax error in the console.log?

For one, I already had an extra function already making up ShockGrenadepackage, so I placed both the function written here and the existing one.

I also removed the 5000 for col%(tumble,5000), making it col%(tumble).

I don't really know where I made a mistake there, do to my own shortsightedness.

Do exactly as I did, your code is not correct. When you're done post your code.

Code: [Select]
};

package ShockGrenadePackage
{
        function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
        {
                if(%col.dataBlock $= "ShockGrenadeItem" && %col.canPickup)
                {
                        for(%i=0;%i<%this.maxTools;%i++)
                        {
                                %item = %obj.tool[%i];
                                if(%item $= 0 || %item $= "")
                                {
                                        %freeSlot = 1;
                                        break;
                                }
                        }

                        if(%freeSlot)
                        {
                                %obj.pickup(%col);
                                return;
                        }
                }
                Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);
        }
};
activatePackage(ShockGrenadePackage);

function ShockGrenadeImage::onCharge(%this, %obj, %slot)
{
        %obj.playthread(2, spearReady);
        %obj.lastShockGrenadeSlot = %obj.currTool;
}

function ShockGrenadeImage::onAbortCharge(%this, %obj, %slot)
{
        %obj.playthread(2, root);
}

function ShockGrenadeProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
        serverPlay3D(ShockGrenadeBounceSound,%obj.getTransform());
}

function ShockGrenadeImage::onFire(%this, %obj, %slot)
{
        %obj.playthread(2, spearThrow);
        Parent::OnFire(%this, %obj, %slot);

        %currSlot = %obj.lastShockGrenadeSlot;
        %obj.tool[%currSlot] = 0;
        %obj.weaponCount--;
        messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
        serverCmdUnUseTool(%obj.client);
}
package ShockGrenadePackage
{
    function ShockGrenadeExplosion::Damage(%this,%obj,%col,%fade,%pos,%normal)
      {
        if(%col.getClassName() $= "Player" && minigameCanDamage(%obj, %col))
            {
            tumble(%col, 5000);
            }
        parent::Damage(%this,%obj,%col,%fade,%pos,%normal);
      }
};
activatePackage(ShockGrenadePackage);

function ShockGrenadeImage::onDone(%this,%obj,%slot)
{
        //this just removes it from the player hand, but not the player inventory
        %obj.unMountImage(%slot);
            //code to remove from inventory
        %obj.tool[%obj.currTool] = 0;
            //now to free the slot so other people can pick up items in that slot
        %obj.client.weaponCount--;
            //makes them drop their hand rather than hold out an empty hand after throwing
        serverCmdUnuseTool(%obj.client);
}

datablock DecalData(ShockGrenadeIcon)
{
   textureName = "Add-Ons/Weapon_ShockGrenade/icon_ShockGrenade";
};

package ShockGrenadePackage
{
    function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
        {
          if(%col.dataBlock $= "ShockGrenadeItem" && %col.canPickup)
             {
              for(%i=0;%i<%this.maxTools;%i++)
                {
                  %item = %obj.tool[%i];
                  if(%item $= 0 || %item $= "")
                    {
                     %freeSlot = 1;
                      break;
                    }
                }
              if(%freeSlot)
              {
          %obj.pickup(%col);
          return;
              }
        }
          Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);
};
activatePackage(ShockGrenadePackage);

Sorry for the Pagestretch. These are all the functions written in my add-on. Currently, three of them use "ShockGrenadepackage".


What purpose could }; be for at the beginning of the code? Nothing. It's an obvious syntax error. Remove it.

Remove the first package, as it's an exact replica of the last package.

Move the function in the second package, over to the last package and then delete that package.

When you re-define a package, using the same package name, it overwrites the package. Don't do this.
You really only need one package per add-ons usually.

Remove
Code: [Select]
datablock DecalData(ShockGrenadeIcon)
{
   textureName = "Add-Ons/Weapon_ShockGrenade/icon_ShockGrenade";
};
As that kind of datablock doesn't exist anymore. So this part isn't even doing anything.

Add in what Dannu said(and do what my quote at the bottom of that post says too) into the package.

New Problem.

Code: [Select]
Loading Add-On: Weapon_ShockGrenade
Add-Ons/Weapon_ShockGrenade/Weapon_ShockGrenade.cs Line: 455 - Syntax error.
>>> Some error context, with ## on sides of error halt:
        stateScript[7]                      = "onFire";
        stateWaitForTimeout[7]              = true;
        stateAllowImageChange[7]            = false;

        stateName[8]                        = "Done";
        stateScript[8]                      = "onDone";

function ##S##hockGrenadeImage::onAbortCharge(%this, %obj, %slot)
{
        %obj.playthread(2, root);
}

function ShockGrenadeProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
        serverPlay3D(ShockGrenadeBounceSound,%obj.getTransform());
}

function ShockGrenadeImage::onCharge(%this, %obj, %slot)
>>> Error report complete.

ADD-ON "Weapon_ShockGrenade" CONTAINS SYNTAX ERRORS

Tried even reordering it. No dice.

Code: [Select]
Loading Add-On: Weapon_ShockGrenade
Add-Ons/Weapon_ShockGrenade/Weapon_ShockGrenade.cs Line: 456 - Syntax error.
>>> Some error context, with ## on sides of error halt:
        stateScript[7]                      = "onFire";
        stateWaitForTimeout[7]              = true;
        stateAllowImageChange[7]            = false;

        stateName[8]                        = "Done";
        stateScript[8]                      = "onDone";


package ##S##hockGrenadePackage
{
    function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
        {
          if(%col.dataBlock $= "ShockGrenadeItem" && %col.canPickup)
             {
              for(%i=0;%i<%this.maxTools;%i++)
>>> Error report complete.

ADD-ON "Weapon_ShockGrenade" CONTAINS SYNTAX ERRORS

Tried renaming the file itself from "ShockGrenade" to "shockGrenade" in case it was all case sensitive. Not even that worked.

Code: [Select]
Loading Add-On: Weapon_ShockGrenade
Add-Ons/Weapon_ShockGrenade/Weapon_shockGrenade.cs Line: 456 - Syntax error.
>>> Some error context, with ## on sides of error halt:
        stateScript[7]                      = "onFire";
        stateWaitForTimeout[7]              = true;
        stateAllowImageChange[7]            = false;

        stateName[8]                        = "Done";
        stateScript[8]                      = "onDone";


package ##s##hockGrenadePackage
{
    function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
        {
          if(%col.dataBlock $= "shockGrenadeItem" && %col.canPickup)
             {
              for(%i=0;%i<%this.maxTools;%i++)
                {
                  %item = %obj.tool[%i];
>>> Error report complete.

ADD-ON "Weapon_ShockGrenade" CONTAINS SYNTAX ERRORS

Mac's are such strange devices....Any ideas?

You are missing a }. Did you even try looking for the error?

You are missing a }. Did you even try looking for the error?

Lol. I didn't even notice that. gg.

Quote
Loading Add-On: Weapon_ShockGrenade
Add-Ons/Weapon_ShockGrenade/Weapon_shockGrenade.cs Line: 456 - Syntax error.
>>> Some error context, with ## on sides of error halt:
        stateScript[7]                      = "onFire";
        stateWaitForTimeout[7]              = true;
        stateAllowImageChange[7]            = false;

        stateName[8]                        = "Done";
        stateScript[8]                      = "onDone";
}

package ##s##hockGrenadePackage
{
    function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
        {
          if(%col.dataBlock $= "shockGrenadeItem" && %col.canPickup)
             {
              for(%i=0;%i<%this.maxTools;%i++)
                {
                  %item = %obj.tool[%i];
>>> Error report complete.

ADD-ON "Weapon_ShockGrenade" CONTAINS SYNTAX ERRORS

Apparently the code still doesn't want to work. I've checked it thoroughly and it's still returning syntax errors that don't even exist. I've done everything you three have provided me. But this is seriously stressing me out. 

Apparently the code still doesn't want to work. I've checked it thoroughly and it's still returning syntax errors that don't even exist. I've done everything you three have provided me. But this is seriously stressing me out.  

Code: [Select]
}

package ##s##hockGrenadePackage
{

Correction:

Code: [Select]
};

package ##s##hockGrenadePackage
{

« Last Edit: March 20, 2016, 11:25:02 AM by Crazycom »

Apparently the code still doesn't want to work. I've checked it thoroughly and it's still returning syntax errors that don't even exist. I've done everything you three have provided me. But this is seriously stressing me out. 
Dannu made a mistake. It's }; not }, when defining a datablock/package you always need a }; at the end instead of }

Saw that ninja edit.
« Last Edit: March 20, 2016, 11:28:25 AM by Kyuande »

Code: [Select]
};

package ##s##hockGrenadePackage
{

Still doesn't explain the part as to how the "s" in shockGrenade Package isn't working as it should. Either that or my comp is complete stuff.

Dannu made a mistake. It's }; not }, when defining a datablock/package you always need a }; at the end instead of }
Saw that ninja edit.

Yeah, I checked all the Datablocks. But as I said before, it's not the issue anymore. It's just that the addon won't run, because of a syntax error that shouldn't exist.

Still doesn't explain the part as to how the "s" in shockGrenade Package isn't working as it should. Either that or my comp is complete stuff.

Yeah, I checked all the Datablocks. But as I said before, it's not the issue anymore. It's just that the addon won't run, because of a syntax error that shouldn't exist.

It's not that precise, usually wherever the script halts you have to go back a couple lines to find where the actual syntax error occurred. So now I'd post your current code.

Saw that ninja edit.

I was editing at the same time you posted after I realized it was a datablock.

It's not that precise, usually wherever the script halts you have to go back a couple lines to find where the actual syntax error occurred. So now I'd post your current code.
His code should be fine now until he gets another error again, it looks fine to me. Badspot's syntax error is pretty cheesy so usually it's a line or so above if you don't see the error on the current line.

His code should be fine now until he gets another error again, it looks fine to me. Badspot's syntax error is pretty cheesy so usually it's a line or so above if you don't see the error on the current line.

I can't tell if OP has actually corrected the syntax error or if he thinks it's not the real issue, or if he's trying to say he now has a different syntax error altogether. OP clarify please.