Majic-Jungle / sapiens-mod-creation

Official tools and examples for mod creation in the game Sapiens
MIT License
54 stars 12 forks source link

Custom world gen settings #21

Closed suppergerrie2 closed 1 year ago

suppergerrie2 commented 1 year ago

Currently there is no way I know to add custom settings to the world gen menu to be used in C mods. I'm not sure how this would be implemented, maybe a dictionary or lua table mods can put custom settings in and load from C?

mjdave commented 1 year ago

I've now added support for this in 0.4 with:

typedef struct SPWorldGenOptions {
    double heightOffset;
    double rainfallMultiplier;
    double temperatureOffset;
    SPVec3 scales;
    SPVec3 influences;

    SPVec4 userDataA; //these can all be used for mods that want to add more options. They are read from the table passed through from Lua.
    SPVec4 userDataB;
    SPVec4 userDataC;
    SPVec4 userDataD;
    void* userDataP; //any data can be stored in here by mods. On the Lua side, it needs to be passed in the customOptions table as a lua string for the key 'userDataP'. A good way to do this might be to serialize your own struct using LuaJIT's FFI

} SPWorldGenOptions;