SetResourceType lua questions/problems

Aldollin

Chieftain
Joined
Mar 7, 2017
Messages
87
so for a custom civ i made some lua code that gives them a chance to "discover" resources when building a mine on a tile that does not have a resource, 2 problems showed up that i cant figure out:

1. The resources are added to the map(and you can see them just fine) , they affect the tiles yield correctly, but otherwise the game does not seem to recognize them, i.e. you dont get the resources to trade, you dont get the amenities, and strategic resources like iron wont work for units that require them

2. Modifers that affect plot yields and require a resource to be present do only apply to these newly added resources after reloading the game.
i used the vanilla requirementsets
PLOT_HAS_STRATEGIC_MINE_REQUIREMENTS
PLOT_HAS_BONUS_MINE_REQUIREMENTS
PLOT_HAS_LUXURY_MINE_REQUIREMENTS
as well as all possible combinations of
RunOnce and Permanent
and none of them worked

in the lua script i used ResourceBuilder.SetResourceType(pPlot, resource, 1)

is there anything i am missing?
can anyone tell/guess what the problem/mistake could be?(and maybe even how to fix it)
 
not sure it will work, but try to remove and put back the mine after adding the resource.
 
not sure it will work, but try to remove and put back the mine after adding the resource.

i tried that, both by using lua to set improvementtype to none and then back to a mine and by removing the mine with a builder and rebuilding it, no result, i still dont get the resource

it seems that everything lua related recognizes the resource, pPlot:GetResourceType gives the right result, and the CQUI builder lens marks it as a tile with a resource that needs an improvement
 
okay so i tested some more and found a solution to my first problem:
if you, before placing the resource remove the mine, then place the resource and put the mine back, you get the resource

while if you place the resource(on a tile with a mine) then remove the mine and put it back (in that order) it wont work

no idea why, but it works now

modifiers seem to still not work
 
Did you look at how Firetuner adds resources? The resources added with it seem to work fine. I don't know what difference exist between Firetuner scripts and in-game ones though.
 
Back
Top Bottom