workers or settlers joining cities

artemisarrow

Warlord
Joined
Dec 1, 2003
Messages
181
is there a way we can code in xml or python to make workers and or settlers have the ability to join a city?

i think this would be more of a python thing
 
is there a way we can code in xml or python to make workers and or settlers have the ability to join a city?

i think this would be more of a python thing

I have implemented "refugees" in my Fury Road mod. It is only a few lines of python, but I am pretty sure there is no way to do it in only xml. It is a unit which pops in a goody hut. You move it to a city and click a "resettle" action button. The city population increases by one and the unit is consumed.
 
that sounds pretty neet, is there anyway to make that action via python for a worker or a settler unit?
 
Sure, if you want to I'll make it. It doesn't look to hard, considering davidlallen did most of the code.
 
that would be awesome if you could make it... id love to incorpriate it into mods that i play... i think that making workers and settlers joining cities is great, especially if you have to abandon your cities and move to others...please keep me posted!
 
Sorry, been a little busy. Davidlallen, if you could tell me which python file it's in, that would help. It's probably obvious, I just don't know python very well.
 
Getting the action button is a little complex. I figured it out, based on Gods Of War, and I meant to write up a tutorial. But I never got around to it.

The code is in the Fury Road mod, see my sig or the download database. Briefly, you want to do the following. (Fury Road filenames in parentheses)

1. Define the unit you want to perform this, make sure you can control it in the game using WB

2. Define MOUSE_OVER help text for the action button. (XML/text/FuryRoadTextObjects.xml)

3. Define button art and create a related button (XML/art/CIV4ArtDefines_Interface.xml, search for RESETTLE)

4. Add code to draw the button, optionally disabled (Python/EntryPoints/CvMainInterface.py, search for "DaveA" comments)

5. Add the connection between the button from #3 and the help from #2 in getWidgetHelp (Python/CvGameUtils.py, search for RESETTLE)

6. Add code to call your local action routine (Python/EntryPoints/CvMainInterface.py, handleInput)

7. Add code in the local action routine to actually perform the operation (Python/CvFuryRoadEvents.py, handleResettle)

If you are good at python, this may be enough, but I should probably add a tutorial with a lot more detail.
 
Any idea what would be the problem if unit action buttons stop working? You can see the buttons, just not select them.
 
If I understand correctly, you have added a new button and it gets drawn, but nothing happens when you click it. That is the hard part :-) It may be critical that your first new button has event code 665, second one 666, etc. That is what I did but I don't know if the exact number matters.

Please confirm you have python exception popups enabled, it is impossible to debug productively without this.

Is your help appearing when you mouse-over the button? That is controlled by getWidgetHelp in the gameutils object.

Try putting a print statement in your handleInput routine in CvMainInterface.py. If that is getting called, you are most of the way there.
 
Add the connection between the button from #3 and the help from #2 in getWidgetHelp (Python/CvGameUtils.py, search for RESETTLE)

OMG, that's all that is necessary to create hover text in Python? ROFL, I had to jump through hoops to get hovers for the PLE buttons, and here I could add a couple lines to have hovers for everything!

Sweet, looks like I have that much more reason to make CvGameUtils modular. :D
 
Glad to provide something useful. I think I got that tip from Jeckel. It was almost a year ago, I have forgotten exactly where it came from.
 
The funny thing is that once upon a time I scanned through CvGameUtils to see if there was anything useful for BUG, but I think I started skimming instead of scanning after seeing so many game-rule-related callbacks. Cést la vie.
 
Back
Top Bottom