[Development Thread]CIVILIZATION 4: World of Pokiphlanon

EVERYTHING!!! The problem is that there IS NO SYNTAX!!!
There's plenty of syntax. In fact, there is something a lot like exactly the right amount for it to work - if there wasn't, it wouldn't.
The for loops are like 'For something in something. What the hell does that mean?
It means exactly what it sounds like, more or less. In many languages it would be a "foreach" instead of a "for", if it matters to you. Python for loops can loop over anything that is iterable, but it is typically a list.

When you go through the contents of your pocket looking for something do you create some integer and increment it and such, or do you just do something a lot like "for thing in MyPocket" and examine each thing?

In C++, for loops are nice and simple.

Code:
for (int i = 0; i < GC.getNumUnitInfos(); i++)
{

}
That isn't particularly simple. In fact, the only reason it seems to be simple to you is that you know what it means. You have to know the secret to the magic to get it to work. Specifically you have to know that there are 3 separate things inside the parenthesis of the for loop each of which is an expression of some sort, separated by semicolons, and what each of the 3 is used for (they aren't even the same kind of expression, the middle one is a boolean and the other two aren't). Only simple if you know the magic. If you didn't know, it would make no sense to you.

The equivalent in Python would be
Code:
for i in range(gc.getNumUnitInfos()):
	blah
	blah
	blah
The magic part of that is in knowing what the range function does: when it has one argument, it returns a list of integers with the specified number of elements in it which starts with 0 and increases with an increment of 1 (you can specify more parameters to change these characteristics). So from range(3) you get the list [0,1,2].

or

Code:
CvCity* pCity;
for (pCity = firstCity(); pCity != NULL; pCity = nextCity())
{

}

The equivalent in Python, because of the way the city list is accessed in the Civ4 Python API (assuming you have a variable "player" which is a CyPlayer type object, a detail you left out of your example - presumably you'd intend to use the above loop in a function inside the CvPlayer class since it wouldn't work as-is anywhere else, unless some other object keeps a list of cities like that):
Code:
(loopCity, iter) = player.firstCity(false)
while(loopCity):
	blah
	blah
	blah
	(loopCity, iter) = player.nextCity(iter, false)
Which, technically, isn't even a for loop, it is a while loop. It's the equivalent of the C++ version which goes like so:
Code:
CvCity* pCity;
pCity = firstCity();
while (pCity != NULL)
{
  blah;
  blah;
  blah;
  pCity = nextCity();
}

Also, in python, there's no type specifiers, so you never know what something is! And sometimes you can't tell if you're creating an object or calling a function!
If you don't know what something is, you should have payed more attention to what it was when you made it. It doesn't magically change what it is, it only changes if you change it. But that is why the Civ Python code uses the notation it does, so that you can know what the intended usage is: iPlayer is an integer, pPlayer is not (the "p" was apparently selected to match the C++ code where it uses pointers to the objects, but in the Python it is pretty much the object - although technically, behind the scenes, every variable in Python is a pointer since it does everything by reference, not by value, just in case you wanted to know).

And creating an object is calling a function (possibly more than one), specifically it's constructor and/or initializer (whatever terminology you want to use). That's true in C++ too.

Functions generally return objects of one sort or another, so the difference is pretty small.

What's the difference between calling a function that does calculation X and returns the data in the fields of a MyFoo type object (that it must have either created or received as an argument or from somewhere else) and creating a MyFoo type object who's initialization function does calculation X and sets its fields accordingly?

If you weren't sufficiently confused before, maybe you are now...
 
Just a suggestion: Why not read up on the language if you're gonna use? I mean; it can't hurt, can it?

Or don't. No one is twisting your arm to do Python in the first place. And no one is interested in listening to you whining just because you can't be bothered to look at the documentation. (Hint: Python.org)

And in order not to get another warning for "not being helpful": If you need help grabbling with basic Python I can totally walk you through it, whenever I get the time. (Unfortunately I'm probably as new to game interface modding as you are, so I wouldn't be able to do the actual work for you.) Just calm down a notch - or two - and be patient enough to listen. And learn. (You will be able to return the favor once I get into SDK modding. One of these years...)
 
That's what happened, and I'm working on it now.

If you don't know what something is, you should have payed more attention to what it was when you made it.

Who says I made it?

And creating an object is calling a function (possibly more than one), specifically it's constructor and/or initializer (whatever terminology you want to use). That's true in C++ too.

Yes, but in C++, when you declare an object or pointer, you have to say what it is. Not true in Python.

Just a suggestion: Why not read up on the language if you're gonna use? I mean; it can't hurt, can it?

:mad: :mad: :mad:

I do have a book about Python, and I'm somewhat familiar with the language, I can write basic programs in it. But every time I start reading the book, I get mad because the language is so annoying.
 
Well, I happen to love the language. Looking at C++ code makes me... nauseous. :p

In my humble opinion, you don't know basic Python, why I highly doubt you can write anything in it. But thankfully the language is really easy to learn. In my limited experience, of course. In any case it shouldn't be a problem for you, of all people, since if I remember correctly, you picked up SDK modding in a matter of days, not weeks! :eek: Were you even familiar with C++ before you started posting here? :confused: Personally I thought you were way over your head, starting this very thread and setting out to refashion CivIV from the ground-up. But, it seems that I couldn't have been more wrong! :king:
 
Ummm... I do know basic python. Do you have evidence that I don't?

I guess we all have our favorites. Let's stop arguing and accept each other. I still hate python, you still love it, and we're not going to convince each other.
 
If you don't know how to execute a for-in loop, for example, you clearly don't know how to even make even the simplest thing, in Python. No, we're not gonna convince anybody, and I don't think this is anyone's agenda either. Rather focus on getting the job at hand done. You mostly end up learning something while you crack these things, and thats just a bonus.
 
If you don't know how to execute a for-in loop, for example, you clearly don't know how to even make even the simplest thing, in Python. No, we're not gonna convince anybody, and I don't think this is anyone's agenda either. Rather focus on getting the job at hand done. You mostly end up learning something while you crack these things, and thats just a bonus.

I know how to use a for loop, I just find it confusing and unclear and don't like it
 
Still trying to fix PlayerOptionInfos bug so I can resume modding.
 
With the bug fixed, I can go on to fixing more bugs.
 
Fixed at least 5 bugs in the last 5 minutes.
 
I am going to explode. Gamefont is broken. Again. A F***ING GAIN!


Look:
 
I did. And yeah, it's pretty useful. But this is serious corruption of my files. Anyone know why this happened?
 
The letters and, under careful inspection, some of the other icons, are seriously mutilated.
 
I'd agree about the odd zoom level. At 197.25% you are going to see blending/misaligning of pixels on the screen that isn't in the actual file. Try to use even multiple of 100% when checking things.

Aside from that, you should to keep careful track of what changes you've been making and always keep at least one older version around (Like the one from before that last changes were made). If your change list includes dates (and maybe times) then you will know what time span the problems must have show up in (occasionally I remember, or discover via file modification times, that I have changed something since the last entry in my change log, having forgotten to add it to the log, at which point I often realize that I never tested the change).

Something you might find useful: Setting up a local SVN repository for version control (and then using it, of course - don't forget to commit changes every time you verify that they work) could be helpful for reverting to older versions when something goes wrong, and for tracking what changes you make: see this thread.
 
Got it. 200% zoom.
 
It's hard to be sure but here is my guess:

It looks like the various alpha channel for the parts of the letters that are supposed to be semi-transparent are now messed up and either fully opaque or fully transparent, or at least most of them are (it looks like the Euro symbol and maybe a couple of others have some partially transparent parts). This could happen if the file was saved when the alpha channel was set to be less than 8 bits. A 1-bit value (so every pixel is either fully transparent or fully opaque) would wipe out the partially transparent pixels entirely, probably by converting them to the nearer of the two choices. A 2 or 4 bit alpha channel would probably reduce the number of choices to get what you are seeing. I'm not sure if there is such an option for TGA files, but if you ever saved it as something else such options are certainly available. For example, a DDS file has at least one possible setting, the DXT1 format, with a 1-bit alpha channel and some of them have other amounts (I'm not sure about 2, but there is at least one that uses 4). If you edited the Alpha channel separately then the file it was saved to may not have had enough bits per pixel. Alternatively, actually reducing the number of levels in the alpha channel would have this effect as might adjusting it via contrast enhancement or gamma adjustment or other such things in the editing program, regardless of the file format it is saved to.

You may have noticed that the alpha channel is where all of the information for the letters is stored. The boxes are pure 100% white in the RGB channels - there is nothing in them. So if the alpha channel is messed up in various ways (like too few bits) the letters will tend to be messed up.
 
Back
Top Bottom