Python scripting outside a Mod (how to?)

Trynthlas

King
Joined
Nov 6, 2007
Messages
799
Location
Texas
So, playing with the world builder, I see that you can "Add Script" using the Edit City or Edit Unit tools. This brings up a dialog asking for a script file as input.

So, what sort of code would you place in this file, and what could you do with it?

Experienced coder, python newb (not that it's that hard to figure out), looking for a push in the right direction with how to use scripting to have some fun with things. The catch is I don't want to create a Mod for it, I want to be able to load a script into a running game using the WB, and throw it back at a player who will then get to enjoy the fun of dealing with my tinkering in a dynamic fashion!

So, anyone up for helping me shove off? :)
 
Unfortunately, the "script data" you see in the WorldBuilder is not a Python script. Rather, it is "data that can be used by scripts (Python/C++)". It's merely a text value that can be used for whatever purpose you want.

Of course, with Python being a dynamic language, you could conceivably store Python code in that field and write Python code (in a mod) to read it out and execute it on-the-fly, but that's pretty advanced.

If you want to play around with Python in the game, you can modify CivlizationIV.ini's "Cheat Code" setting to "chipotle" (without the quotes) and then hit tilde (~) in the game to bring up the developer console where you can enter Python code to be executed immediately.

Code:
gc.getPlayer(0).changeGold(1000)

Free money!
 
Top Bottom