Question about getGridsize

jkp1187

Unindicted Co-Conspirator
Joined
Aug 29, 2004
Messages
2,496
Location
Pittsburgh, Pennsylvania
I wanted to play with maps that are the same dimensions as the maps in the Terra.py script. I copied the below code into Big_and_Small.py from Terra.py:

Code:
def getGridSize(argsList):
    "Enlarge the grids! According to Soren, Earth-type maps are usually huge anyway."
    grid_sizes = {
        WorldSizeTypes.WORLDSIZE_DUEL:        (13,8),
        WorldSizeTypes.WORLDSIZE_TINY:        (16,10),
        WorldSizeTypes.WORLDSIZE_SMALL:        (21,13),
        WorldSizeTypes.WORLDSIZE_STANDARD:    (26,16),
        WorldSizeTypes.WORLDSIZE_LARGE:        (32,20),
        WorldSizeTypes.WORLDSIZE_HUGE:        (38,24)
    }

    if (argsList[0] == -1): # (-1,) is passed to function on loads
        return []
    [eWorldSize] = argsList
    return grid_sizes[eWorldSize]

I also adjusted minStartingDistanceModifier to -20 (as it is on the Terra.py map, although I suspect that shouldn't have caused the lack of oceans.)

Once I ran the script, however, all I got was one giant rectangular landmass with no oceans. I also noticed on the front-end menus that some of the menu options that normally appear for the Big_and_Small.py were missing in my modified script. (E.g., the Normal/Snaky/Massive continents option.)

Any suggestions on what I'm doing wrong here? That is, other than messing around with this instead of playing the game more.... ;)
 
When you get a big block of land it usually means your map script has crashed. Do you have the error pop-u[s and debug logging enabled? That will tell you exactly what went wrong.
 
edit civilizationIV.ini located into MyDocuments ( vanilla , warlords &/or BtS ) and change :

; Enable message logging
MessageLog = 1

; Enable the logging system
LoggingEnabled = 1

; Overwrite old network and message logs
OverwriteLogs = 1

; Set to 1 for no python exception popups
HidePythonExceptions = 0

Tcho !
 
Thanks. I enabled logging and got the following message:

Code:
File "string", line 1
import TERRA-SIZED_Big_and_Small

               ^

SyntaxError: invalid syntax

Of course, I copied the Big_and_Small.py file to TERRA-SIZED_Big_and_Small.py once I made my change.

As far as I can tell, line 1 is just a comment, so I'm assuming it's referring to the lines after the comments....this is what I see there. I thought, at first, that I had to change the "getDescription():" line, but I changed that to TXT_KEY_MAP_SCRIPT_TERRA-SIZED_BIG_AND_SMALL_DESCR" and still got the same error message.

Code:
#
#	FILE:	 Big_and_Small.py
#	AUTHOR:  Bob Thomas (Sirian)
#	PURPOSE: Global map script - Mixed islands and continents.
#-----------------------------------------------------------------------------
#	Copyright (c) 2007 Firaxis Games, Inc. All rights reserved.
#-----------------------------------------------------------------------------
#

from CvPythonExtensions import *
import CvUtil
import CvMapGeneratorUtil
from CvMapGeneratorUtil import FractalWorld
from CvMapGeneratorUtil import TerrainGenerator
from CvMapGeneratorUtil import FeatureGenerator

def getDescription():
	return "TXT_KEY_MAP_SCRIPT_BIG_AND_SMALL_DESCR"

def isAdvancedMap():
	"This map should not show up in simple mode"
	return 0

def getNumCustomMapOptions():
	return 3
 
Thanks. I enabled logging and got the following message:

Code:
File "string", line 1
import TERRA-SIZED_Big_and_Small

               ^

SyntaxError: invalid syntax

Is this the only error you got? Sometimes one error will cause a chain reaction of false error reports. Look at the very first error. Also, get the new Python IDE so you can check for syntax errors before trying them in Civ. http://www.python.org/
 
Code:
File "string", line 1
import TERRA-SIZED_Big_and_Small

               ^

SyntaxError: invalid syntax

Is this the entire error message ?

you don't have to care about getDescription() and the message error would have notice it . What program do you use to edit the file ? ... this is perhaps a problem of tabulation &/or structure ( missing if , else , for .... ) .

Tcho !
 
I get this popup immediately at startup:

Code:
Failed to load python module TERRA-SIZED_Big_and_Small

Then, when I click "OK", it is immediately followed by the syntax error message I listed above.

When I go to CUSTOM GAME and select "TERRA-SIZED_Big_and_Small" from the script options, I get the exact same string of those two error messages one after the other. It was repeated 9x.

Out of sheer habit, I used notepad to edit the script. I could use IDLE(Python GUI) to edit it, if that would help...I didn't think it made a difference though. Color me embarrassed if that's the cause of the errors here....

I've attached the edited map script (with a TXT extension, b/c this interface doesn't want to let me upload a file with a PY extension....)
 
I get this popup immediately at startup:

Code:
Failed to load python module TERRA-SIZED_Big_and_Small

Then, when I click "OK", it is immediately followed by the syntax error message I listed above.

When I go to CUSTOM GAME and select "TERRA-SIZED_Big_and_Small" from the script options, I get the exact same string of those two error messages one after the other. It was repeated 9x.

Out of sheer habit, I used notepad to edit the script. I could use IDLE(Python GUI) to edit it, if that would help...I didn't think it made a difference though. Color me embarrassed if that's the cause of the errors here....

Notepad is not good to edit python because some TAB are replaced with space when you copy paste . You should use notepad++ but python IDLE is the best . there is a trick to edit python with notepad but not easy to explain . Try to retabulate all your script with python and check for errors likes Cephalo suggest you .

Tcho !
 
I've retabulated all the file but it seems that it was good .

I've change the - with _ in the name .

I've had this to def gridSize ( probably the cause of bug on load ) :

Code:
    if (argsList[0] == -1): # [COLOR="Red"](-1,) is passed to function on loads !!!!!!!!!!!![/COLOR]
        return []
    [eWorldSize] = argsList
    return grid_sizes[eWorldSize]

and all is working now :)

Tcho !
 
Nice -- Thank you! I was about to report that using IDLE didn't change anything....

SO what is this bit of code supposed to do? What does "(-1,) is passed to function on loads" mean?

Code:
if (argsList[0] == -1): # (-1,) is passed to function on loads
        return []
    [eWorldSize] = argsList
    return grid_sizes[eWorldSize]
 
Nice -- Thank you! I was about to report that using IDLE didn't change anything....

SO what is this bit of code supposed to do? What does "(-1,) is passed to function on loads" mean?

Code:
if (argsList[0] == -1): # (-1,) is passed to function on loads
        return []
    [eWorldSize] = argsList
    return grid_sizes[eWorldSize]

I don't know why , but civ IV check the map script when the module is loaded , it send (-1,) to the function and expect to have [] for return .

Tcho !
 
Back
Top Bottom