Placing Custom Resources

S3rgeus

Emperor
Joined
Apr 10, 2011
Messages
1,270
Location
London, United Kingdom
Has anyone already solved the problem of placing new custom resources through AssignStartingPlots.lua? (I opened this file and upon comprehending the volume of horror contained within, returned here in hopes that someone else has already dealt with this particularly time-intensive task.) Looking at other custom resources mods, I see Barathor's More Luxuries explicitly adds his own resources with configuration calibrated to properly distribute his resources.

I remember there being a mod that did this (you added a single line of Lua at the top of AssignStartingPlots.lua which said which XML resource you were adding) but given I haven't seen it updated on here and I believe that was pre-G&K, I imagine it doesn't function correctly any more.

Help would be much appreciated, I would strongly prefer to not have to rip apart AssignStartingPlots.lua to make it more easily configurable. Just understanding alone would take very long, let alone testing that the resulting distributions were fair.
 
The code in AssignStartingPlots.lua is beyond my comprehension, so I removed the part that places resources altogether, and replaced it with my own code that does it in a simple way - it doesn't do things like adding extra resources at starting locations, balancing them by continents or regions etc. - it just places them randomly depending on the terrain and feature type, using some new columns in the database that I defined.

I made these changes in the G&K version of my mod, I haven't done it in the BNW version yet, but I hope there won't be many changes required to make my old version of AssignStartingPlots work with BNW - actually I'm going to do it soon, so if you're interested, I can share my version of the file with you.

Alternatively, you can use the method that is used to place resources on worldbuilder maps, using existing columns in the database - see WorldBuilderRandomItems.lua.
 
Bluesea's Resources Generator still works to this day. Its in CCTP or any of my Resource mods. I reverted to using this rather than AssignStartingPlots.lua for simplicity more than anything else(oh and I didn't like the Grouping in AssignStartingPlots)

Looking over AssignStartingPlots in Barathor's More Luxuries he has a better understanding of that file than myself. Poke him for some tips, failing that I am willing to help with this file if ya need it.

Edit: Added the Lua files for the Resource Generator.

You need an Entry Point for you mod to fire this Generator(It will not refire if you use the Restart Option form within a loaded game)

<EntryPoint type="InGameUIAddin" file="Lua/New_Main.lua">
<Name>Resource Generator</Name>
<Description>Generates New Resources on Maps</Description>
</EntryPoint>
 
Interesting stuff, guys, thanks! And thanks for the files, Horem! Bluesea's generator was the one I was referring to in my first post, glad it still works! However, I thought that generator hooked into the way AssignStartingPlots already worked (rather than replaced it). I can see that that might be easier than deciphering Firaxis' system, but I quite like the resource distribution they get out of the built-in system. I like how some 'clumping' means that there will be some resources which are scarce or only accessible to certain places, encouraging far-reaching expansion.

I think I'll use Bluesea's generator for now, but hopefully I'll be able to work from what Barathor did to make a more modular system that leverages Firaxis' distribution method (eventually).
 
As much as I hate the coding of AssignStartingPlots.lua, I really do like the resource grouping and other effects. Makes each continent seem unique.

I added the first few resources by simply copying existing resources in AssignStartingPlots as template. But since my mod has such different yields, I really needed to understand the algorithms to modify them for the mod's needs. It is possible to understand it if you put in the time. After that, it's pretty easy to add in new resource or alter the distribution of existing ones.

And who wouldn't want to play a civilization of opium farming Sídhe? (My apologies, Horem, for corrupting your beautiful poppies to my own evil purposes.)
 
The code in AssignStartingPlots.lua is beyond my comprehension, so I removed the part that places resources altogether, and replaced it with my own code that does it in a simple way - it doesn't do things like adding extra resources at starting locations, balancing them by continents or regions etc. - it just places them randomly depending on the terrain and feature type, using some new columns in the database that I defined.

I made these changes in the G&K version of my mod, I haven't done it in the BNW version yet, but I hope there won't be many changes required to make my old version of AssignStartingPlots work with BNW - actually I'm going to do it soon, so if you're interested, I can share my version of the file with you.

Alternatively, you can use the method that is used to place resources on worldbuilder maps, using existing columns in the database - see WorldBuilderRandomItems.lua.

Any chance you can upload your resource-less version of AssignStartingPlots.lua? I'd like to use it together with BlueSea's Resource Generator to replace all the default resources in a mod.

Thanks!
 
Any chance you can upload your resource-less version of AssignStartingPlots.lua? I'd like to use it together with BlueSea's Resource Generator to replace all the default resources in a mod.

Thanks!

I still don't have a BNW version of AssignStartingPlots.lua ready, it's one of the things I need to do before releasing my mod (I'm going to use a bit different method of placing resources than in G&K version). But if you only want to remove resources, it shouldn't be hard to delete (or comment out) all calls to functions that place them.

If you really need my G&K version of the file, you can find it here.
 
I still don't have a BNW version of AssignStartingPlots.lua ready, it's one of the things I need to do before releasing my mod (I'm going to use a bit different method of placing resources than in G&K version). But if you only want to remove resources, it shouldn't be hard to delete (or comment out) all calls to functions that place them.

If you really need my G&K version of the file, you can find it here.

Thanks a ton! I'll look forward to seeing the updated version in your mod when it's ready.
 
Back
Top Bottom