Creating custom Action Control buttons for the FireTuner

skodkim

Deity
Joined
Jan 16, 2004
Messages
2,497
Location
Denmark
Hi

First of all let me say that I have no experience yet with lua/scripting.

When using the FireTuner I discovered that iut could be used to change some terrain (or features) ingame. Theres an "Action Control" button that can be used to place Forests on the Map panel (and maybe one more - haven't got access to it right now). You can also create your own Action Control buttons that uses a script to do similar things.

The problem is that I can't figure out how to do other things, e.g. create hills, jungles etc.

So far I copied the "Place Forest" button and played around with the script a bit but all I was able to trigger was the placement of Forests (which was already there) and Fallout (which is hardly interesting to place near one of your cities).

Have been looking around for a description of how to mod Action Control buttons but haven't seen anything yet. Anyone got any ideas?

\Skodkim
 
I am trying to do the same thing....

I found the Fire Tuner and its customable panels pretty cool. I am a programmer and scripter, but my experience is limited to NWScript, and the tools for Fallout 3 and Oblivion. I am just starting to explore the Civ 5 infrastructure and tools. I am fresh off the boat so be warned. :) Here is what we're up against....

If you right click on the Add Forest button and select edit, you can view the code for this Action Button ...

PHP:
UI.SetInterfaceMode(InterfaceModeTypes.INTERFACEMODE_DEBUG);
-- ID1 : 4 is Feature
UI.SetInterfaceModeDebugItemID1(4);
-- ID2 : 5 is Forest
UI.SetInterfaceModeDebugItemID2(5);

There are 3 functions used here ...

UI.SetInterfaceMode
UI.SetInterfaceModeDebugItemID1
UI.SetInterfaceModeDebugItemID2

The problem is that there is really no documentation on exactly what these functions do, what the valid call parameters of the functions are, nor what they return if anything.

That said, we can surmize the following .....

UI.SetInterfaceMode(InterfaceModeTypes.INTERFACEMODE_DEBUG)

This probably sets the system to a mode where if I click on a tile or object I can change that tile or object?? You will find this function is the first function called in any action button on the Fire Tuner map pannel ... like Remove Forrest, Add Road, or whatever.

-- ID1 : 4 is Feature

Any line that starts with -- is a comment and not code that exectutes. This comment tells us the number 4 is a feature. It is used as a parameter in the next line. We need to find the valid numbers for Terrain and Plot Type...

UI.SetInterfaceModeDebugItemID1(4);

This function sets a value that defines what type of object I am changing when I click on a location on the map. There can be a number things on the map in the same location. A map tile has a number of things in there that could be changed. One of the problems I am having is I can't find where the numeric values for these object types are defined.

We know from this code that 4 = Feature
We know from the code in the Add Road action button that 3 = Route

I do not know the value for Terrain or Plot Type ... two things we need to adjust the terrain of a tile.

I think it is probably somewhere in the Table Browser Panel. I found much of what we need there. For example to know all the possible values for features, look under Game Core, Feature Types in the Table Browser. You can also find the values for Terrain Types, Plot Types, etc.... here. That said, though I can see the values for each of the object types, what value to use in the UI.SetInterfaceModeDebugItemID1 function still eludes me... :(

UI.SetInterfaceModeDebugItemID2(5)

This function is the one that changes the tile item type you defined in the preceeding function. So since we are changing a feature (object type 4) using the number 5 as a parameter of this function will change the FEATURE to FORREST. If we used the number 1 here, the tile FEATURE would change to JUNGLE ... again those numbers can be found in the table browser under Game Core, Feature Types.

But again, I can't find the valid parameters for the function ... UI.SetInterfaceModeDebugItemID1 so I am not sure how to change terrain or plot type...

I am going to start some trial and error by changing the value used for UI.SetInterfaceModeDebugItemID1
 
Good luck and if you figure it out you get two thumbs way, way up! Just make sure you give us detailed instructions, a How to Change Terrain in Firetuner for Dummies, would be perfect.
 
Action Control button is just a lua script which you execute when you press that button. To see any print commands or errors you have to switch to "Lua Console" tab.

To me your question here is more about how to use the functions you can see in Tuner not about the tool itself. To learn more about functions is the basic detective work we are all doing here. What you can do is:
  • Search the assets-folder in your Civ 5-folder to see how the game is using different functions.
  • Search other peoples mods how they are using functions.
  • Test the function with no paramaters in the Tuners lua console. It can give you an error message what kind of parameters it requires.
  • And of course try your luck on these forums. ;)
As I have understod the Tuner, it's just a lua console with access to all the different threads within the game. All the commands and functions you could create in your mods lua file can also be done in Tuner. And vice-versa! Exception is that in your mod file you can only access your mods own thread. In Tuner you can choose to use any thread (Main State, InGame, etc.). Depending on the thread chosen you only have access to xml-elements and functions within that thread.

Hope this helps you forward. :)

ps. If you wan't to create a mod then you should do it in ModBuddy of course and use Tuner just for testing it.
 
Thanks for the answers!

Cosian: You cracked it.

Just did a little test with features setting UI.SetInterfaceModeDebugItemID1(4) and varying UI.SetInterfaceModeDebugItemID2. It's not a full list but here are the variables I did find:

1: Jungle
2: Marsh
3: Oasis
4: ?
5: Forest
6: ?
7: The Barringer Crater
...

\Skodkim
 
@skodkim, It looks identical to the Features database table, as such:
0 - Ice
1 - Jungle
2 - Marsh
3 - Oasis
4 - Flood Plains
5 - Forest
6 - Fallout
7 - Crater
8 - Fuji
9 - Mesa
10 - Reef
11 - Volcano
12 - Gibraltar
13 - Geyser

The question is, what does ID1 relate to when various integers are applied?
 
@skodkim, It looks identical to the Features database table, as such:


The question is, what does ID1 relate to when various integers are applied?

Christ - where did you find that. Seems I'm outsmarted every time :mischief:

\Skodkim
 
Well, to start, it's in the xml files, which puts it into the database. To view the xml, well, just open it in a text editor. To view the database, check out the modding guide pdf.
 
Well, to start, it's in the xml files, which puts it into the database. To view the xml, well, just open it in a text editor. To view the database, check out the modding guide pdf.

You're right of course. I suppose you're talking about c:\Program Files (x86)\Steam\steamapps\common\sid meier's civilization v\Assets\Gameplay\XML\Terrain\CIV5Features.xml and the order the feature types are given in.

Not going to check now but that's maybe the way you could determine the other types, roads etc.

\Skodkim
 
Sure, once you figure out what the ID1 changes (in this case, 4 was Features), you can go find the table, and use that index. But you still need to figure out what the rest of the numbers do to ID1.
 
As mentioned in my first post, you can find the values for many things right from within Fire Tuner. With a game loaded ... Go to the TABLE BROWSER panel in fire tuner, Scroll Down to GameCore and expand it, Scroll Down to GameInfoTypes and expand it. In this section you can see the index numbers for all the different object types in the game. Scroll down to FEATURES and you will see the index numbers. Scroll down to ROUTES and you will see the two route types ... Road and Railroad with their index numbers.

Again, as JeBus27 points out, the index numbers to be used in the ID2 function are there and known. The problem remains knowing what number to use in the ID1 function.

Also, I am not even sure you can put down terrain using the ID1 and ID2 functions. Those functions clearly work for placing FEATURES and ROUTES and probably other stuff as well...

Continuing to dig....
 
Found a few more of the ID1 values, though not of much value as they tend to mimic the example 'plopper' tools already present on the Map Tuner panel. Still can't find a way to change the actual base tile type from land to water to mountain etc.

Anyone else had any success?

ID1 value meanings

1 = Units
2 = Terrain Improvements/buildings
3 = Terrain Routes (roads and railroads)
4 = Terrain Features

ID2 values

Units
0 = settler
1 = worker
2 = work boat
3 = Great Artist
4 = Great Scientist
etc

Terrain Improvements/buildings
0 = City Ruins
1 = Barbarian Encampment
2 = Ancient Ruins
3 = Farm
4 = Mine
etc

Terrain Features

0 = Ice
1 = Jungle
2 = Marsh
3 = Oasis
4 = Flood Plains
5 = Forest
6 = Fallout
No Feature = -1

From the table browser these are the Terrain type values but I can't find a correspoding ID1 value to enable placing them.

Terrain Types
-1 = No Terrain
0 = Grass
1 = Plains
2 = Desert
3 = Tundra
4 = Snow
5 = Coast
6 = Terrain = 6
7 = Mountain
8 = Hills

Plot Types
-1 = No Plot
0 = Mountain
1 = Hills
2 = Land
3 = Ocean
 
Back
Top Bottom