How do I overwrite the default "CivBEColonists" & etc XMLs?

OranHarken

Warlord
Joined
Oct 26, 2014
Messages
130
I am trying to implement new citizen types that do more than just modify yields.

I have made a copy of the original files in which I have added IntrigueCapChange as one of the possible columns to the table and a sql file to add a citizen type to that grants this. It is also my intent to add Modifiers city health and strength colonists using the same method.

However I am unable to make it show up in the game. All of my various attempts at blocking or overwriting the default XMLs have failed. Both in removing the Fusion Reactor option so it could be replaced with something better and in this.

Is what I am trying to do even possible. From a coding stand point I do not seem to have done anything wrong and have mimic'd the game's formats perfectly as far as I can tell.

As far as I can tell it is entirely my inability to block the original XMLs from taking president over my new ones.

What am I doing wrong?

Included is a copy of the mod so far.
 

Attachments

You give a file the exact same name and set it to VFS=true (import="1" in the .modinfo) if you want to simply replace the original. However, that's a bad idea for mod interaction. You want to just address the changes you're making.

In this case you can use this SQL:
Code:
ALTER TABLE Colonists ADD COLUMN IntrigueCapChange INTEGER DEFAULT 0;

However [most importantly], I'm not sure what you think that's going to do. You need code to actually make the game understand what to do with that. EDIT: In other words, you'd need to use Lua (or C++ once the DLL is released).
 
This is a newer version.

Additionally I notice there is a section for "blocks" in the MODINFO file but I am unsure if it does what I am looking for and I have no way to test it because I do not know the format of commands to use there. I cannot find a single other mod out yet that uses this command so I have zero reference.

Edit: Disregard this. I did not notice your reply.
 

Attachments

You give a file the exact same name and set it to VFS=true (import="1" in the .modinfo) if you want to simply replace the original. However, that's a bad idea for mod interaction. You want to just address the changes you're making.

In this case you can use this SQL:
Code:
ALTER TABLE Colonists ADD COLUMN IntrigueCapChange INTEGER DEFAULT 0;

However [most importantly], I'm not sure what you think that's going to do. You need code to actually make the game understand what to do with that.

I just copied it over the relevant bits from the building section. I assumed it would just apply whatever logic is used there to make it do it's thing to colonists instead. However if that is not the case I guess it is beyond my ability to implement this feature.

As for mod interaction I guess that is a good point. The problem is though that I hate superfluous options clogging the screen up when the intended replacements are in the same section.
 
No, that's not the case.

More edification:
Blocks prevent your mod from being activated if another mod is already active. It's much easier to use ModBuddy, but it would look something like this:
Code:
  <Blocks>
    <Mod id="b97b7d68-9b58-4245-b32c-9d499d80cd27" minversion="0" maxversion="999" title="Name of the mod" />
  </Blocks>

The syntax is the same for References and Dependencies. Dependencies are the opposite of blocks; they require the other mod to be active before yours can be activated. References simply tell the modding subsystem to load the other mod before yours.
 
*Sigh* I can't even find a lua that refers to defining what colonists can do...

This game has to have one of the worst codes I have ever seen. I have been churning out mod's for StarSector (everything from new ships, locations, weapons, particle effects and sound effects) and I have never had any problems getting the game to recognise new definitions. It however was designed to be modder friendly, not to shill DLC so what should I have expected...

Not to sound like a completely negative person but at this point I feel more like giving up on beyond earth than continuing. Between this and my difficulty working with dds.
 
It's harder than modding some games, but easier than others. Quite a lot is done in C++ rather than Lua, so the possibilities aren't endless without DLL modding, but you can make some rather powerful changes if you know Lua. It looks like Firaxis recently added some new Lua hooks that should make a few tasks easier to accomplish (and backported them to Civ5).

You need to create an invisible building (Cost=-1) with your change to IntrigueCapChange. You also need to create a BuildingClass (with MaxPlayerInstances set to 1, for good measure).

The problem is how to give this building to the player when your collectivist colonist is chosen. Unfortunately, there's no built-in method for just this situation, but Lua comes to the rescue. Note I'm not a Lua expert, so it took me a while to figure out just this short bit of code:
Code:
Events.SerialEventCityCreated.Add(function(hexPos, playerID, cityID, cultureType, eraType, continent, populationSize, size, fowState)
	local currentColonists = PreGame.GetLoadoutColonist(playerID);
	if ( cityID == (Players[playerID]:GetCapitalCity()):GetID() ) then
		if ( currentColonists == GameInfoTypes["COLONIST_ESO_COLLECTIVISTS"] ) then
			Players[playerID]:GetCityByID(cityID):SetNumRealBuilding(GameInfoTypes["BUILDING_ESO_COLLECTIVISTS"], 1);
		end
	end
end);

Find my test mod attached. Note you're going to need an icon for your colonists (at the moment it comes up with the red-checked error texture).
 

Attachments

Are you sure that Cost=-1 makes the building invisible in BE? I believe JFD used that method for v.1 of his Space Pope mod and it still showed in the city screen.
 
Setting Cost to -1 never made a building invisible; it just prevented that building from being constructed. In BNW, setting GreatWorkCount to -1 set that building to being invisible, because of the logic used in the CityView.lua which skipped those buildings from showing up. The same such method cannot be found in BE, unfortunately; though one could be made.
 
Looking for some help here as I'm trying to do more or less the same thing......grant a building as a result of selecting a certain colonist. (This is my first time venturing outside of XML-only modding)

Colonist LUA (from Nutty's above example; I just sub'd my colonist name and building name)
Spoiler :
Code:
Events.SerialEventCityCreated.Add(function(hexPos, playerID, cityID, cultureType, eraType, continent, populationSize, size, fowState)
	local currentColonists = PreGame.GetLoadoutColonist(playerID);
	if ( cityID == (Players[playerID]:GetCapitalCity()):GetID() ) then
		if ( currentColonists == GameInfoTypes["COLONIST_MIB_AGENT"] ) then
			Players[playerID]:GetCityByID(cityID):SetNumRealBuilding(GameInfoTypes["BUILDING_MIB_AGENT"], 1);
		end
	end
end);

Colonist SQL (also from Nutty's above example, but I changed "INTEGER DEFAULT 0" TO "TEXT DEFAULT NULL" pretty sure that was incorrect :confused:)
Spoiler :
Code:
ALTER TABLE Colonists	ADD COLUMN GrantBuilding     TEXT DEFAULT NULL;

Colonist XML
Spoiler :
Code:
<GameData>
	<Colonists>
		<Row>
			<Type>COLONIST_MIB_AGENT</Type>
			<Description>TXT_KEY_COLONIST_MIB_AGENT</Description>
			<ShortDescription>TXT_KEY_COLONIST_MIB_AGENT_SHORT</ShortDescription>
			<PortraitIndex>0</PortraitIndex>
			<IconAtlas>LOADOUT_MIB_AGENT_ATLAS</IconAtlas>
			<GrantBuilding>BUILDING_MIB_AGENT</GrantBuilding>
		</Row>
	</Colonists>
</GameData>

1. As I kind of expected, the game didn't like <GrantBuilding> in the Colonist table of the XML, and it showed in the Logs

2. I'm not sure I even need the SQL and <GrantBuilding> in the XML table, if I have the LUA code above??

3. In the Content section of the Mod's properties, I added AgentColonists.lua as "Custom" with VFS False

4. For the AgentColonists.sql, in the Actions section , I added the file to OnModActivated - UpdateDatabase with VFS also False.


As I said before, sql and lua are completely foreign to me, but I thought this thread might be close enough to what I was trying to achieve that I could CopyPasteReplace it and it might work......not so (so far)

Anyone got any pointers on the above code or how I set things up in the properties that might be causing problems?
 
Again, I just showed the ALTER TABLE syntax for edification. I was answering his literal request. Frankly, ignore that I even put it up there. It won't DO anything, unless you're going to code support for it yourself (in which case it's not even necessary, merely one way to make your work more modular). The game would have happily accepted the XML if the SQL had been loaded BEFORE the XML [i.e., the order it appears in the Actions tab, top to bottom], but since there's no point in including the SQL... don't worry about it.

You're very close. For the Lua file, you want InGameUIAddin, not Custom.
 
Again, I just showed the ALTER TABLE syntax for edification. I was answering his literal request. Frankly, ignore that I even put it up there. It won't DO anything, unless you're going to code support for it yourself (in which case it's not even necessary, merely one way to make your work more modular). The game would have happily accepted the XML if the SQL had been loaded BEFORE the XML [i.e., the order it appears in the Actions tab, top to bottom], but since there's no point in including the SQL... don't worry about it.

You're very close. For the Lua file, you want InGameUIAddin, not Custom.

I was figuring that the LUA would be the only thing necessary, but after trying InGameUIAddin, it's still not working......I checked the lua logs and there's not even a mention of my LUA file, so I'm thinking its just not even being loaded properly

Of note: When I add my LUA file in the content section, I must select the file dropdown first to choose my LUA file then select InGameUIAddin and.......if I start by choosing InGameUIAddin, the drop down for file only lists my XML files, and I am unable to choose the LUA file. Is that normal?

EDIT: Scratch that, it actually did work! I kept running Bosparan's "Mod Test Helper" mod, and it doesn't work with that mod also enabled...I guess this lua file is incompatible with his "Demolish Buildings.lua"......

I don't know if I can post his LUA code here, so I won't, but do you know what would make another LUA file incompatible with this one? If so, is there an easy way to make them compatible or is that impossible?

Thanks for your help Nutty!
 
You're not going to have a mention in the lua.log unless you put in something like:
Code:
print("Hello, world!")

Yup, the odd behavior in ModBuddy's content tab is normal. Good job discovered the workaround. I was typing it in by hand for a long time before I saw that mentioned in the forum.

If you attach a copy of the built mod (either the .civ5mod from the solution's Packages folder, or just zip up the copy in your mods folder), then someone can easily troubleshoot it.
 
Didn't realize you already replied, but I did add some "edit" remarks to the previous post, it did work but I found that it was incompatible with Bosparan's Mod Test Helper mod, and was wondering if that could be helped

EDIT Again: actually its not incompatible, but it doesn't load when you first start up the game, I have to back out to the main menu and then start another game before it loads
 
Thanks to this thread, I was able to correct the LUA coding to allow it to be loaded without having to start the game, then back out to the main menu, and re-start a new game. Code changed as follows:

it went from:
Code:
Events.SerialEventCityCreated.Add(function(hexPos, playerID, cityID, cultureType, eraType, continent, populationSize, size, fowState)
	local currentColonists = PreGame.GetLoadoutColonist(playerID);
	if ( cityID == (Players[playerID]:GetCapitalCity()):GetID() ) then
		if ( currentColonists == [B][U][I]GameInfoTypes[/I][/U][/B]["COLONIST_MIB_AGENT"] ) then
			Players[playerID]:GetCityByID(cityID):SetNumRealBuilding([B][U][I]GameInfoTypes[/I][/U][/B]["BUILDING_MIB_AGENT"], 1);
		end
	end
end);

To this (and it works the first time you start the game now)

Code:
Events.SerialEventCityCreated.Add(function(hexPos, playerID, cityID, cultureType, eraType, continent, populationSize, size, fowState)
	local currentColonists = PreGame.GetLoadoutColonist(playerID);
	if ( cityID == (Players[playerID]:GetCapitalCity()):GetID() ) then
		if ( currentColonists == [U][B][I]GameInfo.Colonists[/I][/B][/U]["COLONIST_MIB_AGENT"][B][U][I].ID[/I][/U][/B] ) then
			Players[playerID]:GetCityByID(cityID):SetNumRealBuilding([B][U][I]GameInfo.Buildings[/I][/U][/B]["BUILDING_MIB_AGENT"][B][I][U].ID[/U][/I][/B], 1);
		end
	end
end);
 
Back
Top Bottom