Author Topic: Function is being fickle - Raycasts  (Read 2097 times)

Okay, so I don't know what it is, but it appears to just not like something, namely the absence of something after the }; mark.


Here is my original function:
Code: [Select]
function leviathanImage::onFire(%this, %obj, %slot)
{
if(%obj.lastShot[%this] + %this.minShotTime > getSimTime())
{
return;
}
%obj.lastShot[%this] = getSimTime();
%start = %obj.getMuzzlePoint(%slot);
%end = vectorAdd(%start, vectorScale(%obj.getMuzzleVector(%slot), 500));
%typemasks = $Typemasks::PlayerObjectType | $Typemasks::FxBrickObjectType | $Typemasks::TerrainObjectType | $Typemasks::InteriorObjectType | $TypeMasks::StaticObjectType | $TypeMasks::VehicleObjectType;
%ray = containerRaycast(%start, %end, %typemasks, %obj);
if(isObject(%hit = firstWord(%ray)))
{
%pos = posFromRaycast(%ray);
%apos = vectorAdd(%pos, vectorScale(normalFromRaycast(%ray), 0.05));
%prj = new Projectile()
{
datablock = LeviathanProjectile;
initialPosition = %apos;
initialVelocity = vectorScale(%obj.getMuzzleVector(%slot), 200);
scale = %obj.getScale();
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
Leviathanbullet = true;
};
}
};

Here is the error report:
Code: [Select]
Loading Add-On: Weapon_Leviathan (CRC:327213675)
Add-Ons/Weapon_Leviathan/server.cs Line: 462 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^^%apos = vectorAdd(%pos, vectorScale(normalFromRaycast(%ray), 0.05));

^^%prj = new Projectile()

^^{

^^^datablock = LeviathanEmitterA;

^^^initialPosition = %apos;

^^^initialVelocity = "0 0 0";

^^^scale = %obj.getScale();

^^^sourceObject = %obj;

^^^sourceSlot = %slot;

^^^client = %obj.client;

^^};

^}

};##
##


function leviathanImage::onFire(%this, %obj, %slot)

{

^if(%obj.lastShot[%this] + %this.minShotTime > getSimTime())

^{

^^return;

^}

^%obj.lastShot[%this] = getSimTime();

^%start = %obj.getMuzzlePoint(%slot);

^%end = vectorAdd(%start, vectorScale(%obj.getMuzzleVector(%slot), 500));
>>> Error report complete.

ADD-ON "Weapon_Leviathan" CONTAINS SYNTAX ERRORS

Correct me if I'm wrong, but it looks like it doesn't like something that isn't there, maybe it doesn't like the enter.  Any variation with the semicolon seems to fail.  The "symptom" is that when switching to the Loading Datablocks phase, Blockland crashes.

There's no semicolon after a function definition.

There's no semicolon after a function definition.
There is no need for a semicolon there.
You only use semicolons in a package, I think..... Maybe...
« Last Edit: December 05, 2012, 09:27:17 AM by Rainzx¹ »

There is no need for a semicolon there.
You only use semicolons in a package, I think..... Maybe...

After a package, object or datablock definition

There is no need for a semicolon there.
You only use semicolons in a package, I think..... Maybe...
Don't try to help if you're clearly confused about what you're saying. Zack literally just said the exact same thing as you, those semicolons do not belong there

Don't try to help if you're clearly confused about what you're saying. Zack literally just said the exact same thing as you, those semicolons do not belong there
I'm not confused moron valued member of society. I know what it is used for i just wasn't completely sure.
Zack didn't say anything about packaging, sorry for giving more information...

I'm not confused moron valued member of society. I know what it is used for i just wasn't completely sure.
Zack didn't say anything about packaging, sorry for giving more information...

Wow you're a loving cunt. Stop acting like you're some saint who's here to save everyone and give them knowledge. Treynolds and Zack0Wack0 probably know way more about coding than you do.
« Last Edit: December 05, 2012, 12:57:02 PM by Electrk² »

I'm not confused moron valued member of society. I know what it is used for i just wasn't completely sure.
Zack didn't say anything about packaging, sorry for giving more information...
He didn't say anything about packaging because there's no package.

I'm not confused moron valued member of society. I know what it is used for i just wasn't completely sure.
Zack didn't say anything about packaging, sorry for giving more information...
Saying umm this might be right but I'm not sure is not an example of giving additional information. A good example of giving additional information can be seen in mold's post:
After a package, object or datablock definition

Well fellas, I don't know what to say.

This is with no semicolons:
Code: [Select]
Loading Add-On: Weapon_Leviathan (CRC:-939920505)
Add-Ons/Weapon_Leviathan/server.cs Line: 461 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^^%apos = vectorAdd(%pos, vectorScale(normalFromRaycast(%ray), 0.05));

^^%prj = new Projectile()

^^{

^^^datablock = LeviathanEmitterA;

^^^initialPosition = %apos;

^^^initialVelocity = "0 0 0";

^^^scale = %obj.getScale();

^^^sourceObject = %obj;

^^^sourceSlot = %slot;

^^^client = %obj.client;

^^}

^}##
##
}

This is with semicolons on the last closing bracket.
Code: [Select]
Loading Add-On: Weapon_Leviathan (CRC:-284018831)
Add-Ons/Weapon_Leviathan/server.cs Line: 461 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^^%apos = vectorAdd(%pos, vectorScale(normalFromRaycast(%ray), 0.05));

^^%prj = new Projectile()

^^{

^^^datablock = LeviathanEmitterA;

^^^initialPosition = %apos;

^^^initialVelocity = "0 0 0";

^^^scale = %obj.getScale();

^^^sourceObject = %obj;

^^^sourceSlot = %slot;

^^^client = %obj.client;

^^}

^}##
##
};



function leviathanImage::onFire(%this, %obj, %slot)

{

^if(%obj.lastShot[%this] + %this.minShotTime > getSimTime())

^{

^^return;

^}

^%obj.lastShot[%this] = getSimTime();

^%start = %obj.getMuzzlePoint(%slot);

^%end = vectorAdd(%start, vectorScale(%obj.getMuzzleVector(%slot), 500));
>>> Error report complete.

ADD-ON "Weapon_Leviathan" CONTAINS SYNTAX ERRORS

To me, it appears to not like any final bracket without a semicolon.

However, it then dislikes the semicolon when placed back in where the error was cited:
Code: [Select]
Loading Add-On: Weapon_Leviathan (CRC:1136400796)
Add-Ons/Weapon_Leviathan/server.cs Line: 461 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^^%apos = vectorAdd(%pos, vectorScale(normalFromRaycast(%ray), 0.05));

^^%prj = new Projectile()

^^{

^^^datablock = LeviathanEmitterA;

^^^initialPosition = %apos;

^^^initialVelocity = "0 0 0";

^^^scale = %obj.getScale();

^^^sourceObject = %obj;

^^^sourceSlot = %slot;

^^^client = %obj.client;

^^}

^}##;##

};



function leviathanImage::onFire(%this, %obj, %slot)

{

^if(%obj.lastShot[%this] + %this.minShotTime > getSimTime())

^{

^^return;

^}

^%obj.lastShot[%this] = getSimTime();

^%start = %obj.getMuzzlePoint(%slot);

^%end = vectorAdd(%start, vectorScale(%obj.getMuzzleVector(%slot), 500));
>>> Error report complete.

ADD-ON "Weapon_Leviathan" CONTAINS SYNTAX ERRORS

Stuck here.  I don't even edit this part of the code and it occasionally breaks here.

Complete shot in the dark here, but try to define a variable called %scale, set it equal to %obj.setScale(), and replace %obj.getScale() with the new variable. I don't think functions can be called in obj definitions.

http://forum.blockland.us/index.php?topic=192083.0

Complete shot in the dark here, but try to define a variable called %scale, set it equal to %obj.setScale(), and replace %obj.getScale() with the new variable. I don't think functions can be called in obj definitions.

Wrong.



Put the semi-colon on the bracket above.

@swat, instead of just guessing where the semicolons go, perhaps use a little reasoning to figure it out.

Put the semi-colon on the bracket above.
Relative to what?
Add a new semicolon or replace?

@swat, instead of just guessing where the semicolons go, perhaps use a little reasoning to figure it out.
I suppose you would be scratching your head if you tried literally every permutation of semicolon placement.
« Last Edit: December 06, 2012, 10:31:39 PM by SWAT One »

Okay, thanks to Elm, this is a fully-working Add-On.  Thanks man, it's great.  Locking this topic.