Militia

I'm no expert on this, but comparing to other functions RevDCM uses that basically tack themselves onto CvEventManager.py via BUG's modular loading, there are some things that are different.

It seems weird that you are creating a new class, Militia, when all I see inside it is the function you want the EventManager to launch, and an unknown init function. Putting your main function inside a class should be protecting it, so that may be the cause of it not working right there. Though admittedly I don't know python that well, and haven't looked up classes in python, they may be different, but at least in C++ putting that function in a class, and not defining it as public would shield it, so that it couldn't be launched. Also however BUG taks on functions into CvEventManager wouldn't know to look inside this new class anyway, assuming it was public (unless you told it to do so, which I don't see any code doing that).

You're also importing alot of python files that I don't think are necessary, but that shouldn't be causing the problem. But all you should need is the function OnImprovementBuilt itself, and the files needed for that function to work. Try eliminating the class and init functions and see if that works. No guarantees, but that's my guess.

This of course assumes that all you're trying to do is get militia units to spawn for a player running Caste System when they build a farm. If not, and this function is tied into the Militia class, then we need more information about what behavior you are trying to get, and also more knowledge about the parts of this modcomp.
 
I have no idea about RoM, but i've recently digged into RevDCM, so i understand some things of what phungus said :D.

To work in RevDCM (i know RoM is based on it), the milita class would have to be removed, which then leads to a complete re-intendation of the whole file.
Because i know, that you can mess it really easy up if you don't have python, i've shortly done this, the changed file is attached.
Try it out, hopefully it works (but no guarantee).
 

Attachments

I have no idea about RoM, but i've recently digged into RevDCM, so i understand some things of what phungus said :D.

To work in RevDCM (i know RoM is based on it), the milita class would have to be removed, which then leads to a complete re-intendation of the whole file.
Because i know, that you can mess it really easy up if you don't have python, i've shortly done this, the changed file is attached.
Try it out, hopefully it works (but no guarantee).

OK tried it above and its a NO GO. I didnt change anything except the python file itself, and i completely removed the old python file and replaced it with the one above. Heres the error:

Traceback (most recent call last):
File "BugConfig", line 110, in unknown_endtag
File "BugConfig", line 334, in endChild
File "BugConfig", line 337, in end
File "BugConfig", line 318, in process
File "BugConfig", line 547, in handle
File "BugUtil", line 650, in callFunction
File "BugUtil", line 629, in lookupFunction
File "BugUtil", line 623, in lookupModule
ConfigError: No such module 'Militia'

Heres what the pic is referring to:

Spoiler :
Code:
<!-- Rise of Mankind -->
	<events module="WarPrizes">	</events>
	<events module="WorldFair">	</events>
	<events module="ScreenResolutionSize">	</events>
	<events module="CvWaterAnimalsModEventManager">	</events>
	<events module="NukeAfterEffects">	</events>
	<events module="WarriorsOfGod">	</events>
	<events module="CvMercEventManager">	</events>
	<events module="SubdueAnimals">	</events>
	<events module="CaptureSlaves">	</events>
	<events module="Espionage">	</events>
	[B]<events module="Militia">	</events>[/B]		
	<events module="CvEnhancedTechConquestEventManager">
	</events>
	<!-- Rise of Mankind end -->

old python is in second spoiler (1st post).
 
I've been again unclear :/.

I meant the XML which is mentioned here.

Ok i have never seen this stuff before, until Orion mentioned something he did about this, but in RoM, i never have seen it done this way?

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
Lucky Charms - Provides various free goodies at random
-->
<mod id="LuckyCharms"/>

but i have it listed in the events in the init file:

<!-- Rise of Mankind -->
<events module="WarPrizes"> </events>
<events module="WorldFair"> </events>
<events module="ScreenResolutionSize"> </events>
<events module="CvWaterAnimalsModEventManager"> </events>
<events module="NukeAfterEffects"> </events>
<events module="WarriorsOfGod"> </events>
<events module="CvMercEventManager"> </events>
<events module="SubdueAnimals"> </events>
<events module="CaptureSlaves"> </events>
<events module="Espionage"> </events>
<events module="Militia"> </events>
<events module="CvEnhancedTechConquestEventManager">
</events>
<!-- Rise of Mankind end -->
 
Code:
ConfigError: No such module 'Militia'

This is a very specific error telling you that there is no Python module named "Militia.py" in the Python folder or its subfolders.

@The_J - My sig has a link to the BUG Modding Tutorial.
 
Code:
ConfigError: No such module 'Militia'

This is a very specific error telling you that there is no Python module named "Militia.py" in the Python folder or its subfolders.

I think thats what is wrong, but as you can tell, i have it there, thats what i dont understand what the heck is going wrong:confused::crazyeye::(
 
@The_J - My sig has a link to the BUG Modding Tutorial.

Yes, i know ;).
I've gone through it, and it worked without any problems -> well done :goodjob:.

But, if i see this right, the modular approach seems to be a bit different, isn't it?
 
@strategyonly

Look at some of the other modules in RoM that are loaded via bug. Specifically look at the MovieMod. RoM uses a RevDCM core, so there should be a few modules to use as a reference guide.
 
@strategyonly

Look at some of the other modules in RoM that are loaded via bug. Specifically look at the MovieMod. RoM uses a RevDCM core, so there should be a few modules to use as a reference guide.

Yeah but its all over the place, hard to tell what goes where?
 
The movie mod, or the militia mod? I only see one function that you're trying to tak into for the example code; if so you should be able to implement it exactly the same way as the movie mod. You can read up in the BUG forums about how to modularlize it, if using an existant python module isn't working for you; personally I find using an existing module as a reference easier, but to each their own.
 
The movie mod, or the militia mod? I only see one function that you're trying to tak into for the example code; if so you should be able to implement it exactly the same way as the movie mod. You can read up in the BUG forums about how to modularlize it, if using an existant python module isn't working for you; personally I find using an existing module as a reference easier, but to each their own.

Thats exactly what i did, i used one from RoM and did everything the same just renamed stuff, but again NO units show up?:(
 
Sorry StrategyOnly, I should have been watching this thread.

@Guys, the only difference in structure between this mod and already successfully running mods (by StrategyOnly, Afforess and myself) is that this one calls the onImprovementBuilt event. An that event is not being called, I put a BUG debug statement at the begining of the event in the mod. The debug messages from my other mods are showing up as expected but never the onImprovementBuilt one.

Yes it uses an old way of doing things, I think we had a successful mod before the tutorial was written and just used that one as a model rather than going back to the doco.

I will now do one following the tutorial and see what happens. I am really good at reading instructions wrongly - and then figuring out what it should have said. :)
 
These are notes as I work through building this mod based on the tutorial.

1. doco saye it is mod=. idiot I used module=
2. do not get any of the messages I should get => turn on BugEventManager logging to true

run Civ
3. still not getting the debug and info messages expected.

Gah! My BUG options had changed.
4. OK now getting the messages I should be getting. On to next page.

5. Events page - can't find a CvEventManager.py any where in the RoM python directory.

Used the one in BTS to make sure I spelt onImprovementBuilt correctly.

Python code now:-
Spoiler :
Code:
# Militia

from CvPythonExtensions import *
import BugUtil

gc = CyGlobalContext()

def onImprovementBuilt(argsList):
	BugUtil.debug("Militia - onImprovementBuilt called")

Start new game. Add enough workers to build a farm in two turns. Play three turns, end game. Look at PythonDug.log debug message is not there. the ones from subdue animals are.

Conclusion onBuildImprovement does not work in BUG. May be a bit harsh.
 
I need to see your configuration XML file that has the <event .../> element in it. The full file, please.
 
Back
Top Bottom