adapt a script

In this attempt it didn't crash, but it gave me these errors
Traceback (most recent call last):
File "BugGameUtils", line 340, in callHandler
TypeError: doHolyCity() takes exactly 1 argument (0 given)
the error may depend on the fact that it is now just (arglist) while the original is (self, arglist)?
 

Attachments

  • Screenshot 2024-06-26 185654.png
    Screenshot 2024-06-26 185654.png
    957.1 KB · Views: 32
  • Screenshot 2024-06-26 191702.png
    Screenshot 2024-06-26 191702.png
    48.3 KB · Views: 28
  • Screenshot 2024-06-26 192044.png
    Screenshot 2024-06-26 192044.png
    68.9 KB · Views: 38
Last edited:
Ah, good that there is an error message now. (The error messages that appear on the screen also get written to PythonErr.log -- not to PythonErr2.log, that one is pretty much never useful --, so in the event of a crash to desktop there may still be something useful in the log.) Yes, we forgot to remove one self argument. Since doHolyCity takes no other arguments, it should just be def doHolyCity(): I think. So doHolyCityTech(argsList) should be fine, doHolyCity is the one that causes the error.
 
I took a test, this is what happens when I discover a religion
Traceback (most recent call last):
File "BugGameUtils", line 342, in callHandler
File "LimitedReligionsHandlers", line 129, in cannotTrain
File "LimitedReligions", line 355, in getReligionMissionary
AttributeError: 'NoneType' object has no attribute 'getPrereqReligion'
 

Attachments

  • Screenshot 2024-06-26 210308.png
    Screenshot 2024-06-26 210308.png
    822 KB · Views: 26
Looks like the mod assumes that every civ has access to every unit class; very much not the case in Realism Invictus.
Adding ...
Code:
			if pCivilization.getCivilizationUnits(iUnitClass) < 0:
				continue
(indented) under if gc.getUnitClassInfo(iUnitClass).getMaxPlayerInstances() > 0: should fix that.
Spoiler :
So that it says:
Code:
	for iUnitClass in range(gc.getNumUnitClassInfos()):
		if gc.getUnitClassInfo(iUnitClass).getMaxPlayerInstances() > 0:
			if pCivilization.getCivilizationUnits(iUnitClass) < 0:
				continue
		#if gc.getBuildingClassInfo(iUnitClass).getMaxPlayerInstances() > 0:
			kUnit = gc.getUnitInfo(pCivilization.getCivilizationUnits(iUnitClass))
			if kUnit.getPrereqReligion() == iReligion:
So this is probably a compatibility issue with LimitedReligions and Realism Invictus specifically, not with the BUG framework. The function getReligionMissionary is supposed to return the ID of the missionary unit for a given religion. Hopefully, there is still exactly one missionary per religion in Realism Invictus, otherwise, this task isn't really well-defined. (The error message basically says that kUnit was None, which probably happened because pCivilization.getCivilizationUnits(iUnitClass) didn't return a valid unit ID for the given unit class ID.)
 
I thought about it too, do you think it's possible to eliminate the whole part that refers to the missionaries? otherwise in my personal mod mod, I will insert a missionary for each religion, and then make that type of missionary unbuildable, so as to avoid that problem,
 
Last edited:
Now i have this error.:
Traceback (most recent call last):
File "BugConfig", line 110, in unknown_endtag
File "BugConfig", line 334, in endChild
File "BugConfig", line 337, in end
File "BugConfig", line 318, in process
File "BugConfig", line 525, in handle
File "BugUtil", line 642, in getFunction
File "BugUtil", line 629, in lookupFunction
File "BugUtil", line 621, in lookupModule
File "<string>", line 52, in load_module
File "LimitedReligionsHandlers", line 8, in ?
File "<string>", line 35, in load_module
File "<string>", line 13, in _get_code
IndentationError: unindent does not match any outer indentation level (LimitedReligions, line 356)
 

Attachments

  • Screenshot 2024-06-27 154230.png
    Screenshot 2024-06-27 154230.png
    38.2 KB · Views: 18
The kUnit= line should be at the same level as the if pCivilization. The intended structure is:
Spoiler :
Code:
for iUnitClass in range(gc.getNumUnitClassInfos()):
{
	if gc.getUnitClassInfo(iUnitClass).getMaxPlayerInstances() > 0:
	{
		if pCivilization.getCivilizationUnits(iUnitClass) < 0:
		{
			continue
		}
		kUnit = gc.getUnitInfo(pCivilization.getCivilizationUnits(iUnitClass))
		if kUnit.getPrereqReligion() == iReligion:
		{
			...
(But Python doesn't allow curly braces to convey that; has to be done through careful indentation.)
There's the OC_TRAIN_ONLY_STATE_RELIGION_MISSIONARY XML setting for disabling the missionary part of the mod. If you do want to block missionaries to the extent that they exist, you could add return None to the end of getReligionMissionary. (With a single tab for indentation.) Currently, it'll probably crash (Python error, not a crash to the desktop) when it doesn't find any missionary unit for a given religion. And cannotTrain will need code for ignoring the None case:
Code:
if LimitedReligions.getReligionMissionary(iOwner, iReligionLoop) is None:
	continue
After if iReligionLoop != iStateReligion: and indented one tab farther than that line.
 
so do you think it could work?
nb:

missionaries are not a problem since they exist for all religions
 

Attachments

  • Screenshot 2024-06-27 173509.png
    Screenshot 2024-06-27 173509.png
    27.8 KB · Views: 27
The #if... doesn't matter because the line is commented out, i.e. ignored by the Python interpreter. But the next line needs another tab. After a line that ends with a colon (and isn't commented out), the next line (that isn't a comment) always needs to be indented one level more. The "continue" seems to be indented with one more tab than necessary, but that shouldn't be a problem.
 
it crashed, maybe I did something wrong :(
 

Attachments

  • Screenshot 2024-06-27 202416.png
    Screenshot 2024-06-27 202416.png
    29.6 KB · Views: 8
now no errors, and it hasn't crashed, but strange because on the first try it crashed, then I tried again and everything is ok, but now I have to check what happens as soon as I discover the second religion ;)
 

Attachments

  • Screenshot 2024-06-27 205312.png
    Screenshot 2024-06-27 205312.png
    30 KB · Views: 18
/Edit: Hadn't seen that it crashes only sometimes. I guess, in that case, let's see what else happens .../

No, looks correct. Maybe this change ...
If you do want to block missionaries to the extent that they exist, you could add return None to the end of getReligionMissionary. (With a single tab for indentation.) Currently, it'll probably crash (Python error, not a crash to the desktop) when it doesn't find any missionary unit for a given religion. And cannotTrain will need code for ignoring the None case:
Code:
if LimitedReligions.getReligionMissionary(iOwner, iReligionLoop) is None:
	continue
After if iReligionLoop != iStateReligion: and indented one tab farther than that line.
... should be made even if Realism Invictus appears to have a Missionary for each religion. And perhaps some print statements too in the code mentioned above, so that we get some output (in PythonDbg.log) even when the mod causes a crash in the DLL:
Code:
print "no missionary found"
return None
Code:
print "calling getReligionMissionary"
if LimitedReligions.getReligionMissionary(iOwner, iReligionLoop) is None:
	continue
print "missionary found"
These print statements are only temporary, for debugging purposes. If these don't produce any output, then perhaps one print statement (can be just print the line number of something like that) after every conditional (if) in getReligionMissionary.
 
i have error
raceback (most recent call last):
File "BugConfig", line 110, in unknown_endtag
File "BugConfig", line 334, in endChild
File "BugConfig", line 337, in end
File "BugConfig", line 318, in process
File "BugConfig", line 525, in handle
File "BugUtil", line 642, in getFunction
File "BugUtil", line 629, in lookupFunction
File "BugUtil", line 621, in lookupModule
File "<string>", line 35, in load_module
File "<string>", line 13, in _get_code
IndentationError: unindent does not match any outer indentation level (LimitedReligionsHandlers, line 131)
 

Attachments

  • Screenshot 2024-06-27 214036.png
    Screenshot 2024-06-27 214036.png
    741 KB · Views: 26
Don't know if that's line 131, but the second print seems to have a space in front of it; it's not straight under the first print.
 
I corrected, but now other error
Traceback (most recent call last):
File "BugConfig", line 110, in unknown_endtag
File "BugConfig", line 334, in endChild
File "BugConfig", line 337, in end
File "BugConfig", line 318, in process
File "BugConfig", line 525, in handle
File "BugUtil", line 642, in getFunction
File "BugUtil", line 629, in lookupFunction
File "BugUtil", line 621, in lookupModule
File "<string>", line 35, in load_module
File "<string>", line 13, in _get_code
File "LimitedReligionsHandlers", line 133

MyNonStateRelMissionary = str(LimitedReligions.getReligionMissionary(iOwner, iReligionLoop))

^

SyntaxError: invalid syntax
 

Attachments

  • Screenshot 2024-06-27 215659.png
    Screenshot 2024-06-27 215659.png
    39.5 KB · Views: 14
  • Screenshot 2024-06-27 215911.png
    Screenshot 2024-06-27 215911.png
    1.6 MB · Views: 1,976
Probably because it's indented farther than the preceding line. Indentation should increase only after a colon. Also the next line, "if eUnit...".
 
i not understand sorry
maybe in this mode or second
 

Attachments

  • Screenshot 2024-06-27 221713.png
    Screenshot 2024-06-27 221713.png
    34.3 KB · Views: 25
  • Screenshot 2024-06-27 221959.png
    Screenshot 2024-06-27 221959.png
    34 KB · Views: 8
Attaching a screenshot with what little Italian I can manage (since you can't easily copy it into a translator). I think you ought to get a bit of a handle on Python indentation. Some of the mod components use spaces or double tabs, but this one and all the original Civ code just does one tab at the start of every block of code (i.e. after each line ending in a colon). And then the indentation stays there, meaning that the block continues, or it goes back one or multiple tabs, meaning that one or multiple blocks end.

Edit: And the "return False" is also OK, same block as the initial "if". (And all the other blocks end there.)

If you want to upload your current version of that file, I can of course also edit it and put the tabs where I think they belong.
 

Attachments

  • indentation.jpg
    indentation.jpg
    155.1 KB · Views: 19
Last edited:
Sorry. because I don't know if 1 tab is 4 spaces or 8 spaces. i used 1 tab 8 space i hope it is good ;)
I'm certainly wrong in understanding, but from the graph you put, it seems that for 1 tab you mean both 4 and 8 spaces

excellent Italian :). thx
 

Attachments

  • Screenshot 2024-06-27 230646.png
    Screenshot 2024-06-27 230646.png
    31.9 KB · Views: 23
Last edited:
Back
Top Bottom