Understanding the stacking of Civ 5 terrain and features and modifying it.

Unfortunately, I'm currently in the thick of the last of us remastered. Once I've finished that I'll give this a go.
Also, if possible, it'd be cool to have fiveout contamination as NOT a feature. That way I could probably get the graphics working, and it could stack with all of the other features.
I'd just have to find a mod that applies non vanilla graphical effects to tiles, so I could study the code.
 
OK, if I change the feature I want to change it to forest, it works fine. I now have to get it working with fiveout.
 
Graphics in the 3D map only update for some features - those you can chop or clear IIRC, so forest, jungle, marsh and fallout - others (eg ice) will be removed/changed but the 3D map will not update until you save/reload the game. (This is one reason why the DLL is hard-coded to not "melt the ice-caps" when you fire a nuke that includes ice.) The SV map updates immediately though.
 
Yep, I encountered that problem, but figured that for the purposes of functionality, I should overlook it until I can get the core problems fixed. The main problem is setfeaturetype doesn't seem to work- when I ask it to change a tile feature to a new feature that I have included in my mod (feature_l1), it doesn't change it to feature_l1- it changes it to feature_ice. I'm pulling my hair out trying to figure out where I went wrong- my lua seems solid. The only explanation I can come up with is that setfeaturetype can't seem to figure out what feature_l1, even though it is a valid feature that I can place in worldbuilder and that appears in game when placed by worldbuilder. As it can't figure it out, it defaults to 0 (doesn't everything?) which happens to be the feature id for ice. It seems like a logical explanation for what I observe. If that's the case, how do I get setfeaturetype to recognise new features?
 
pPlot:SetFeatureType() definitely works, so you should work on the assumption that you are passing 0 as the parameter. Have you tried adding a print to confirm the value you are passing.
 
For many Lua functions obj:SetBlahBlahType(nil) gives you the same exact result as obj:SetBlahBlahType(0). So it is good to learn the ID=0 items in your mod because these are the ones that appear when you screw something up with your args and pass a nil. (In Éa the unit with ID=0 used to be a workboat, so the mod spawned workboats whenever I goofed up with InitUnit.)

The construction feature_l1 is rather weird. Are you intentionally try to say feature_ or 1? This will evaluate to feature_ (if not nil) or 1 (if feature_ is false or nil). Never mind. Was reading your post literally.

I don't remember off the top of my head if FEATURE_ICE is ID 0 or 1, but I'm pretty sure it is one of those. Edit: OK, 0 supports the notion that you are sending nil

Edit2: I can absolutely guarantee that you are sending nil and so can you. Type this in Fire Tuner:
Code:
>print(FeatureTypes.FEATURE_L1)
nil
>print(GameInfoTypes.FEATURE_L1)
--will print number if it was successfully added to the Features table.

--or look at entire table contents with:
>for k,v in pairs(FeatureTypes) do print(k,v) end
... --only base features

>for k,v in pairs(GameInfoTypes) do print(k,v) end
... --very long list
"Enum tables" like FeatureType, ImprovementType, and so on are created by the DLL and match the base Civ5 (unmodded!) tables. So if you add a feature to the Features table, it will not be reflected in the FeatureTypes table. The workaround for this is easy, however. Just use GameInfoTypes instead. It is constructed from your modded DB tables and contains keys for every item in every table that has the standard Type/ID construction.


On graphics:
It's definitely true that feature graphics won't update in-game on the main map for added features (or for any NWs or atoll, for that matter). I thought that the original 7 or 8 worked fine (including ice) but haven't tested that. Forest, Jungle, Marsh and Fallout are the only ones that definitely work. Edit: what Nutty said below. Don't even think that you will be able to solve this one. (A hack is possible however where your "feature" is really an improvement or resource.)
 
Forest, Jungle, Marsh and Fallout are the only ones that definitely work.
If you add oasis, then those are the only ones that work, period (i.e., not flood plains nor ice).

As mentioned above, there is a very lengthy exploration here [talking about the problems swapping them out with new graphics].
 
So, I've changed the mod, so Fiveout contamination is a set of 4 different resources now, so that it'll update the models. The only problem is, when I have the mod activated, I can't place the resource either in worldbuilder or Firetuner (when I've made a game). What do?
 

Attachments

I don't ever work with Worldbuilder so someone else will have to give a more specific answer. But I understand that there is a problem with it knowing table IDs for things added (or changed) by a mod. That is, it doesn't.

If you are using Worldbuilder simply to test mod effects, don't. Use Fire Tuner or IGE mod to add/change stuff. If you really need it to create a specific map scenario, I think there may be workarounds but someone else will have to address that.
 
Civ5 seems pretty temperamental. Got it working by removing everything new, and rebuilding one step at a time. Now everything works, except for the production bonus. As it isn't a feature, I tried putting <Production>20</Production> in the part where the build is defined. Didn't work. Then tried to do this: Still didn't work.

Spoiler :
<BuildFeatures>
<Row>
<BuildType>BUILD_SCRUB_FIVEOUT2</BuildType>
<FeatureType>NO_FEATURE</FeatureType>
<Production>20</Production>
<Remove>true</Remove>
</Row>
<Row>
<BuildType>BUILD_SCRUB_FIVEOUT3</BuildType>
<FeatureType>NO_FEATURE</FeatureType>
<Production>20</Production>
<Remove>true</Remove>
</Row>
<Row>
<BuildType>BUILD_SCRUB_FIVEOUT4</BuildType>
<FeatureType>NO_FEATURE</FeatureType>
<Production>20</Production>
<Remove>true</Remove>
</Row>
</BuildFeatures>


Somehow I think that I'll have to use a lua function to get the nearest city to get production. Problem is, I don't know which one, as the documentation on the Civ5 Modiki is a little sparse. Here's one I tried- it worked, but I only tested it on one city. When tested on one city, it worked, but only worked for one tile - if I tried to harvest 2 in the same turn, it would only recognise 1:

city was plot:getworkingcity()

Spoiler :
plot:SetImprovementType(-1);
plot:SetResourceType(GameInfoTypes.RESOURCE_L1, -1);
print ("Step1")
print (city)
city:SetFeatureProduction(20);
print (city:SetFeatureProduction(20))
iChange = iChange + 1;



I then went on a 4 hour coding and lua learning spree, which didn't work- my code kept failing to run whenever a harvester was placed. Here's the error message (this was before I added the comments to keep track of what does what):
Spoiler :
Qn4XX8Z.png




Attached is my current code, including the failed lua but not the failed xml edits
 

Attachments

I still can't figure it out. It seems that grid isn't an acceptable variable, despite me having defined it at the top, and then ensuring enough rows exist for new entries. I am completely lost!
 
I haven't looked at your code, but I'm guessing from this:
Code:
attempt to index field '?' (a nil value)
that you are attempting to index a table with nil (rather than an allowed key) or an object with nil (rather than an existing method for that object). It's the same error you would see if you typed:
Code:
Players[0]:MyMadeUpMethodThatDoesntExist()
You can verify that by typing this in Fire Tuner:
Code:
print(Players[0]:MyMadeUpMethodThatDoesntExist) --No () after function!
The above would print "nil", of course. If MyMadeUpMethodThatDoesntExist really did exist and was a method for player objects, the print would print something like: "Function: C43DF1E".

If it were the object missing:
Code:
nonExistantObject:GetID()
...then you would see a differnt error, something like "attempt to index a nil value". It's sometimes fastest to simply believe the error statement when trying to find your mistake. However, sometimes I still refuse to believe the error statement and in those cases I use Fire Tuner to print what I think is not nil but the error statement is telling me is nil. (You can print anything, a table, a function, whatever.) The error statement is always right.


Another tip: If you don't want to spend hours and hours on troubleshooting, then download SQLite Manager or any one of a dozen other applications that will allow you to look at the DB contents directly. Then you can know immediately whether or not your XML table alterations are happening as you intended.
 
Every instance where I try and use grid, (which is a variable I defined correctly at the top of the file) it errors
 
Code:
grid[thing][1]:SetFeatureProduction(...);

grid[thing][1] is an int, not a plot object
 
It doesn't like lines 31 and 54
line 31-33

Spoiler :
grid[iThing + 1][0] = 0;
grid[iThing + 1][1] = 0;
-- next entry is made so nil values aren't encountered


line 54
Spoiler :
if grid[iThing][0] == 0 then return false end;
-- if the cityname field is == 0 then that indicates that the last entry is the previous entry, or, if this is the first, then there are no entries


It says I am attempting to field '?', a nil value. It's not nil! Grid isn't nil. I've defined it right at the top! Then I'm adding new rows as I go, so non existant rows are never encountered! Also I set the new rows values as zero, so empty rows are never encountered. WTH is wrong?
 
I haven't looked at your code, but if you're using a table constructor ( e.g., i = { 10, 20, 30 } ), for some odd reason Lua starts its indexes at 1 rather than 0 (i.e., i[1]=10, i[2]=20, i[3]=30, but i[0] = nil.
 
Huh, I'll give it a go- I was using zeros, but I was giving each row of the table (table has 2 columns) a number, starting from zero. I'll give it a go but I don't think that's the problem, as when I used that method of making tables in a normal lua script (not civ) it worked fine. Will update in a bit.
 
I think I have a rough idea of what's going on. Playing with a lua script outside of civ, it seemed to be that it doesn't like you creating new rows on the fly, so I think I'm gonna have to create a big table at the point of initialisation with all the cities currently in existance, with two columns, and then add to that list, even if the city has no fiveout being harvested. This seems like it would massively increase in between turn times (by massively, I mean a few seconds or so- something I really do not want for my mod).
 
Back
Top Bottom