Sorry guys, my efforts to simplify things and then explain the full story out of sequence is creating confusion. I'll start again...
I'm making a submod for TATW (Kingdoms) that provides a unit named "Elven Rangers". It is trying to do this in campaign_script.txt:
Code:
monitor_event FactionTurnStart turks
if I_NumberUnitsInSettlement Bree Elven_Rangers > 0
{do something}
end_if
end_monitor
This didn't work. Taking my unit out of the equation I tried again with standard TATW units for the "turks" faction:
Breeland Militia (type = Breeland Militia, dictionary = Breeland_Militia)
Bandits (type = Bandits, dictionary = Bandits)
This worked:
Code:
monitor_event FactionTurnStart turks
if I_NumberUnitsInSettlement Bree Bandits > 0
{do something}
end_if
end_monitor
But this:
Code:
monitor_event FactionTurnStart turks
if I_NumberUnitsInSettlement Bree Breeland_Militia > 0
{do something}
end_if
end_monitor
did nothing (but no errors in the log).
When I tried either of these:
Code:
monitor_event FactionTurnStart turks
if I_NumberUnitsInSettlement Bree Breeland Militia > 0
{do something}
end_if
end_monitor
Code:
monitor_event FactionTurnStart turks
if I_NumberUnitsInSettlement Bree "Breeland Militia" > 0
{do something}
end_if
end_monitor
then at first glance it appears to work but if I take that unit out of the city then it still works, which it shouldn't do. Looking at the log shows a "Number of units not declared" error. My guess is the IF statement is failing to parse and therefore being ignored so the {do something} is always being called - no longer being wrapped in an IF block.
Flummoxed, I wanted to see if vanilla M2TW had this same behaviour - using add_money as the {do something} - and sure enough it does.
Okay, so now I have installed BareGeomod and tried again in London with:
Town Militia (type = Town Militia, dictionary = Town_Militia)
Peasants (type = Peasants, dictionary = Peasants)
Peasants works fine.
Town_Militia and town_militia do nothing.
Town Militia and "Town Militia" give the same error and ignore-IF behaviour as before.
I tried both structures:
Code:
monitor_event FactionTurnStart FactionType england
and I_SettlementOwner London = england
and I_NumberUnitsInSettlement London town_militia > 0
add_money England 20000
end_monitor
and:
Code:
monitor_event FactionTurnStart FactionType england
and I_SettlementOwner London = england
if I_NumberUnitsInSettlement London town_militia > 0
add_money England 20000
end_if
end_monitor
Now, here's the strange thing. I renamed my Elven Ranger unit's "type" so that it didn't contain spaces:
type = ElvenRangers
dictionary = Elven_Rangers
name = Elven Rangers
Using ElvenRangers in the call works perfectly. The {do something} does its thing when this unit is in the city and doesn't do it when they're out of the city.
Surely this means, then, that type is the parameter to use, not dictionary. Which begs the question: how can you use a type that contains spaces? Because Town Militia, "Town Militia", Breeland Militia and "Breeland Militia" all failed with that error and ignore-the-IF behaviour.
The Docudemons say to use the "unit type (id)" and then uses a dictionary name in its sample. Maybe using dictionary is how RTW did it? I know that some of the samples are out of date.
@Taiji
Sorry mate - I only just noticed your post. I'll take a look at what you suggested.
+reps all round for trying to help