Author Topic: Objects entering Scientific notation  (Read 1083 times)

It seems I've run into a problem when objects enter scientific notation (1.02e+06 stuff like this) where bits and pieces of my code seem to stop functioning. Is there anyway I could combat this by either A.) Resetting the Object count or B.) Making my code function regardless.
Here is a snippet of the error and the code that stopped functioning when it entered scientific notation. It could ultimately end up being a problem with it but I hadn't run into anything beforehand.
Code: [Select]
Syntax error in input.
eval error >> Add-Ons/Gamemode_SuperKart/server.cs (347): Unable to find object: '1.5679e+006'
BackTrace:
%  attemp
%  attempting to call function 'setVelocity'
Syntax error in input.
eval error >>  attempting to call function 'setVelocity'
BackTrace:
% Ba
% BackTrace: ->[GameModeSpeedKartPackage]VehicleData::onEnterLiquid->[GameModeSpee
Syntax error in input.
eval error >> BackTrace: ->[GameModeSpeedKartPackage]VehicleData::onEnterLiquid->[GameModeSpee
BackTrace:
% dK
% dKartPackage]Player::SSKRespawn
Syntax error in input.
eval error >> dKartPackage]Player::SSKRespawn
And the code block in question
Code: [Select]
function vehicleData::onEnterLiquid(%a, %obj, %coverage, %type)
{
if((%obj.getClassName() $= "WheeledVehicle" || %obj.getClassName() $= "FlyingVehicle" || %obj.getClassName() $= "AIPlayer") && %obj.getControllingObject().client.restorePoint !$= "")
{
%player = %obj.getControllingObject();
if(isObject(%player))
%player.SSKRespawn(%obj);
}
else
{
%obj.finalExplosion();
%obj.getControllingObject().kill();
}
parent::onEnterLiquid(%a, %obj, %coverage, %type);
}
In the context, this happened on players and vehicles that were still alive and still existed from what I've been told.

.. I think if you're reaching that point then the server is long overdue for a reset (this is personal preference, though). How long does it take to get there? If it's not long, make sure to check that there isn't some routine of code that is constantly creating and deleting objects (ScriptObjects for instance)

If absolutely necessary, you can try forcing it to be an integer by doing %obj | 0 since objects are integers by default anyways.
« Last Edit: July 06, 2015, 06:13:32 PM by Val »

.. I think if you're reaching that point then the server is long overdue for a reset. How long does it take to get there? If it's not long, make sure to check that there isn't some routine of code that is constantly creating and deleting objects (ScriptObjects for instance)

If absolutely necessary, you can try forcing it to be an integer by doing %obj | 0
I create 1 script object on Server creation if that's causing problems. I don't recall exactly how long it took to reach this point.
It's changing around every time bricks are loaded in (E.I loading a new save) so could that be grounds for a major problem?

I mean, it's certainly fine for object IDs to get to that point. It's only ~1.5 million, which isn't anywhere near the supposed limit of around 2 billion. I just like to reset my server every 12 hours when I host and I never get above a million.

But since object IDs are integers by default, you must be implicitly converting it to a float somewhere. Simple arithmetic operations like addition are common and will convert your int to a float, causing problems like these. Can we see Player::SSKRespawn? It seems to be what the console is complaining about.
« Last Edit: July 06, 2015, 05:22:14 AM by Val »

Code: [Select]
function player::SSKRespawn(%player)
{
%this = %player.client;
%veh = %player.getControlObject();
%veh.setVelocity("0 0 0");
%veh.setTransform(%this.restorePoint);
%veh.setDamageLevel(0);
if(!isObject(%veh))
{
%player.getControlObject().setVelocity("0 0 0");
%player.getControlObject().setTransform(%this.restorePoint);
%player.getControlObject().setDamageLevel(0);
}
}
The block containing the isObject is new and was added in attempt to combat the issue.

Ah, here's the issue:



The return type is a float. gg torque devs.

Code: [Select]
%veh = %player.getControlObject() | 0;
Alternatively, just use %veh = %player.getObjectMount();
« Last Edit: July 06, 2015, 06:17:54 PM by Val »

Ah, here's the issue:



The return type is a float. gg torque devs.

Code: [Select]
%veh = %player.getControlObject() | 0;
Thank you, I'll write a mini-function so I don't have to entirely revise all my code.