Python (civ4 scripting language) tutorial thread

I found this post on mail.python.org - it may have been seen before:
Mustafa Thamer <SNIP THIS ADDRESS>
Wed Mar 2 01:54:57 CET 2005

Games

Civilization IV

"The fourth game in the PC strategy series that has sold over five million
copies, Sid Meier's Civilization IV is a bold step forward for the
franchise, with spectacular new 3D graphics and all-new single and
multiplayer content. Civilization IV will also set a new standard for
user-modification, allowing gamers to create their own add-ons using Python
and XML.

Sid Meier's Civilization IV will be released for PC in late 2005. For more
information please visit www.firaxis.com or write <SNIP THIS ADDRESS>"

Boost.Python is used as the interface layer between the C++ game code and
Python. Python is used for many purposes in the game, including map
generation, interface screens, game events, tools, tutorials, etc. Most
high-level game operations have been exposed to Python in order to give
modders the power they need to customize the game.

-Mustafa Thamer

Civ4 Lead Programmer
source

but what is of real interest is this - the Boost.Python doc page

Also, in news...
My completely resdesigned web page has been uploaded! go to sthurlow.com to see it in its full beauty! Obviously there is the new look, but the main page also makes provisions for more things to be added.

If possible, post a link to sthurlow.com on your home page, other forum, etc. This way people (and google) can find it easily, allowing this resource to be used.
 
By the way, Gingerbread Man, thanks for offering this chance to learn about Python already. Will take part as soon as my time allows. Good job!
 
Thanks for the news bit, just a tiny amount of new info.
BTW, the site looks great, and very organized. :)
 
I just saw this thread. Impressive work, Gingerbread Man :goodjob:

Nice of you to take the time to write a tutorial like this!
 
Thanks for the feedback!

If anybody wants to learn something more, I can write a lesson/series of lessons that will lead you there. Just ask.
 
Just found this thread - it happened to be at the top of the Civ4 forum -(maybe should be sticky?) - I will check out your website - are the lessons there more correct than the ones posted here; i.e. improved?

I read through the first 4 or five lessons - I will try and catch up as I am able. No formal programming training - I am more of an operating system engineer - some basic Visual and DOS scripting; I do occasionally struggle through and write basic AD scripts for Windows 2000 servers; also use Windows SMS scripting tool. But that is not really programming ;).

Thanks for all your hard work! :)
 
Gingerbread Man said:
Thanks for the feedback!

Its well deserved :)

If anybody wants to learn something more, I can write a lesson/series of lessons that will lead you there. Just ask.

I work as a Java and .NET developer and am not a stranger to python. I'm just vey impressed that you took the time to write something like this. I'd never bother doing it. I think this thread should be accessible on from the first page, either as a sticky or linked to in a 'notice board' (like the one in OT).
 
I haven't read the thread yet (propably won't...) I'm just installing Linux on my own computer and would like to know of any problems with making Python work with it?

I know how to code basic, & I can "read" HTML & XML's. I've also done a few mods to Locomotion so I know how xml works.

ie Joining in to be the first one to make a WWII Mod for cIV ;)

EDIT: UU! Uu! 1st part done, now working the 2nd.
EDIT2: 2nd part done too, those were for novices, clearly :p Perhaps parts 4&5 will bring something new? Oh well, 3rd's up now.
EDIT3: Lesson 3 done too. The only difference to BASIC is that stuff that has text doesn't need to have the $ in the end.
 
oldStatesman & Cilpot - the thread is linked to in the (lengthy) prerelease information thread. I doubt it will ever be stickied, but if somebody wants it so, I can create a new thread with all the up to date lessons on it, plus extras.

The tutorial isn't currently active, unless somebody would like to learn something about python. When I get enough time, I'll do a few python/xml tutorials.

Paasky - well done for venturing into linux! Persevere through the learning curve. Once I got the hang of it, I never booted windows again.

As for specifics with python? depends which distro you are using:
With debian distros (e.g. Ubuntu) you need to install the specific package for IDLE. The latest (at time of posting) is 'idle-python2.4'. I've had problems with IDLE periodically crashing here, so try version 2.3 if you have a similar issue

With Gentoo (if you are patient enough to sit through compiles) make sure you have 'tcltk' in the CFLAGS section and then 'emerge python'. Gentoo is heavily based on python (portage is written in python)

I'm not too in to RPM-based distros, but preferably use their package managers.

If you have to compile from their source tar.gz files, there are a few things you might have to do before compile. I haven't done that in a while, so you might want to check that out if you decide to install from the tar.gz that comes from the python.org website.

Despite what I've said above, it isn't all that difficult with some initial perseverence to get used to the different environment. Good luck!
 
I found that the dist I got (can't remember the name...) has python already. So that shouldn't be a problem unless the newest of the new python has something that we'll be using.

Right now I'm having a bit of a problem (it can't install stuff from the CD) but I'm downloading Suse now and hopefully it will work ;)
Besides, it's a Finnish product :D
 
I'll join! :D

Now where do I get a copy of Civ4? ;)

I am a professional web programmer who has never touched Python and who has little interest in XML (darn, bad combo! :sad:), but learning new languages is a piece of cake so no worries...
 
stormbind said:
I am a professional web programmer who has never touched Python and who has little interest in XML (darn, bad combo! :sad:), but learning new languages is a piece of cake so no worries...
A quick summary:
python == C++ with changes
XML == HTML minus the functionality.

I am currently using python to generate HTML pages from an XML source. If you people want it, I'll write a lesson on what I'm doing, but I cannot guarantee that civIV will use the same type of concept for dealing with XML.
 
Hopefully the publisher will make available a Civ4 Developer Network with a library of all custom objects and attributes.

How about a fully fledged http://dn.civfanatics.com for Python and Civ -stuff?
 
stormbind said:
Hopefully the publisher will make available a Civ4 Developer Network with a library of all custom objects and attributes.

How about a fully fledged http://dn.civfanatics.com for Python and Civ -stuff?
http://pc.ign.com/articles/614/614551p3.html

IGNPC: The core game's great but Civilization's also done well thanks to massive community support. What types of tools and editors can players expect out of the box?

Barry Caudill: Civilization 4 will be the most moddable version of Civilization ever. Players can edit basic stats and attributes in XML files. On a higher level, much of the game will be exposed to Python so modders will be able to edit events and have more control over how the game works. On an even higher level, we are planning to provide an AI SDK to allow experienced programmers to dig very deep into customization.


Wishes indeed do come true sometimes.... :D
 
Hey I just found this thread as well. I am a SQL Server 2000 Database Architect with 4 years TSQL, 6 years Visual FoxPro, 2 years Visual Basic, 1 year C# and HTML professional programming experience - not to mention some minor graphic editing skills and over 6 years of modding Civ2, 3, and SMAC.

I have never used Python, and am only roughly familiar with XML, but now that I know the direction of the new game I will be brushing up on these languages. If anyone wants to get some ideas flowing now of mods they would like to see, we can start planning them out, but there is little we could do before the game is released....
 
I want to join. I have done all the way up to lesson 6 and Have made a few programs of my own already
 
Nice job Gingerbread Man :)

I don't have the time to follow with the lessons but I am going to lurk and offer any help I am able for questions that arise.

I studied fortran in college, taught myself c/++ but gave up on learning windows programming. know the basics of java and javascript, pretty familiar with assembly, and have dabled with XML.

Civ2 was what inspired me to learn c/c++. I thought I could make it a better game. It looks like with Civ4 those so inclined will have the chance :) I got as far as making a main interface and figuring out how to make scrolling terrain out of tiles. All in dos since as I said windows programming left me confused :)
 
Gingerbread Man said:
LESSON 7
The 'for' loop, and some programs of your own

Now I said you would write some programs now. Here is your chance! Your task, if you chose to accept it, is to post a better text adventure game. When you are finished, post them here (in a .txt file - the forums don't let you post python files). You can use any of the code I have given you here. Remember to check back on previous lessons we have done - they are priceless tools.
Hey. This is your text game you made in lesson 7 but I just made it more complex. I tried as you see at the end of the txt that I tried to Make sub-loops. or what programmers call branching. I tried to have 2 loops
if i find the key i go to loop two
if i drop it :D:D i go back to 1. but for some reason it will not go back to one instead it sopts the loop. any suggestions?
 

Attachments

  • Text game.txt
    2.8 KB · Views: 160
Top Bottom