Author Topic: A weapon I'm trying to code doesn't work and I don't know why  (Read 1228 times)

Attached: a wand that is supposed to work like the throwing knife, where left-clicking does a melee attack and right-clicking is supposed to shoot a magic projectile akin to the medieval weapon pack's wand weapon.

I do not understand what is causing it to break, because not only is the weapon broken, but it breaks the whole weapon pack, too.

As in the entire weapon pack just doesn't load?
A console.log would be a bit helpful.

As in the entire weapon pack just doesn't load?
A console.log would be a bit helpful.

This is the only thing relating to my weapon pack

Code: [Select]
Loading Add-On: Weapon_RPGDefault (CRC:-609443350)
Add-Ons/Weapon_RPGDefault/wandgold.cs Line: 74 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^   emitter[0]       = MagicExplosionEmitter;

^   faceViewer       = 1;

^   lifetimeMS       = 180;

^   lightEndRadius   = 0.5;

^   lightStartColor  = "0 0.7 1 1";

^   lightStartRadius = 1;

^   shakeCamera      = 1;

^   soundProfile     = "wandBrickSound";

     

    datablock ExplosionData(##M##agicshotExplosion)

    {

       //explosionShape = "";

       lifeTimeMS = 500;

     

       soundProfile = wandPlayerSound;

     

       particleEmitter = MagicExplosionEmitter;

       particleDensity = 10;

       particleRadius = 0.2;

     

       faceViewer     = true;
>>> Error report complete.

Nothing else seems to be causing it to not work other than this, and I don't understand what the problem is

You seem to not be closing sonething properly. Post the code.

You seem to not be closing sonething properly. Post the code.

I posted the code

Using a phone I can't help you then. Just posting what is around the error report helps.

Using a phone I can't help you then. Just posting what is around the error report helps.

It's the only error related to the weapon

I'll post it again cause I accidentally left out the last line
Code: [Select]
Loading Add-On: Weapon_RPGDefault (CRC:-1683523011)
Add-Ons/Weapon_RPGDefault/wandgold.cs Line: 74 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^   emitter[0]       = magicExplosionEmitter;

^   faceViewer       = 1;

^   lifetimeMS       = 180;

^   lightEndRadius   = 0.5;

^   lightStartColor  = "0 0.7 1 1";

^   lightStartRadius = 1;

^   shakeCamera      = 1;

^   soundProfile     = "wandBrickSound";

    

    datablock ExplosionData(##m##agicshotExplosion)

    {

       //explosionShape = "";

       lifeTimeMS = 500;

    

       soundProfile = wandPlayerSound;

    

       particleEmitter = magicExplosionEmitter;

       particleDensity = 10;

       particleRadius = 0.2;

    

       faceViewer     = true;
>>> Error report complete.

ADD-ON "Weapon_RPGDefault" CONTAINS SYNTAX ERRORS

Code: [Select]
     
    datablock ExplosionData(MagicshotExplosion)
    {
       //explosionShape = "";
       lifeTimeMS = 500;
     
       soundProfile = wandPlayerSound;
     
       particleEmitter = MagicExplosionEmitter;
       particleDensity = 10;
       particleRadius = 0.2;
     
       faceViewer     = true;
       explosionScale = "0.5 1 1";
     
       shakeCamera = true;
       camShakeFreq = "20.0 22.0 20.0";
       camShakeAmp = "1.0 1.0 1.0";
       camShakeDuration = 0.5;
       camShakeRadius = 10.0;
     
       // Dynamic light
       lightStartRadius = 2;
       lightEndRadius = 0;
       lightStartColor = "1 0 0";
       lightEndColor = "0 0 0";
    };

What is the syntax error?

post whatever is above that

post whatever is above that

Code: [Select]
    datablock AudioProfile(wandBrickSound)
    {
       filename    = "Add-Ons/Weapon_RPGDefault/sounds/wandmagichitbrick.wav";
       description = AudioClosest3d;
       preload = true;
    };
    datablock AudioProfile(wandPlayerSound)
    {
       filename    = "Add-Ons/Weapon_RPGDefault/sounds/wandmagichitplayer.wav";
       description = AudioClosest3d;
       preload = true;
    };
    datablock AudioProfile(wandDrawSound)
    {
       filename    = "Add-Ons/Weapon_RPGDefault/sounds/wanddraw.wav";
       description = AudioClosest3d;
       preload = true;
    };
    datablock AudioProfile(wandShoot)
    {
       filename    = "Add-Ons/Weapon_RPGDefault/sounds/wandShoot.wav";
       description = AudioClosest3d;
       preload = true;
    };
     
    datablock ParticleData(MagicExplosionParticle)
    {
            dragCoefficient      = 5;
            gravityCoefficient   = 0.1;
            inheritedVelFactor   = 0.2;
            constantAcceleration = 0.0;
            lifetimeMS           = 500;
            lifetimeVarianceMS   = 300;
            textureName          = "base/data/particles/chunk";
            spinSpeed               = 10.0;
            spinRandomMin           = -50.0;
            spinRandomMax           = 50.0;
            colors[0]     = "0.9 0.9 0.6 0.9";
            colors[1]     = "0.9 0.5 0.6 0.0";
            sizes[0]      = 0.25;
            sizes[1]      = 0.0;
    };
     
    datablock ParticleEmitterData(MagicExplosionEmitter)
    {
       ejectionPeriodMS = 1;
       periodVarianceMS = 0;
       ejectionVelocity = 5;
       velocityVariance = 0.0;
       ejectionOffset   = 0.0;
       thetaMin         = 80;
       thetaMax         = 80;
       phiReferenceVel  = 0;
       phiVariance      = 360;
       overrideAdvance = false;
       particles = "MagicExplosionParticle";
     
       uiName = "Magic Shot Hit";
    };

   datablock explosionData(MeleeWandExplosion)
   {
   camShakeDuration = 0.5;
   camShakeFreq     = "1 1 1";
   emitter[0]       = MagicExplosionEmitter;
   faceViewer       = 1;
   lifetimeMS       = 180;
   lightEndRadius   = 0.5;
   lightStartColor  = "0 0.7 1 1";
   lightStartRadius = 1;
   shakeCamera      = 1;
   soundProfile     = "wandBrickSound";
     

You are missing }; at the end.

You are missing }; at the end.

Jeez, there's a lot of things I messed up pertaining to where datablocks end. I'll fix all that right now and see if it works

edit: it works peeeerfectly. I'm going to package the wand for people to use right now!
« Last Edit: July 25, 2015, 01:15:21 PM by IkeTheGeneric »