You could use JRouteNative instead...
You could use JRouteNative instead...
;It is very easy to use this. Here is some example code:
[UNIT_WARRIOR] ;We want to work with the warrior
ROUTE_ROAD = True ;We want the warrior to require that a road be on the plot
[UNITCLASS_ARCHER] ;We want to work with the archer, skirmisher, and bowman
ROUTE_RAILROAD = True ;They all require that a railroad be on the plot
Since there is a request, here is a revised version updated to BtS 3.19.
I didn't try to change the logic of this ModComp, but be aware that, as such, when there is no route on the plot, your units cannot move into it. I'm surprised that nobody made the remark in this thread before! Note that this could be adjusted in Python.
Also, be aware that a unit configured to move only into plots with roads will not be able to enter your cities as soon as the tech for railroads has been researched!
[UNIT_WARRIOR] ;We want to work with the warrior unit
ROUTE_ROAD = True ;the warrior is only allowed to move along roads
[UNITCLASS_ARCHER] ;we want to work with the archer unit class
ROUTE_ROAD = True
ROUTE_RAILROAD = True ;the archer unit class can only move along roads and railroads
I can change the code one way or another but first, I would like to know what you want to achieve with this. As such, this mod comp is not very practical. Imagine that you have 200 units, adding some each week, if you want them to be allowed to use roads, you would have to add them all in the Config file and updating it regularly.
Some people were mentioning a mobile artillery only available on trains/railroads: it would be easier then to set the road as False than set the railroad as true and even more, a Config file is useless, you might as well insert a list in your code.
[UNIT_WARRIOR] ;Unrestricted
[UNIT_SCOUT] ;Roads only
ROUTE_ROAD = True
[UNIT_ARCHER] ;Can't move anywhere
ROUTE_ROAD = True
ROUTE_RAILROAD = True
Still, no unit can enter a plot without routes and only units with the corresponding route ability can enter a city. Is that needed and interesting?
Not to say that the mixture in the same file of UNIT types and UNITCLASS types complicates the whole thing.
The for loop is problematic: it loops through the routes (in BtS, there is only Road & Railroad), without looking at the plot(s). Since there are two entries in the Config file, one for each route, the condition is met twice and the code goes on to the next step, twice, to check if the plot has the same route as the loop. Automatically, once it is correct and once it is not, which makes the code declare that the unit cannot enter the plot, whether it has a road or a railroad!
I'm not sure I understand what you're saying. As it works now, only the units listed with routes are restricted. As is any unit not listed is unaffected, and any unit listed without a route specified is unrestricted. The logic is "Cannot enter tile" = TRUE or NULL (FALSE = double TRUE).
What am I trying to do? Well, I've got this Caravans II modcom, and I'd like to restrict caravans to roads & railroads (and to loading on vessels only at cities/forts).
I don't see a use for ROAD+NOT RAILROAD (I've got gypsy horse carts going past my house every day), but I suppose RAILROAD+NOT ROAD would open the possibility for a FREIGHT unit. (Not that interesting, IMO.) My goal is just ROUTE/NO ROUTE, to make the utility of caravans dependent upon the connectivity of the transportation network. Absent an rewrite of zRoutes, I'll just obsolete caravans with railroad.
@ Patriachica:
I've revised the CvPediaUnit.py file too: see previous post.
Does this version works for you?
You're a rock star.
How did you know?!
But I don't understand what you packed together: it's a mismatch between two different versions, GameUtils from version II and CvPediaUnit + the Config files from version I !!! It's not up to you to do that anyway.
Please delete this attachment as it is confusing.
Edit: packed version II with instructions: see post #56 above.