• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Directory Reading!

First: I have NOT tested this yet, just found it; so it may be it needs something turned on in a DLL and won't work for us. But I'm an optimist.

Pieter pointed out that the US version lacked a file called CheckDlgLoad.c

I looked in it and beheld the Holy Grail of POTC modding (well, POTC _scripting__): Directory reads, and loading all files within a directory.

What does this mean? It means each modder can have his or her own item, ship, model, whatever, init file--and the script _does not have to know their names_.
I.e. you can finally do:
#include "Directory*.*"

Which means that _any_ modder who adds a new item need not modify a core file (nor have it overwritten on update!).

Code:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->object objChkDlg;

objChkDlg.dir = "DIR_TO_CHECK";

objChkDlg.mask = "*.h"; // or other wildcard based mask, I presume.

CreateEntity(&objChkDlg,"FINDFILESINTODIRECTORY");

DeleteClass(&objChkDlg);

//then:

objChkDlg.filelist.* // one attribute per file, with the attr. value the filename.

//so then if you want to do all:

aref arList, arCur;

makearef(arList,objChkDlg.filelist);

for(int i = 0; i < GetAttributesNum(arList); i++)

{

    arCur = GetAttributeN(arList,i);

    if(LoadSegment(GetAttributeValue(arCur)))

    {

 Execute_function(); // or whatever function is in the file

 UnloadSegment(GetAttributeValue(arCur));

    }

}<!--c2--></div><!--ec2-->
 
<img src="http://www.musicats.com/images/whoa.gif" border="0" class="linked-image" /> <span style='`font-size`:25pt;`line-height`:100%'><b>mo</b></span><span style='`font-size`:30pt;`line-height`:100%'><b>JO!!!</b></span> <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" />

I hope it works, I hope it works, I hope it works!!! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/william.gif" style="vertical-align:middle" emoid=":will" border="0" alt="william.gif" />
 
<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_eek.gif" style="vertical-align:middle" emoid=":shock:" border="0" alt="icon_eek.gif" /> No more copies of all the -init files before getting a new mod <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/william.gif" style="vertical-align:middle" emoid=":will" border="0" alt="william.gif" /> That would be, well, it´s beyond words. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_praise.gif" style="vertical-align:middle" emoid=":bow" border="0" alt="icon_praise.gif" />
 
If you look at seadogs.c

void Main()
{

if(LoadSegment("storeinitGoods.c"))
{
InitGoods();
UnloadSegment("storeinitGoods.c");
}

if(LoadSegment("InterfaceBaseInterface.c"))
{
InitBaseInterfaces_main();
InitBaseInterfaces();
UnloadSegment("InterfaceBaseInterface.c");
}
...


It can be set on if (Mod == 1)

But what do it give to the game??

Some diff param in start??
 
Nathan - hurray! I think this amounts to the moddings style that Scheffnow suggested all along.

Alexus, so sorry, but I dont understand what you're trying to say.
What will be on if Mod == 1 ??
And how will that be set to 1 ? (Is that what you're asking - whether i'ts a startup parameter ? ) Or is it set in engine.ini ?
 
Inez: Bingo! Part of it, though, not the preprocessor part that'd do `code-swapping`.

ALexusB: it gives no advantage if you're not allowing `end-user` modifications or choices (because if that's so, then you do all the modding to the stock files)
But if the code's open, then you can do, for example:
Set up a directory programgoodsinit
In there place all init files that relate to goods (i.e. stock goods file, and the new goods file that adds your mod's goods). Then anyone who wants to add more goods, just adds a file to that directory, with the same function name as the others, and new goods defines.
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->if(LoadSegment("storeinitGoods.c"))

{

    InitGoods();

    UnloadSegment("storeinitGoods.c");

    //do directory processing here

    for(int i = 0; i < Numer_of_Files_in_dir; i++)

    {

 loadsegment(filename i);

 InitGoods();

 Unloadsegment(filename i);

    }

}<!--c2--></div><!--ec2-->

And that will load any and all goods init files. No need to change the base files, just add new ones.

Doing this for ships or items would be more clearly advantageous (because for goods, they're not `self-contained`, you have to set up trade types on the islands. But items and ships are (at least the way I and others have modified the items and ships backends) `self-contained`--whenever you add a new ship or item, you need only touch the init file and the scripting will handle the availability...
 
You can also do neat stuff like changing settings based on whether files exist or not (rather than reading them and checking #defines).
The only downside is I can't think how to apply this to the INIs, because you'd also want them to be read initexts*.*.
So maybe Scheffnow's `external-tool` approach _is_ still necessary...
 
Back
Top