Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Guide] Edit Files in Excel using 010 Editor (shown for ItemLooting)

Newbie Spellweaver
Joined
Aug 23, 2008
Messages
8
Reaction score
4
This tutorial is meant for those that like using 010 Editor and have an idea of how to create and/or modify scripts and templates.

I love the power of 010 Editor for doing mass edits and things, but for some files I like the power of excel (filtering, copying, etc). This tutorial will show you how I edit ItemLooting.dat in Excel and use 010 editor to export and import.

I am not giving every single step in this tutorial. I use the scripts and templates released by Intrepid Web. You may need to change some variable names if they are different for you. This is just a guide as to how to write the scripts needed to do this.

Script 1, the export:
Code:
//--------------------------------------
//--- 010 Editor v5.0 Script File
//
// File:    item_looting_export.1sc
// Author:  GMoney
// Revision:
// Purpose:
//--------------------------------------

string savePath = "C:\\PathTo\\export.csv";
int i, y;
int curFile = GetFileNum();
int newFile = FileNew();
string currentLine = "";
string temp = "";

DeleteFile( savePath );

FileSelect( curFile );

for(i = 0; i < header.blocks; i++)
{ 
    currentLine = "";    
    
    if(item[i].lootRate > 0)
    {   
        //I am using templates released by Intrepid Web
        //We are simply writing the comma delimited values to a csv file
        SPrintf(temp, "%s", item[i].base.code);
        currentLine += temp;
        currentLine += ",";
    
        SPrintf(temp, "%d", item[i].lootRate);
        currentLine += temp;
        currentLine += ",";
    
        SPrintf(temp, "%d", item[i].lootTime);
        currentLine += temp;
        currentLine += ",";
        
        SPrintf(temp, "%d", item[i].operationCount);
        currentLine += temp;
        currentLine += ",";
    
        SPrintf(temp, "%d", item[i].totalLoot);
        currentLine += temp;
        currentLine += ",";
        
        for(y = 0; y < 200; y++)
        {
            SPrintf(temp, "%s", item[i].item[y].code);
            currentLine += temp;
            if(y != 199)
                currentLine += ",";
        }   
        
        currentLine += "\n";
    
        FPrintf(newFile, "%s", currentLine);
    }
}

FileSelect( newFile );
FileSave( savePath );
FileClose();

Utilizing the code above, you will have a csv file containing the contents of ItemLooting. In some cases you can simply double click to open the file in excel, BUT you may get some formatting that you don't want. For this particular file, I opened excel and imported the data from text. To import, you need to choose "Delimited", then Comma instead of Tab, then for item looting I picked the column with the mob codes and selected "Text" instead of "General" for the formatting. The data is then imported and you can change what you wish. You can filter out groups of mobs, add new rows, filter based on items, etc. you do still need to adhere to the rule of keeping all mob rows together (all loot rows for a mob must be next to each other).

Once complete simply save the file as a new csv or overwrite the existing one (excel will warn you about formatting, but you don't want the formatting).

When you are done editing, it is time to import it with this script. Import really isn't the best term here as you are actually creating a new file:
Code:
//--------------------------------------
//--- 010 Editor v5.0 Script File
//
// File:    item_looting_import.1sc
// Author:  GMoney
// Revision:
// Purpose:
//--------------------------------------
//#include "general_functions.1sc";

//If you are using Intrepid Web scripts, simply add this to general_functions.1sc
int string_to_int(string number)
{
    int len, i, return_num = 0;
    len = Strlen(number);
    for(i = 0; i < len; i++)
    {
        return_num = return_num * 10 + (number[i] - '0');
    }
    return return_num;
}

//path to the csv to import from
string importPath = "C:\\PathTo\\import.csv";
string destinationPath = "C:\\PathTo\\ItemLooting.dat";
int i = 0, y, pos, eofPos = 0, currentItem = 0;
int newFile = FileNew();
int csvFile = FileOpen(importPath);
int fileSize, delIndex;
char currentLine[];
string temp = "";

int numItems = 0;

//INSERT HEADER INFO
FileSelect( newFile );

InsertBytes(0, 4);
WriteInt(eofPos, 1); //placeholder for number of blocks
eofPos += 4;

InsertBytes(eofPos, 4);
WriteInt(eofPos, 206); //number of columns
eofPos += 4;

InsertBytes(eofPos, 4);
WriteInt(eofPos, 1684); //block size
eofPos += 4;

//PARSE CSV
FileSelect( csvFile );
fileSize = FileSize();
pos = 0;

while (pos < fileSize)
{
    FileSelect( csvFile );
    currentLine = ReadLine(pos, -1);
    pos += Strlen(currentLine);
    currentLine += ",";

    FileSelect( newFile );

    InsertBytes(eofPos, 4);
    WriteUInt(eofPos, numItems); //index
    eofPos += 4;    

    currentItem = 0;
    while(Strstr(currentLine, ",") > 0)
    {
        // Get the first commans position
        delIndex = Strstr(currentLine, ",");
        if(currentItem == 0)
        {
            //Mob code
            InsertBytes(eofPos, 64);
            WriteString(eofPos, SubStr(currentLine, 0, delIndex));
            eofPos += 64; 
        }
        else if (currentItem < 5)
        {
            //lootrate, loottime, operationcount, totalloot
            InsertBytes(eofPos, 4);
            WriteInt(eofPos, string_to_int(SubStr(currentLine, 0, delIndex)));
            eofPos += 4; 
        }
        else
        {
            //item
            InsertBytes(eofPos, 8);
            WriteString(eofPos, SubStr(currentLine, 0, delIndex));
            eofPos += 8; 
        }
        currentItem++;
        currentLine = SubStr(currentLine, delIndex+1, -1);
    }

    numItems++;
}

//rewrite the block count
DeleteBytes(0, 4);
InsertBytes(0, 4);
WriteInt(0, numItems);

FileSave( destinationPath );
FileClose();

Test, rinse and repeat when needed.

You can also do some things in the script if you like. I ignored all rows that had "0" for the lootRate on the export and got rid of unused lines.

If there are enough people that use 010 Editor and would like to get the SVN active again for templates and scripts, let me know.
 
Junior Spellweaver
Joined
Feb 16, 2012
Messages
119
Reaction score
21
finally some one share editing with excel method
ty for your tutorial
i hope more step by step for lecher like me ^^

finnaly i can do it too lol
gregcool - [Guide] Edit Files in Excel using 010 Editor (shown for ItemLooting) - RaGEZONE Forums


my question :
1. how can get header like monstertab,count tab, botty ,etc
2. after i edit some drop lootitem what must i do take back that file to (.dat) again
3. ty for awesome tutorial
4. hope some one finish all script export for server script or client

ty so much
 
Last edited:
Joined
Jun 7, 2012
Messages
506
Reaction score
23
do u even read bro?

//--------------------------------------
//--- 010 Editor v5.0 Script File
//
// File: item_looting_import.1sc
// Author: GMoney
// Revision:
// Purpose:
//--------------------------------------
//#include "general_functions.1sc";

//If you are using Intrepid Web scripts, simply add this to general_functions.1sc
int string_to_int(string number)
{
int len, i, return_num = 0;
len = Strlen(number);
for(i = 0; i < len; i++)
{
return_num = return_num * 10 + (number - '0');
}
return return_num;
}

//path to the csv to import from
string importPath = "C:\\PathTo\\import.csv";
string destinationPath = "C:\\PathTo\\ItemLooting.dat";
int i = 0, y, pos, eofPos = 0, currentItem = 0;
int newFile = FileNew();
int csvFile = FileOpen(importPath);
int fileSize, delIndex;
char currentLine[];
string temp = "";

int numItems = 0;

//INSERT HEADER INFO
FileSelect( newFile );

InsertBytes(0, 4);
WriteInt(eofPos, 1); //placeholder for number of blocks
eofPos += 4;

InsertBytes(eofPos, 4);
WriteInt(eofPos, 206); //number of columns
eofPos += 4;

InsertBytes(eofPos, 4);
WriteInt(eofPos, 1684); //block size
eofPos += 4;

//PARSE CSV
FileSelect( csvFile );
fileSize = FileSize();
pos = 0;

while (pos < fileSize)
{
FileSelect( csvFile );
currentLine = ReadLine(pos, -1);
pos += Strlen(currentLine);
currentLine += ",";

FileSelect( newFile );

InsertBytes(eofPos, 4);
WriteUInt(eofPos, numItems); //index
eofPos += 4;

currentItem = 0;
while(Strstr(currentLine, ",") > 0)
{
// Get the first commans position
delIndex = Strstr(currentLine, ",");
if(currentItem == 0)
{
//Mob code
InsertBytes(eofPos, 64);
WriteString(eofPos, SubStr(currentLine, 0, delIndex));
eofPos += 64;
}
else if (currentItem < 5)
{
//lootrate, loottime, operationcount, totalloot
InsertBytes(eofPos, 4);
WriteInt(eofPos, string_to_int(SubStr(currentLine, 0, delIndex)));
eofPos += 4;
}
else
{
//item
InsertBytes(eofPos, 8);
WriteString(eofPos, SubStr(currentLine, 0, delIndex));
eofPos += 8;
}
currentItem++;
currentLine = SubStr(currentLine, delIndex+1, -1);
}

numItems++;
}

//rewrite the block count
DeleteBytes(0, 4);
InsertBytes(0, 4);
WriteInt(0, numItems);

FileSave( destinationPath );
FileClose();
 
Joined
Apr 9, 2012
Messages
2,357
Reaction score
440
have anyone try importing csv to dat?
when i try to create script based on this, if the value is -1, it's not converted to FFFFFFFF but E3FFFFFF.
and in the end of the files, it returned -388 = 7CFEFFFF

---------update-------
i fix it using Atoi(currentline)
instead of string_to_int(SubStr(currentLine, 0, delIndex))
 
Last edited:
Newbie Spellweaver
Joined
Apr 3, 2016
Messages
9
Reaction score
2
hello guys,
sorry, i really like this tuto, but i'm very noob about that!
when i run the script on 010, i got that error

Executing script 'D:\Program Files\010 Editor\development\010-editor\010 Scripts\exportexcel\ItemLooting.1sc' on 'D:\work\work_rf\RF ONLINE\RF server\Edits_Server\ItemLooting.dat'...
*ERROR Line 21: Variable 'header' is undefined.

Same error if i copy script from here.

any1 can help-me? at all web search, this the only place with this guide about RF
 
Newbie Spellweaver
Joined
Apr 3, 2016
Messages
9
Reaction score
2
I don't see any error
my bad, sorry... writing was invisible by selecting you can see.

>> hello guys,
sorry, i really like this tuto, but i'm very noob about that!
when i run the script on 010, i got that error

Executing script 'D:\Program Files\010 Editor\development\010-editor\010 Scripts\exportexcel\ItemLooting.1sc' on 'D:\work\work_rf\RF ONLINE\RF server\Edits_Server\ItemLooting.dat'...
****ERROR Line 21: Variable 'header' is undefined.****

Same error if i copy script from here.

any1 can help-me? at all web search, this the only place with this guide about RF
 
Newbie Spellweaver
Joined
Apr 3, 2016
Messages
9
Reaction score
2
you need to apply the template first before running the script

first i open ItemLooting.dat on 010
next, i open ItemLooting.bt, and run
next i open ItemLooting.1sc from folder excelexport
there i got this error.

*ERROR Line 21: Variable 'header' is undefined.*

line 21: is ***for(i = 0; i < header.blocks; i++)***
 
Back
Top