Merging BUG with other Mods

Fuyu, you nailed the dll attribute, thanks.

The dirty bit tells BUG to set a Civ4 dirty bit using Cyinterface. This in turn tells the EXE to redraw certain parts of the screen. There is a list of dirty bit constants in the BTS API, and you can pass any one of those. For example, all scoreboard options specify the scoreboard dirty bit so the whole thing is redrawn when any of those options changes, either by the user or by code (same thing really).
 
Can you add a get and set function to something you are exposing to the dll? For instance would this work?

Code:
			<option id="EventsWithImages" key="EventsWithImages" 
					type="boolean" default="True" dll="5"
					get="isEventsWithImages" set="setEventsWithImages"/>

I'm curious to know if I can have something exposed to the dll, and still be able to call it from python using bug's function names.
 
The DLL can access all options, but it cannot use the Python get and set functions to do so. Instead it must always use getBugOptionXXX() and pass in the option's full ID (<modID> + "__" + <optionID>). The dll options attribute only tells BUG to disable the option's control on the options screen.

All options receive accessor functions. The attributes allow you to override the default function names: get<ID>()--is<ID>() for boolean options--and set<ID>(). The DLL cannot see these at all.
 
Ah, OK, that makes sense. Answers my question, and means I can't do what I was intending to, but that's OK, already have working code, was just looking for a way to simplify things.
 
I have been trying to merge this little mod I downloaded a while ago with the BUG mod. I have tried the tutorial, but it is not working for me. I got as far as the configuration step, which I think I did properly, but after that I just don't know what parts of the code need to be put in a module, and where and how to link them to get them working. I admit to having no modding experience. Can someone help me get this working? I know that it can't be that difficult. I just don't know what I'm doing.

This is the original mod

Timed Settler Mod

It has been working great for me alone.
 
Never mind, issue resolved. :p
Spoiler :
I have been trying to merge this little mod I downloaded a while ago with the BUG mod. I have tried the tutorial, but it is not working for me. I got as far as the configuration step, which I think I did properly, but after that I just don't know what parts of the code need to be put in a module, and where and how to link them to get them working. I admit to having no modding experience. Can someone help me get this working? I know that it can't be that difficult. I just don't know what I'm doing.

This is the original mod

Timed Settler Mod

It has been working great for me alone.
I tried to convert the mod-comp into a BUG module but it simply isn't working. This is my first attempt at BUG modding and the whole experience has left me doubtful I'll ever be able to work with BUG. Which is a real bummer. This is what I have done:
Spoiler :
Timed Settler.xml:
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
	Timed Settler Mod - converted to BUG by Baldyr
-->
<mod id="TimedSettler" module="TimedSettler">
	<event type="BeginPlayerTurn" function="onBeginPlayerTurn"/>
	<gameutils/>
</mod>
TimedSettler.py:
Code:
# Timed Settler mod

from CvPythonExtensions import *

gc = CyGlobalContext()

def onBeginPlayerTurn(argsList):
        iGameTurn, iPlayer = argsList
        iFirstTurnSettler =5
        iTurnsBetweenSettlers = 7
        if iGameTurn >= iFirstTurnSettler:
                if (iGameTurn-iFirstTurnSettler)%iTurnsBetweenSettlers == 0:
                        if iPlayer != gc.getBARBARIAN_PLAYER():
                                pPlayer = gc.getPlayer(iPlayer)
                                if pPlayer.isAlive():
                                        pCity = pPlayer.getCapitalCity()
                                        if not pCity.isNone():
                                                pPlayer.initUnit(gc.getCivilizationInfo(pPlayer.getCivilizationType()).getCivilizationUnits(gc.getInfoTypeForString('UNITCLASS_SETTLER')),pCity.getX(),pCity.getY(),UnitAITypes.NO_UNITAI,DirectionTypes.DIRECTION_NORTH)

def cannotTrain(argsList):
        if gc.getUnitInfo(argsList[1]).getUnitClassType() == gc.getInfoTypeForString('UNITCLASS_SETTLER'):
                return True
I've gotten rid of all issues I had with the XML (of which I basically know nothing, so it was a painful experience) and file encoding and tons of other nonsense. I'm not experiencing any more errors but I simply can't seem to be able to add a handler (by auto-detection) for the cannotTrain callback. (Yes, I enabled the callback by including a edited PythonCallbackDefines.xml file.)

What am I missing here?

edit: I've been working on Buffy 3.19.003 rather than BUG, by the way. (This is what shanpooter wanted to do anyway - merge Timed Settler with Buffy.)
 
Does this mean you merged it for shanpooter or helped them do it?
I managed to get my first BUG module working. So shanpooter doens't need to bother with any of this modding business. :D
 
Ahh, so you've finally decided to drink the Kool Aid? Nice! :goodjob:
Well, I was gonna do this guy a favor since no-one else seemed interested in helping him out. So I thought to myself: "how difficult can it be?" and also "its about time I look into this!". But I managed to regret this at least 3 times before I solved all the issues. :p

Basically, I think its an awful idea to have all this XML stuff involved. None of my text/code editors seem to be able to save XML in any efficient manner - the encoding somehow gets messed up whatever I do. And I keep messing up the XML itself - I pretty much only know Python at this point.

My problem is of course that I don't know any XML. So this little project took me like an entire evening. :rolleyes: And I still don't know why the callback wasn't being auto-detected. So I'm only gonna revisit BUG modding once I've learned some proper XML and know my way around a XML editor, or something. Otherwise it won't be a pleasant experience at all...

With that said, I'm continuously impressed with everything BUG whenever I read up on anything related to it. I guess its just a lot to take in - especially since I wanna be able to utilize all of it. Is pretty overwhelming.
 
Hey there, he of the nice Avatar.

For XML modding/coding, Notepad++ is your best friend. :D

It's available here: http://notepad-plus-plus.org/

Enjoy!

(And welcome to the jungle. :lol: )
 
I'm not big on installing anything and everything on my machine, and I already have several editors that I'm using. But just because you're a fellow Lena admirer I did what you suggested. I'll try Notepad++ out later. It'll better not cause me any grief over text encoding... :p
 
I'm not big on installing anything and everything on my machine, and I already have several editors that I'm using. But just because you're a fellow Lena admirer I did what you suggested. I'll try Notepad++ out later. It'll better not cause me any grief over text encoding... :p
Haha. No, it shouldn't. I like it because it's a WYSIWYG editor. If it can handle Irish without messing it up, I'm sure you won't have a problem with XML. :lol:
 
I'm trying to merge the Real Always War with BUG, it has it's own CvEventManager.py, I get errors

Spoiler :
Traceback (most recent call last):
File "BugEventManager", line 361, in _handleDefaultEvent
File "autologEventManager", line 801, in onChangeWar
RuntimeError: unidentifiable C++ exception
Traceback (most recent call last):
File "BugEventManager", line 361, in _handleDefaultEvent
File "autologEventManager", line 800, in onChangeWar
RuntimeError: unidentifiable C++ exception
Spoiler :
Civ4ScreenShot0004.jpg


What's up with that?
 

Attachments

You basically don't use CvEventManager with BUG. So you need to isolate the custom code in that module and put it into functions/classes-methods in a BUG module. Then you make a XML file for loading those functions/methods and add one line into the init.xml file of BUG.

Try the tutorial. It should be noted that merging Python code is not easy - and converting into a BUG setup adds another set of challenges - so you might as well ask someone else to do it for you if you're not fluent in Python. (Or you could learn Python first.)
 
Haha. No, it shouldn't. I like it because it's a WYSIWYG editor. If it can handle Irish without messing it up, I'm sure you won't have a problem with XML. :lol:
I tried Notepad++ and I basically can't save XML files. When I save my edits in GlobalDefines.xml the encoding gets messed up somehow and the game can't recognize the first character, or something.

So clearly I'm missing something. :dunno: How do I edit XML? Is there a guide? :confused:

edit: Someone enlightened me about the need to always use UTF-8 - without BOM for saving XML files. The problem is however that the encoding gets automatically changed to ANSI anytime I open up an XML file in Notepad++. This is basically the same problem I have with the regular Notepad (whenever I use it to edit Python modules).
 
I'm trying to merge the Real Always War with BUG, it has it's own CvEventManager.py, I get errors

C++ errors typically mean there's something wrong with the artwork (usually a missing button) or info classes. Doesn't that mod simply force everyone to declare war on everyone else at the start of the game?

Also, it's okay to have changes in CvEventManager as long as you're not merging a bunch of mods that do so. BUG does use CvEventManager. Technically, BugEventManager subclasses it, so any changed events should continue to work. What other files are changed in that mod? Does it have a custom DLL? Any new/changed XML files?

Someone enlightened me about the need to always use UTF-8 - without BOM for saving XML files. The problem is however that the encoding gets automatically changed to ANSI anytime I open up an XML file in Notepad++. This is basically the same problem I have with the regular Notepad (whenever I use it to edit Python modules).

Look for a setting in Notepad++ to change the default file encoding. I suspect your European version of Windows is messing with Notepad++.
 
Also, it's okay to have changes in CvEventManager as long as you're not merging a bunch of mods that do so. BUG does use CvEventManager. Technically, BugEventManager subclasses it, so any changed events should continue to work.
Aha, that explains some other odd behavior I've noticed...

Look for a setting in Notepad++ to change the default file encoding. I suspect your European version of Windows is messing with Notepad++.
Well, its possible that my Swedish version of Notepad++ is already messed up. :lol:

The issue is with any text/code editor I tried however. But I changed the default now so I won't be using anything else than Notepad++ for XML work.
 
C++ errors typically mean there's something wrong with the artwork (usually a missing button) or info classes. Doesn't that mod simply force everyone to declare war on everyone else at the start of the game?

Also, it's okay to have changes in CvEventManager as long as you're not merging a bunch of mods that do so. BUG does use CvEventManager. Technically, BugEventManager subclasses it, so any changed events should continue to work. What other files are changed in that mod? Does it have a custom DLL? Any new/changed XML files?

Look for a setting in Notepad++ to change the default file encoding. I suspect your European version of Windows is messing with Notepad++.

Yes it just forces the AI to be at war with each other. CvEventManager is the only file in the mod, I was going to use BULL also but one thing at a time.
 
Back
Top Bottom