action buttons ... in python ... with BTS?

davidlallen

Deity
Joined
Apr 28, 2008
Messages
4,743
Location
California
I have been setting up a mod where fuel is precious. I have a simple system (described here) for units to run out of gas, which is working, in python with no SDK changes.

I want a fuel truck, which has an action button. When the action button is used it should refuel all the units in the stack. There is an Action Buttons mod which is pure python, and another Action Buttons 2.0 mod, which is SDK. Both of these appear to predate Warlords, let alone BTS. That means the particular files are relatively useless to "modern" modders, and I cannot find anything more recent on this.

I was able to patch the changes from Action Buttons 1.0 into the current game interface files, and my action button is successfully appearing. My problem is that my handler is not called; something is changed along the call chain between vanilla and BTS. In the Action Buttons 1 mod, I find:

Code:
class CvActionButtonsGameUtils(CvGameUtils.CvGameUtils):
def cannotHandleAction(self,argsList): 
# this is the only place I've found that you can respond to the action buttons

That no longer appears to be true; I added a print statement in this function and it is never called.

Can anybody suggest a standalone way to get action buttons working in BTS? If there is a relatively small but up-to-date SDK mod I can incorporate, that is fine, but I would prefer a python solution.
 
Grr!! I was 99% of the way there. The only thing I was missing is changing one character of PythonCallbackDefines.xml to enable cannotHandleAction.

So, it was easy to update this to BTS by merging the one change into CyMainInterface.py. Now my action buttons are working with no SDK required.
 
Glad to hear talch's old ActionButtons 1.0 mod is used. I have also updated this to BtS. Have you gotten help text to work with your ActionButtons?
 
Unfortunatly, no. BtS added the getWidgetHelp method to the GameUtils.py file, but I had alot of problems because it is expecting the iData passed to it to be a valid eActionID and throws exceptions if the iData is a negative or above the last action enum.

I think that, theoreticly, if you declare your actions in any of the action info xmls. There are a few action xmls, but the only one I can remember off the top of my head is the BuildInfo.xml. But I'm pretty sure if you did that it would give you an easy way to access the ActionButton's info like button image, the acual help text, ect, and it would also give it a valid eActionID to be passed to getWidgetHelp.

I haven't tryed any of that, it was just somthing I came up with a few weeks ago.
 
Hm. I can add a build object and then get its ID to pass around. But, the action button routine relies on the engine calling cannotHandleAction in order to perform my action. If I give it a real ID instead of my negative number, then it won't call cannotHandleAction, right? I don't really know enough about how these things interact to try your idea. But having the help would be really ... well, helpful :-)
 
Give me a few days and I will run by my pop's house and see if I left some copies of my ActionButtons mod on his computer. I'll look in it and see where I left off. I might have got some of the basics done already in preperation for making the flying help work.

But I'll post back here in a couple days with what I got. :)
 
Back
Top Bottom