Author Topic: export($string???  (Read 526 times)

I'm trying to export a string and it won't work for some reason? Is it possible to?
Code: [Select]
    $Player = %client.BL_ID TAB %client.cash TAB %client.ed;
    export($Player, $logFile, false);

exporting is used for arrays usually
$player::one = "blarg";
$player::two = "dooble";
$player::three = "simon";

export("$player::*", path);

edit: lol you should just make one megathread for all your coding help topics.  I think you have like 30.

exporting is used for arrays usually
$player::one = "blarg";
$player::two = "dooble";
$player::three = "simon";

export("$player::*", path);

edit: lol you should just make one megathread for all your coding help topics.  I think you have like 30.

Why does it do this?

My script:

Code: [Select]
$Player::ID = %client.BL_ID;
$Player::Cash = %client.cash;
$Player::Education = %client.ed;
export("$player::*", $logFile, false);

It saves...

Code: [Select]
$Player::Cash = "0";
$Player::Education = "1";
$Player::ID = "999999";
$Player::maxPredictionTicks = "30";
$Player::maxWarpTicks = "30";
$Player::minWarpTicks = "0.5";

maxPredictionTicks? maxWarpTicks? minWarpTicks? << Whats that? Lol

nvm i just changed it to $PlayerData. But I need all the data on one line... So i can set it up to load the data.

Code: [Select]
$Playerdata::Cash999999 = "0";
$Playerdata::Education999999 = "1";
$Playerdata::ID999999 = "999999";

I need it all on one line.

And also i will replace all content. I setup it like this so i wouldn't overwrite the data. Still does...

Code: [Select]
   $Playerdata::ID[%client.BL_ID] = %client.BL_ID;
$Playerdata::Cash[%client.BL_ID] = %client.cash;
$Playerdata::Education[%client.BL_ID] = %client.ed;
    export("$Playerdata::*", $logFile, false);

doing it this way won't replace all content just the content under that bl id:

Code: [Select]
      $LoggedIP[%client.BL_ID] = %client.cash TAB %client.ed;
       export("$LoggedIP*", $logFile, false);

edit: lol you should just make one megathread for all your coding help topics.  I think you have like 30.
Lol. Sorry i just really want to learn this stuff.
« Last Edit: June 12, 2011, 01:50:24 PM by tyler0 »

I need it all on one line.

No you don't
The point of exporting an array is so you can execute that file.  Exec doesnt care how many lines your data is on.

Oh no i mean.... nvm. I need to beable to load this file. I have an idea of how to load it if it is all on one line. If their on different lines then i don't know how to make it load. All-in-all, i need some way of learning how to load content as well.

Do you know where i can find a torque engine file object tutorial?
« Last Edit: June 12, 2011, 01:58:27 PM by tyler0 »

If their on different lines then i don't know how to make it load.

exec("folder/folder/file.cs");

it doesnt care how many lines are in file.cs, it will just execute it.

exec("folder/folder/file.cs");

it doesnt care how many lines are in file.cs, it will just execute it.


My loading script. How would i scan multiple line for more content?

   $logFile = "config/server/ServerLogs/mrAccountData.cs";
   %id = %this.BL_ID;
   if(!isFile($logFile))
   {
      GameSave(%this);
   } else {
      %FO = new FileObject();
      if(%FO.openForRead($logFile))
      {
         %FO.readline();
         while(!%FO.isEOF())
         {
            %line = %FO.readLine();
            %lid = getField(%line,0);
            if(%lid $= %id)
            {
               %found = 1;
               %this.ID = %id;
               %this.cash = getField(%line,1);
               %this.ed = getField(%line,2);
               break;
            }
         }
         %FO.close();
      }
      if(!%found)
      {
         messageClient(%this,'',"No File");
      }
      if(isObject(findclientbybl_id(%id)))
      {
         %this.client = findclientbybl_id(%id);
         %this.client.cashobj = %this;
      }
      %FO.delete();
      }
}

first of all, that code can read multiple lines, but not things mushed into one line.
Whenever you do a %file.readline, it shifts down a line.  Having more than one %file.readline in a loop will almost certainly cause you to skip data while reading.

If you are exporting, the data in that file is already ready to be used, you do not need to read the file and get any data.  Just exec it and all the data that you exported is now once again part of the game.
also, %file.openforread is not an if/else test.

first of all, that code can read multiple lines, but not things mushed into one line.
Whenever you do a %file.readline, it shifts down a line.  Having more than one %file.readline in a loop will almost certainly cause you to skip data while reading.

If you are exporting, the data in that file is already ready to be used, you do not need to read the file and get any data.  Just exec it and all the data that you exported is now once again part of the game.
also, %file.openforread is not an if/else test.

Ok is it fixed in the script below?

Note this is based off of cashmodII's load script.

Code: [Select]
  $logFile = "config/server/ServerLogs/mrAccountData.cs";
   %id = %this.BL_ID;
   if(!isFile($logFile))
   {
      GameSave(%this);
   } else {
      %FO = new FileObject();
      if(%FO.openForRead($logFile))
      {
         while(!%FO.isEOF())
         {
            %line = %FO.readLine();
            %lid = getField(%line,0);
            if(%lid $= %id)
            {
               %found = 1;
               %this.ID = %id;
               %this.cash = getField(%line,1);
               %this.ed = getField(%line,2);
               break;
            }
         }
         %FO.close();
      }
      if(!%found)
      {
         messageClient(%this,'',"No File");
      }
      if(isObject(findclientbybl_id(%id)))
      {
         %this.client = findclientbybl_id(%id);
         %this.client.cashobj = %this;
      }
      %FO.delete();
      }
}


Quote
%file.openforread is not an if/else test.
It returns 1 when you successfully open a file, so yes it can.
No, you don't need to. The only thing you need to put string tags around in Torque is strings with spaces in them.


also its still overwriting my all data on save
« Last Edit: June 12, 2011, 02:39:09 PM by tyler0 »