Author Topic: Need an equivalent to export() for SimObject tagged fields.  (Read 1977 times)

I have this:

Code: [Select]
new SimObject("Microlite")
{
datalList = "name level str dex mind hp ac class race physical subterfuge knowledge communication strmod dexmod mindmod attackmeleemod attackmagicmod attackmisslemod inventory";
worldName = "Blockland"; // todo: figure out how to save config data
dungeonMaster = getNumKeyId(); // get host bl_id
};

exec("microlite/config.cs");
function Microlite::save()
{
export("Microlite.*", "microlite/config.cs");
}
It's untested but I don't honestly believe it'll work, can someone suggest something better? I need to backup the fields noted in the definition of the SimObject.

I could do something like this, which I am doing elsewhere for other things:
Code: [Select]
function Microlite::exportCharacter(%client)
{
echo("Exporting character for " @ %client.blid);
%path = "microlite/" @ %client.blid @ ".txt");

new fileObject("MicroliteFO");
MicroliteFO.openForWrite(%path);
for(%i = 0; %i < getWordCount(Microlite.dataList); %i++)
{
%var = getWord(Microlite.dataList, i);
MicroliteFO.writeLine(%var @ "\t" @ %client.Microlite[%var]);
}
echo("Exported character.");
MicroliteFO.close(); MicroliteFO.delete();
}
Note the reference to Microlite.dataList, defined in the first bit of code.
The stuff I'm exporting for the character sheets is defined as %client.Microlite[%var], where name is one of the things in Microlite.dataList. I could the same sort of thing, manually exporting it, but I was hoping for a default functions similar to export(variableRegex, pathTo.cs);.

Any suggestions?

The entire code, neccesary for whatever purpose, can be found here.

%microlite.save("config/microlite.cs");

exec("config/microlite.cs"); to get it back


...whatever a mircolite is

seriously
are you loving kidding me its that easy
well stuff

it's a this: http://forum.blockland.us/index.php?topic=240948.0

Will this work for scriptobjects as well?

Will this work for scriptobjects as well?

It works for any conobject-class.

did lugnut really not know this?

Yea, Lugnut who hasn't coded torquestuff for a year did not know of this particular somewhat obscure method.

Yea, Lugnut who hasn't coded torquestuff for a year did not know of this particular somewhat obscure method.
I'm not trying to insult your scripting abilities or anything but ConObject::save(path) isn't a very obscure method. It's just not a super practical method for normal scripting (kind of like ConObject::dump()) so you never found out about it and likely missed it in dumps of other objects.

Yeah I've never used it before