Author Topic: Syntax Errors in Pref Files  (Read 623 times)

Whenever I execute a prefs file it gives me syntax errors even thought I exported the prefs okay. What are the characters that cause the syntax errors?
Code: [Select]
Executing Config/Server/CRP/BrickData.cs.
Config/Server/CRP/BrickData.cs Line: 1 - Syntax error.
>>> Some error context, with ## on sides of error halt:
CRP::BrickData::SafeItem204.75_##8##8.75_0.6 = "hammerItem";
$CRP::BrickData::SafeItem211.75_98.75_0.6 = "PrintGun";
$CRP::BrickData::SafeLumber204.75_88.75_0.6 = 19;
$CRP::BrickData::SafeLumber211.75_98.75_0.6 = 10;
$CRP::BrickData::SafeMoney204.75_88.75_0.6 = 15;
$CRP::BrickData::SafeMoney211.75_98.75_0.6 = 50;
>>> Error report complete.
Is there anyway to import prefs without causing the syntax errors?

The periods
Replace them with something else

Whenever I execute a prefs file it gives me syntax errors even thought I exported the prefs okay. What are the characters that cause the syntax errors?
Code: [Select]
Executing Config/Server/CRP/BrickData.cs.
Config/Server/CRP/BrickData.cs Line: 1 - Syntax error.
>>> Some error context, with ## on sides of error halt:
CRP::BrickData::SafeItem204.75_##8##8.75_0.6 = "hammerItem";
$CRP::BrickData::SafeItem211.75_98.75_0.6 = "PrintGun";
$CRP::BrickData::SafeLumber204.75_88.75_0.6 = 19;
$CRP::BrickData::SafeLumber211.75_98.75_0.6 = 10;
$CRP::BrickData::SafeMoney204.75_88.75_0.6 = 15;
$CRP::BrickData::SafeMoney211.75_98.75_0.6 = 50;
>>> Error report complete.
Is there anyway to import prefs without causing the syntax errors?
Try this...

$CRP::BrickData::SafeItem["xDOT00","yDOT00","zDOT00"] = whatever;

instead of this...

$CRP::BrickData::SafeItemx.00_y.00_z.00 = whatever;

People aren't explaining the problem well so here's my attempt.

With arrays, you can get Torque to take the most forgeted up variable names ever.

$Pref::Server::This[" is actually a valid variable with spaces in it! And punctuation too!"] = "<-- True";


This will work. You can see the variable's value, set it, and all that good stuff.
HOWEVER, when the server shuts down and exports everything called $Pref...

$Pref::Server::This is actually a valid variable with spaces in it! And punctuation too! = "<-- True";


As any coder will tell you, that is NOT a valid variable name.


What this means is that if you want to export data so that it's reloadable, your array names have to not contain characters other than the alphanumeric characters (letters + numbers) and the underscore/colon (_ and : respectively) or it won't work correctly.

So basically, if you don't want to do what xalos said, you gotta make your own save format and saving/loading function.

Decided to just strip all spaces, negatives, and decimals from the position.
Code: [Select]
$CRP::BrickData::SafeLumber204.75_88.75_0.6 = 19;Will now show up as
Code: [Select]
$CRP::BrickData::SafeLumber20475887506 = 19;

Decided to just strip all spaces, negatives, and decimals from the position.
Code: [Select]
$CRP::BrickData::SafeLumber204.75_88.75_0.6 = 19;Will now show up as
Code: [Select]
$CRP::BrickData::SafeLumber20475887506 = 19;
That opens up the ambiguous case where what if something is saved at 2047.5_88.75_0.6 and that there's another safe at 204.75_88.75_0.6

Decided to just strip all spaces, negatives, and decimals from the position.
Code: [Select]
$CRP::BrickData::SafeLumber204.75_88.75_0.6 = 19;Will now show up as
Code: [Select]
$CRP::BrickData::SafeLumber20475887506 = 19;[/quote

Just write your own function lol.

That opens up the ambiguous case where what if something is saved at 2047.5_88.75_0.6 and that there's another safe at 204.75_88.75_0.6
That won't happen.