Blockland Forums > Modification Help

export($string???

Pages: << < (2/2)

tyler0:

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?

Nexus:


--- Quote from: tyler0 on June 12, 2011, 01:54:12 PM ---If their on different lines then i don't know how to make it load.
--- End quote ---

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

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

tyler0:


--- Quote from: Nexus on June 12, 2011, 01:57:29 PM ---exec("folder/folder/file.cs");

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

--- End quote ---


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();
      }
}

Nexus:

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.

tyler0:


--- Quote from: Nexus on June 12, 2011, 02:09:30 PM ---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.

--- End quote ---

Ok is it fixed in the script below?

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


--- Code: ---   $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();
      }
}
--- End code ---



--- Quote ---%file.openforread is not an if/else test.
--- End quote ---

--- Quote from: Destiny/Zack0Wack0 on June 11, 2011, 09:05:23 PM ---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.
--- End quote ---


also its still overwriting my all data on save

Pages: << < (2/2)

Go to full version