Another Noob Python Question

Flintlock1415

Emperor
Joined
Feb 24, 2008
Messages
1,057
Location
MN
Hi all, I'm trying to add a route restrictor to my train unit for my mod, but I'm having some trouble. I'm trying to just do it through CvGameUtils.py; modelling it on Zebra 9's modcomp. This mod is for Colonization, so I can't use the mod outright, and I don't really need to have ini configuring.

I don't exactly what to use to define my unit, (I think its iUnit?) nor the route. (Again I'm thinking iUnit, but what does in range do?)

I also don't understand what to make the route/unit do to tell the game what's true.

Here is as far as I got without completely screwing things up:
PHP:
def unitCannotMoveInto(self,argsList):
		ePlayer = argsList[0]
		iUnitId = argsList[1]
		iPlotX = argsList[2]
		iPlotY = argsList[3]
		
		
		## Locomotive Route Restriction
		pPlot = CyMap().plot(iPlotX, iPlotY)
		iUnit = gc.getInfotypeForString ( "UNIT_TRAIN" )
		iRoute = gc.getInfotypeForString ( "ROUTE_ROAD" )
		
		for iRoute
			if iUnit 
		
		## End Edit
		return False
And here's Zebra 9's code:
PHP:
def unitCannotMoveInto(self,argsList):
		ePlayer = argsList[0]		
		iUnitId = argsList[1]
		iPlotX = argsList[2]
		iPlotY = argsList[3]


		## Edited by Zebra 9
		pPlot = CyMap().plot(iPlotX, iPlotY)
		pUnit = gc.getPlayer(ePlayer).getUnit(iUnitId)

		szUnitType = gc.getUnitInfo(pUnit.getUnitType()).getType()
		szUnitClassType = gc.getUnitInfo(pUnit.getUnitType()).getXmlVal()
		for iRoute in range(gc.getNumRouteInfos()):
			if pConfig.getboolean(szUnitType, gc.getRouteInfo(iRoute).getType(), False):
				if pPlot.getRouteType() != iRoute:
					return True
		for iRoute in range(gc.getNumRouteInfos()):
			if pConfig.getboolean(szUnitClassType, gc.getRouteInfo(iRoute).getType(), False):
				if pPlot.getRouteType() != iRoute:
					return True
		## End Edit
		return False
Thanks for help in advance! :)
 
I don't exactly what to use to define my unit, (I think its iUnit?) nor the route. (Again I'm thinking iUnit, but what does in range do?)

Your unit-definition is right, but it doesn't fit to iUnitID, which gives you the unique ID of the unit in this game session.
:( i also don't know, how to connect these 2 variables, and i would need this information for an other work :(.

In range is the python statement for a for-loop.
In the modcomp, it seems, that zebra0 cycles through all available route types, and looks, if they fit to the values in the config.
This is not necessary for you.
You would have to do something like this:

PHP:
        pPlot = CyMap().plot(iPlotX, iPlotY)
        iUnit = gc.getInfotypeForString ( "UNIT_TRAIN" )
        iRoute = gc.getInfotypeForString ( "ROUTE_RAILROAD" )
        plotroute = pPlot.getRouteType
        if plotroute != iRoute:
               return true
        return false



I also don't understand what to make the route/unit do to tell the game what's true.

:confused: what?
 
Okay, but will the game know about the unit? i.e. even though its defined, don't I have to tell the game which unit to use within the if statement?

As for the second part; I worded that horribly :blush: , what I meant was how do I define the route and unit in the if statement? (If that's necessary?)
 
PHP:
	def unitCannotMoveInto(self,argsList):
		ePlayer = argsList[0]		
		iUnitId = argsList[1]
		iPlotX = argsList[2]
		iPlotY = argsList[3]
		player = gc.getPlayer(ePlayer)
		pUnit = gc.getPlayer(ePlayer).getUnit(iUnitId)
		szUnitType = gc.getUnitInfo(pUnit.getUnitType()).getType()
		CurrentUnit = gc.getInfoTypeForString(szUnitType)
		NotMovingUnit = gc.getInfoTypeForString('UNIT_TRAIN')
								
		pPlot = CyMap().plot(iPlotX, iPlotY) 
		if CurrentUnit == NotMovingUnit:
                        route = pPlot.getRouteType()
                        if route ==0:
                                return False
                        return True
                return False

That's it :).
routetype 0 is road, routetype 1 is railroad

Okay, but will the game know about the unit? i.e. even though its defined, don't I have to tell the game which unit to use within the if statement?

PHP:
        pUnit = gc.getPlayer(ePlayer).getUnit(iUnitId)
		szUnitType = gc.getUnitInfo(pUnit.getUnitType()).getType()
		CurrentUnit = gc.getInfoTypeForString(szUnitType)
		NotMovingUnit = gc.getInfoTypeForString('UNIT_TRAIN')
                [...]
        if CurrentUnit == NotMovingUnit:

The first 3 lines identify the current unit, the 4. line identifies the unit, whose movement you want to restrict, the last line compares the 2 units.


As for the second part; I worded that horribly :blush: , what I meant was how do I define the route and unit in the if statement? (If that's necessary?)

PHP:
	              if CurrentUnit == NotMovingUnit:
                        route = pPlot.getRouteType()
                        if route ==0:
                                return False
                        return True
                  return False

Like said above: The first line compares the units.
The second line gets the routetype on the plot you want to move to.
The 3. line compares the value to a defined value (-1 no road, 0 road, 1 railroad).
If the plot has the routetype, it returns a False, which means in the function CanNotMoveInto, that it can move into the plot.
If the plot has not the route-type, it returns a True, which means in the function CanNotMoveInto, that it can not move into the plot.
All other units get a False (they can move).
 
Assuming you want to make it so that Locomotives can only move onto plots with a Railroad route, here's all you need (you were very close):

Code:
def unitCannotMoveInto(self, argsList):
        ePlayer = argsList[0]
        iUnitId = argsList[1]
        iPlotX = argsList[2]
        iPlotY = argsList[3]
        
        ## Locomotive Route Restriction
        pUnit = gc.getPlayer(ePlayer).getUnit(iUnitId)
        iTrainType = gc.getInfotypeForString ( "UNIT_TRAIN" )
        if pUnit.getType() == iTrainType:
            pPlot = CyMap().plot(iPlotX, iPlotY)
            iRoute = gc.getInfotypeForString ( "ROUTE_RAILROAD" )
            if pPlot.getRouteType() != iRoute:
                # Train requires Railroad route
                return True
        
        ## End Edit
        return False

The last block of code above says that Trains cannot move onto Road plots, but it doesn't block moving onto non-Railroad plots.
 
The last block of code above says that Trains cannot move onto Road plots, but it doesn't block moving onto non-Railroad plots.

double negative statements will hunt me in my dreams tonight, but my version should work:

PHP:
                        if route ==0://if a road is there
                                return False //then the unit can move into it
                        return True //else not

PHP:
if pPlot.getRouteType() != iRoute: //if there's not a railroad
                # Train requires Railroad route
                return True //the unit can not move into the plot

Both seems to be the same.
If not, Bool himself should appear, and kick my a***.
But i sat here 5 minutes to understand, what you mean, and again 5 minutes, to make sure, that i understand my code :D, so there's a good chance, that i'm wrong.
 
We're both incorrect (I think) for different reasons.

For my part, I read your code wrong missing the double negative. Your code now reads, "If there's no road, train cannot move onto it." My assumption is that Trains should only be able to move onto Railroads--not Roads.

For your part, you're using Road instead of Railroad (only wrong if my assumption is correct).

Either way, why didn't Firaxis add iRequiredRouteType to UnitInfo? :p
 
Is there a way of determining whether a route is availiable? Like a check to see if there is a route there, then if not return true.

Then if it makes it past that, do a check to see if the route is a road, if so, then return true.

If it makes it past that, give a false statement so the unit can move.
 
CyPlot.getRouteType() returns the route the plot has. If that function returns -1, that means it has no route.

-1 = RouteTypes.ROUTE_NONE
0 = RouteTypes.ROUTE_ROAD
1 = RouteTypes.ROUTE_RAILROAD

But if you use those constants or the numbers, you bind yourself to them. If a mod introduces a new route type between ROAD and RAILROAD (probably unlikely and a bad idea), your code that uses 1 will break.

The code posted above this post uses gc.getInfoTypeForString() to check for "ROUTE_RAILROAD" which will work as long as there is a Railroad route type, no matter which route # it happens to be.
 
I neglected to mention that I tried your code, but it didn't work. :sad:
Just FYI Colonization doesn't have a railroad route, so I did have to add one in (but this shouldn't matter, should it?)

I know that the gc.getInfoTypeForString() will work just the same, but I'm not sure I understand the logic to this part:
iRoute = gc.getInfotypeForString ( "ROUTE_RAILROAD" )
if pPlot.getRouteType() != iRoute:
# Train requires Railroad route
return True
Esp. the if pPlot... line. I don't completely get what it does... :blush:
 
Don't you have to modify the C++ SDK to add new routes?

Regardless, let's say your new route is #2.

Code:
pPlot = CyMap().plot(iPlotX, iPlotY)

This assigns a CyPlot object to pPlot. You can use it to find the route type at those map coordinates.

Code:
iRoute = gc.getInfotypeForString ( "ROUTE_RAILROAD" )

This sets iRoute to 2 (or whatever # your new Railroad route type has).

Code:
pPlot.getRouteType()

This returns the # for the route type on the plot reference by pPlot.

Code:
if pPlot.getRouteType() != iRoute

This tests that returned value against iRoute (2) to see if it has the route type we want. != means "not equal". In this case, if the plot doesn't have the railroad route type, the if test passes and the code indented after it is executed, which is

Code:
return True

This returns True from the function, and since the function is testing if a unit cannot move onto a plot, it says that Trains cannot move onto plots that don't have the Railroad route type.

When you say it doesn't work, you aren't telling me anything that can help you fix the problem. It's like telling your mechanic that your car "doesn't work" and asking him what's wrong with it without letting him examine your car. It could be out of gas, have a dead battery, have no tires, etc.

How does it not work. What happens?
 
Well first of all, in case I copied your work wrong, here is the code in my CvGameUtils file:
PHP:
def unitCannotMoveInto(self,argsList):
		ePlayer = argsList[0]
		iUnitId = argsList[1]
		iPlotX = argsList[2]
		iPlotY = argsList[3]
		
		
		## Locomotive Route Restriction
		pUnit = gc.getPlayer(ePlayer).getUnit(iUnitId)
		iTrainType = gc.getInfotypeForString ( "UNIT_TRAIN" )
		if pUnit.getType() == iTrainType:
			pPlot = CyMap().plot(iPlotX, iPlotY)
			iRoute = gc.getInfotypeForString ( "ROUTE_RAILROAD" )
			if pPlot.getRouteType() != iRoute:
				return True
		
		## End Edit
		return False
Secondly, it doesn't work because it didn't change anything. I plopped a train onto the map w/ Worldbuilder on a Railroad route. I place some road and left some empty, but the Train still goes anywhere it wants to. :confused:
 
Did you enable the unitCannotMoveInto Python callback in the PythonCallbackDefines.xml file?

Code:
<Define>
	<DefineName>USE_UNIT_CANNOT_MOVE_INTO_CALLBACK</DefineName>
	<iDefineIntVal>[B][COLOR="Red"]1[/COLOR][/B]</iDefineIntVal>
</Define>
 
Do you get any Python errors in Logs/PythonErr.log?

Let's try adding some test prints to it:

Code:
def unitCannotMoveInto(self,argsList):
        ePlayer = argsList[0]
        iUnitId = argsList[1]
        iPlotX = argsList[2]
        iPlotY = argsList[3]
        
        
        ## Locomotive Route Restriction
        pUnit = gc.getPlayer(ePlayer).getUnit(iUnitId)
        CyInterface().addImmediateMessage("Testing unit %s %d" % (pUnit.getName(), iUnitId), "")
        iTrainType = gc.getInfotypeForString ( "UNIT_TRAIN" )
        if pUnit.getType() == iTrainType:
            pPlot = CyMap().plot(iPlotX, iPlotY)
            iRoute = gc.getInfotypeForString ( "ROUTE_RAILROAD" )
            CyInterface().addImmediateMessage("Testing plot with route %d against %d" % (pPlot.getRouteType(), iRoute), "")
            if pPlot.getRouteType() != iRoute:
                CyInterface().addImmediateMessage("Blocking move", "")
                return True
        
        ## End Edit
        CyInterface().addImmediateMessage("Allowing move", "")
        return False
 
Okay I got an error, but I can't really make sense of it. the only error in the file I edited is with the return True line.
Here it is:
Spoiler :
Traceback (most recent call last):

File "<string>", line 1, in ?

File "<string>", line 52, in load_module

File "CvGameInterface", line 13, in ?

File "<string>", line 35, in load_module

File "<string>", line 13, in _get_code

File "CvGameUtils", line 74

return True

^

SyntaxError: invalid syntax
Failed to load python module CvGameInterface.
ERR: Call function doGoody failed. Can't find module CvGameInterface
ERR: Call function doGoody failed. Can't find module CvGameInterface
ERR: Call function doGoody failed. Can't find module CvGameInterface
ERR: Call function doGoody failed. Can't find module CvGameInterface
ERR: Call function doGoody failed. Can't find module CvGameInterface
ERR: Call function doGoody failed. Can't find module CvGameInterface
ERR: Call function doGoody failed. Can't find module CvGameInterface
ERR: Call function doGoody failed. Can't find module CvGameInterface
ERR: Call function doGoody failed. Can't find module CvGameInterface
ERR: Call function doGoody failed. Can't find module CvGameInterface
ERR: Call function citiesDestroyFeatures failed. Can't find module CvGameInterface
ERR: Call function doPlotCulture failed. Can't find module CvGameInterface
ERR: Call function citiesDestroyFeatures failed. Can't find module CvGameInterface
ERR: Call function doPlotCulture failed. Can't find module CvGameInterface
ERR: Call function citiesDestroyFeatures failed. Can't find module CvGameInterface
ERR: Call function doPlotCulture failed. Can't find module CvGameInterface
ERR: Call function citiesDestroyFeatures failed. Can't find module CvGameInterface
ERR: Call function doPlotCulture failed. Can't find module CvGameInterface
ERR: Call function citiesDestroyFeatures failed. Can't find module CvGameInterface
ERR: Call function doPlotCulture failed. Can't find module CvGameInterface
ERR: Call function citiesDestroyFeatures failed. Can't find module CvGameInterface
ERR: Call function doPlotCulture failed. Can't find module CvGameInterface
ERR: Call function citiesDestroyFeatures failed. Can't find module CvGameInterface
ERR: Call function doPlotCulture failed. Can't find module CvGameInterface
ERR: Call function doGoody failed. Can't find module CvGameInterface
ERR: Call function citiesDestroyFeatures failed. Can't find module CvGameInterface
ERR: Call function doPlotCulture failed. Can't find module CvGameInterface
ERR: Call function citiesDestroyFeatures failed. Can't find module CvGameInterface
ERR: Call function doPlotCulture failed. Can't find module CvGameInterface
ERR: Call function citiesDestroyFeatures failed. Can't find module CvGameInterface
ERR: Call function doPlotCulture failed. Can't find module CvGameInterface
ERR: Call function doGoody failed. Can't find module CvGameInterface
ERR: Call function doGoody failed. Can't find module CvGameInterface
ERR: Call function citiesDestroyFeatures failed. Can't find module CvGameInterface
ERR: Call function doPlotCulture failed. Can't find module CvGameInterface
ERR: Call function citiesDestroyFeatures failed. Can't find module CvGameInterface
ERR: Call function doPlotCulture failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function calculateScore failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function cannotDoControl failed. Can't find module CvGameInterface
ERR: Call function cannotDoControl failed. Can't find module CvGameInterface
ERR: Call function cannotDoControl failed. Can't find module CvGameInterface
ERR: Call function cannotDoControl failed. Can't find module CvGameInterface
ERR: Call function cannotDoControl failed. Can't find module CvGameInterface
ERR: Call function cannotDoControl failed. Can't find module CvGameInterface
ERR: Call function cannotDoControl failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function cannotSelectionListMove failed. Can't find module CvGameInterface
ERR: Call function cannotSelectionListGameNetMessage failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function cannotSelectionListMove failed. Can't find module CvGameInterface
ERR: Call function cannotSelectionListGameNetMessage failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function cannotSelectionListMove failed. Can't find module CvGameInterface
ERR: Call function cannotSelectionListGameNetMessage failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function unitCannotMoveInto failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function cannotSelectionListGameNetMessage failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function isActionRecommended failed. Can't find module CvGameInterface
ERR: Call function updateColoredPlots failed. Can't find module CvGameInterface
ERR: Call function cannotDoControl failed. Can't find module CvGameInterface
ERR: Call function cannotDoControl failed. Can't find module CvGameInterface
ERR: Call function cannotDoControl failed. Can't find module CvGameInterface
ERR: Call function cannotDoControl failed. Can't find module CvGameInterface
ERR: Call function doGold failed. Can't find module CvGameInterface
ERR: Call function AI_unitUpdate failed. Can't find module CvGameInterface
ERR: Call function AI_unitUpdate failed. Can't find module CvGameInterface
ERR: Call function AI_unitUpdate failed. Can't find module CvGameInterface
ERR: Call function AI_unitUpdate failed. Can't find module CvGameInterface
ERR: Call function AI_unitUpdate failed. Can't find module CvGameInterface
ERR: Call function AI_unitUpdate failed. Can't find module CvGameInterface
ERR: Call function doGold failed. Can't find module CvGameInterface
ERR: Call function doGrowth failed. Can't find module CvGameInterface
ERR: Call function doCulture failed. Can't find module CvGameInterface
ERR: Call function doPlotCulture failed. Can't find module CvGameInterface
ERR: Call function doProduction failed. Can't find module CvGameInterface
ERR: Call function AI_chooseProduction failed. Can't find module CvGameInterface
ERR: Call function AI_chooseProduction failed. Can't find module CvGameInterface
ERR: Call function getExperienceNeeded failed. Can't find module CvGameInterface
 
Strange. Make sure all the indentation around there is correct, though I would expect an IndentationError if it wasn't. "return" is obviously correct. Try removing the line immediately preceding it. If that doesn't work, try deleting the return True line and retyping it. If that doesn't work, remove the line but leave the message: do you now see the message even though your unit is allowed to move where it shouldn't?
 
I fixed up all of the indentation, and now I get a new error:
Spoiler :
AttributeError: 'CyGlobalContext' object has no attribute 'getInfotypeForString'
ERR: Python function unitCannotMoveInto failed, module CvGameInterface
Traceback (most recent call last):

File "CvGameInterface", line 66, in unitCannotMoveInto

File "CvGameUtils", line 67, in unitCannotMoveInto

AttributeError: 'CyGlobalContext' object has no attribute 'getInfotypeForString'
ERR: Python function unitCannotMoveInto failed, module CvGameInterface
 
We're both incorrect (I think) for different reasons.

For my part, I read your code wrong missing the double negative. Your code now reads, "If there's no road, train cannot move onto it." My assumption is that Trains should only be able to move onto Railroads--not Roads.

For your part, you're using Road instead of Railroad (only wrong if my assumption is correct).

Maybe you've been right.
I had first posted a version, where the return values were false, so if you've read this, your correction was right.

And roads, railroads...the principle is the same.

Either way, why didn't Firaxis add iRequiredRouteType to UnitInfo? :p

No idea :D.

Don't you have to modify the C++ SDK to add new routes?

No, is not necessary.
Tsentom has added a new route type to his mod, and he has no own dll.

Okay I got an error, but I can't really make sense of it. the only error in the file I edited is with the return True line.
Here it is:

You should use python idle to modify python files, because all tabs are important to python, and modifying py-files with notepad, etc. doesn't work good, it screws up the tabs.

I fixed up all of the indentation, and now I get a new error:
Spoiler :
AttributeError: 'CyGlobalContext' object has no attribute 'getInfotypeForString'
Spoiler :


It's

Code:
getInfo[COLOR="Red"][b]T[/b][/COLOR]ypeForString

It's a communication with c++, and it cares about case-sensitivy (python itself doesn't care).

But i had this "bug" several times :mad:, but copy+paste works good to avoid it.
 
Top Bottom