Resource Generator (Lua component)

Hi,

A was trying to use this mod component to build a small minimod for myself, however, I am having trouble with it and was hoping you could help me. I am trying to add a new strategic resource to the game. The new resource appears correctly in the tech tree and in the strategic resources bar. However, it isn't added to the map.

In the FireTuner I have the following error messages after the GenericPopup: Loaded Popup messages:

Runtime Error: [string "C:\Users\Me\Documents\My Games\Sid..."]:9: attempt to call global 'OnMapResourceGenerator' (a nil value)
Runtime Error: Error loading C:\Users\Me\Documents\My Games\Sid Meier's Civilization 5\MODS\Mods\Brick by Brick (v 1)\LUA\AddNewResource.lua.

It seems to be connected that the include("ResGenerator.lua"); isn't properly included, sadly I am not any good at any LUA scripting, so I am asking here for help.

Any thoughts on this error message and how to avoid it?

Many thanks in advance!
 
Hi,

A was trying to use this mod component to build a small minimod for myself, however, I am having trouble with it and was hoping you could help me. I am trying to add a new strategic resource to the game. The new resource appears correctly in the tech tree and in the strategic resources bar. However, it isn't added to the map.

In the FireTuner I have the following error messages after the GenericPopup: Loaded Popup messages:

Runtime Error: [string "C:\Users\Me\Documents\My Games\Sid..."]:9: attempt to call global 'OnMapResourceGenerator' (a nil value)
Runtime Error: Error loading C:\Users\Me\Documents\My Games\Sid Meier's Civilization 5\MODS\Mods\Brick by Brick (v 1)\LUA\AddNewResource.lua.

It seems to be connected that the include("ResGenerator.lua"); isn't properly included, sadly I am not any good at any LUA scripting, so I am asking here for help.

Any thoughts on this error message and how to avoid it?

Many thanks in advance!

Try setting "Import Into VFS" to True for each lua file (in Modbuddy Right click on the lua file and select properties).
 
Got some resource icons, so I am going to see if I can use your promising mod to get them in game. :)

Ok, so I got it working, kind of.

It replaced all my Marble with my Cocoa, and it only shows the Marble Icon(instead of my custom Icon), no spices graphic.

Going to tinker around with it some more, though probably hit it again in the morning.
 
Can't seem to get it to work. I have tried everything I can in the resource file, but nothing changes.

When I get in the game, my Cocoa resource uses the Marble Icon and has invisible art. Sometimes in firetuner I can see: "Map Script: Failed to place 2 units of Marble."

Not sure what the fixation on Marble is. I can change the resource to a modern or rush resource, remove all aspects of luxury from Cocoa, and it is always the same. It uses Marble whether I try a new icon, or use info for Spices.
 
Can't seem to get it to work. I have tried everything I can in the resource file, but nothing changes.

When I get in the game, my Cocoa resource uses the Marble Icon and has invisible art. Sometimes in firetuner I can see: "Map Script: Failed to place 2 units of Marble."

Not sure what the fixation on Marble is. I can change the resource to a modern or rush resource, remove all aspects of luxury from Cocoa, and it is always the same. It uses Marble whether I try a new icon, or use info for Spices.


I am sure it will work as in Chocolate example in my first post.

Try these:
- For your Art files always save as DDS DTX3 or DTX5.
- Set "Import into VFS" to true to all Art files
- Set "Import into VFS" to true to all Lua files
- Enable "Reload Landmark System" in mod properties
- Sometimes resetting the game makes things work

if nothing work then post your mod file here so that I check it (Isolate the Cocoa Resource files in your mod into a new mod then post it here).
 
I am sure it will work as in Chocolate example in my first post.

Try these:
- For your Art files always save as DDS DTX3 or DTX5.
- Set "Import into VFS" to true to all Art files
- Set "Import into VFS" to true to all Lua files
- Enable "Reload Landmark System" in mod properties
- Sometimes resetting the game makes things work

if nothing work then post your mod file here so that I check it (Isolate the Cocoa Resource files in your mod into a new mod then post it here).

Hmm, the reload landmark is something I haven't tried. I will take one last stab at it and see what happens. :) I won't bother with new icons until I see it working with stock icons. And I will copy your example verbatim and go from there. :)
 
Now nothing is happening. It won't even attempt to load.

I will probably come back for this at a later date, after I have taken care of a few other things in my mod.
 
Ok, so on my second series of tries, I got it working. :) So far it is pretty good. I have some observations and requests though.

First, is that the MaxLattitude doesn't seem to limit how north the resources wander. Having Coffee grow on Snowy hills near the poles is a little off.

Second, is that my Coffee is also growing on desert hills. Not as bad, but not preferable.

So my main request involves the ability to set disables for specific terrain/feature types. Such as no snow/desert, or no forests, etc.

If you can do it, awesome, if not, it still works pretty well. :)
 
Oh, I have 1 more request.

Could you make an advanced setup option that would allow players to tweak the quantity of resources placed? Preferably ~5 settings, ranging from sparse to abundant.
 
First, is that the MaxLattitude doesn't seem to limit how north the resources wander. Having Coffee grow on Snowy hills near the poles is a little off.

I didnt include max latitude in the algorithm.. this will be a good addition to next vesrion.

So my main request involves the ability to set disables for specific terrain/feature types. Such as no snow/desert, or no forests, etc.

that depends of your settings on TerrainBooleans and FeatureBooleans, if you dont put desert in TerrainBooleans you will not get a resource on desert.

If you are talking about combination like for example Terrain Grass but no forest, then this needs extra work.. I will consider adding this to next version because I need this option myself :)

Could you make an advanced setup option that would allow players to tweak the quantity of resources placed? Preferably ~5 settings, ranging from sparse to abundant.

There is an easy way to modify this in lua, edit ResGenerator.lua and go to the following lines:
Code:
	-- Now multiply quantity with modifiers
	iQuantity = iQuantity * option_modifier *NumCivs_modifier;

Now add your modifier to Quantity, like for example:
Code:
iQuantity = [COLOR="Red"][B]1.5 * [/B][/COLOR]iQuantity * option_modifier *NumCivs_modifier;
 
I didnt include max latitude in the algorithm.. this will be a good addition to next vesrion.

Get MinLattitude while you are hitting that one please. :)



that depends of your settings on TerrainBooleans and FeatureBooleans, if you dont put desert in TerrainBooleans you will not get a resource on desert.

You still get resources on Desert, Tundra, and Snow Hills though.

If you are talking about combination like for example Terrain Grass but no forest, then this needs extra work.. I will consider adding this to next version because I need this option myself :)

Great. :)

There is an easy way to modify this in lua, edit ResGenerator.lua and go to the following lines:
Code:
	-- Now multiply quantity with modifiers
	iQuantity = iQuantity * option_modifier *NumCivs_modifier;

Now add your modifier to Quantity, like for example:
Code:
iQuantity = [COLOR="Red"][B]1.5 * [/B][/COLOR]iQuantity * option_modifier *NumCivs_modifier;

So the 1.5 would multiply the values I have set in the generator by 1.5? And I would duplicate those 2 blocks of code for each option with a different modifier? Or just duplicate the last block?
 
So the 1.5 would multiply the values I have set in the generator by 1.5? And I would duplicate those 2 blocks of code for each option with a different modifier? Or just duplicate the last block?

if you use 1.5 modifier as in the example you will get 50% more resources, this is the net quantity modifier you only edit the line of code once and no need to duplicate it.

do you want to change the Options Modifiers (Sparse,Strategic..etc) themselves not only the net value?
 
I want a new option in advanced setup that lets you choose from several different modifiers, such as .5, 1, 1.5, 2, etc.

Unfortunately that is beyond the scope of this mod component, because it needs UI modding and this mod is only a lua component.

Any way you can modify these values in ResGenerator.lua in the following lines:
Spoiler :
Code:
	if New_Resource_Class == "RESOURCECLASS_LUXURY" then
		if resource_option == 1 then option_modifier = 0.75;
		elseif resource_option == 2 then option_modifier = 1;
		elseif resource_option == 3 then option_modifier = 1.2; 
		elseif resource_option == 4 then option_modifier = 1.1;
		elseif resource_option == 5 then option_modifier = 1;
		end
	elseif New_Resource_Class == "RESOURCECLASS_RUSH" or New_Resource_Class == "RESOURCECLASS_MODERN" then
		if resource_option == 1 then option_modifier = 0.75;
		elseif resource_option == 2 then option_modifier = 1;
		elseif resource_option == 3 then option_modifier = 1.5; 
		elseif resource_option == 4 then option_modifier = 1;
		elseif resource_option == 5 then option_modifier = 1.2;
		end
	elseif New_Resource_Class == "RESOURCECLASS_BONUS" then
		if resource_option == 1 then option_modifier = 0.75;
		elseif resource_option == 2 then option_modifier = 1;
		elseif resource_option == 3 then option_modifier = 1.2; 
		elseif resource_option == 4 then option_modifier = 1.1;
		elseif resource_option == 5 then option_modifier = 1;
		end
	end

resource_option IDs are explained in the code comments, but here is a quick reference:
Spoiler :
Code:
OptionName		OptionID
Sparse			1
Standard		2
Abundant		3
Legendary Start		4
Strategic Balance	5
Random			6
 
That sounds like it can handle what I need. I will go .5, 1, 2, and 4 modifiers for the first 4 options. Thanks. :)

Have you thought about making it so that certain resources only spawn on 1 continent or region? Such as Rice spawning in the old world and Corn spawning in the New World.
 
I think this need a bit more explanation from me:

the code here :

Code:
	if New_Resource_Class == "RESOURCECLASS_LUXURY" then
		if resource_option == 1 then option_modifier = 0.75;
		elseif resource_option == 2 then option_modifier = 1;
		elseif resource_option == 3 then option_modifier = 1.2; 
		elseif resource_option == 4 then option_modifier = 1.1;
		elseif resource_option == 5 then option_modifier = 1;

This translates into:
Luxury Resouce => resource_option = 1 (Sparse) => Modifier = 0.75
Luxury Resouce => resource_option = 2 (Standard) => Modifier = 1
......
and so on.

note that these modifiers are only for new added resources and changing them will not affect Vanilla resources.
 
I think this need a bit more explanation from me:

the code here :

Code:
	if New_Resource_Class == "RESOURCECLASS_LUXURY" then
		if resource_option == 1 then option_modifier = 0.75;
		elseif resource_option == 2 then option_modifier = 1;
		elseif resource_option == 3 then option_modifier = 1.2; 
		elseif resource_option == 4 then option_modifier = 1.1;
		elseif resource_option == 5 then option_modifier = 1;

This translates into:
Luxury Resouce => resource_option = 1 (Sparse) => Modifier = 0.75
Luxury Resouce => resource_option = 2 (Standard) => Modifier = 1
......
and so on.

note that these modifiers are only for new added resources and changing them will not affect Vanilla resources.

Got it.

And it's fine about the Vanilla resources. I am going to delete their entires in assignstartingplots.lua and add them to the map using your mod. :)
 
Is there some code that pushes all the resources out of the vicinity of the player? If I ramp up the resource generation enough then I can see the player surrounded by maybe 3-8 resources, but outside that start zone nearly every tile can be covered in resources.

Also, is there any way to modify the generation rate of individual resources?
 
Top Bottom