Results 1 to 30 of 33

Thread: Scripting problems

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Finder of Little Oddities Senior Member Makanyane's Avatar
    Join Date
    Jan 2006
    Posts
    2,220

    Default Scripting problems

    I put plural in title as I think I'm likely to come up with more prob's later!

    For now - slightly simplified version but the below works so long as I don't include terminate monitor, as soon as I add terminate monitor it stops triggering, though I've managed to get a spawn army script elsewhere that accepts the terminate and only fires once.
    monitor_event SettlementTurnEnd SettlementName Metatron
    and I_CompareCounter Metatron = 1
    and GarrisonSettlementRatio < 0.8
    and SettlementBuildingExists > militia_barracks
    if I_SettlementOwner Metatron = vandals
    and I_FactionBesieged vandals
    and I_FactionBesieging sarmatians
    and I_CompareCounter severin = 1
    set_counter Metatron 2
    console_command create_unit Metatron "archala infantry" 1
    console_command create_unit Metatron "archala infantry" 1
    console_command create_unit Metatron "shovar" 1
    console_command create_unit Metatron "assakii archers" 1
    console_command add_population Metatron -400
    end_if
    terminate_monitor
    end_monitor
    Any idea why that won't take it? Alternatively can you actually get counters to work so that the set_counter = 2 actually stays set and doesn't allow the script which should be looking for it to equal 1 to fire?
    Not used mods before? Looking for something small and fun?!
    Download the:

  2. #2
    Anything that isn't 'member' Member Squid's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    596

    Default Re: Scripting problems

    If I were to take a guess, it would be because your terminte_monitor is outside the if statement that spawns the units. So if the event happens, but the if statement isn't true, the monitor is terminated, meaning that later if the event happens and the if statement were true would trigger because the monitor has already been terminated.

    I figured you didn't want the monitor terminated until the units spawn and the population increases.

    -Trait/Ancillary/Building Editor

    "Two things are infinite: the universe and human stupidity;
    and I'm not sure about the universe." -----Albert Einstein

  3. #3
    CeltiberoRamiroI Member Monkwarrior's Avatar
    Join Date
    Apr 2004
    Location
    Salduie/Caesaraugusta/ Sarakusta/Saragossa
    Posts
    828

    Default Re: Scripting problems

    Why do you use if?
    Why not this?
    monitor_event SettlementTurnEnd SettlementName Metatron
    and I_CompareCounter Metatron = 1
    and GarrisonSettlementRatio < 0.8
    and SettlementBuildingExists > militia_barracks
    and I_SettlementOwner Metatron = vandals
    and I_FactionBesieged vandals
    and I_FactionBesieging sarmatians
    and I_CompareCounter severin = 1
    set_counter Metatron 2
    console_command create_unit Metatron "archala infantry" 1
    console_command create_unit Metatron "archala infantry" 1
    console_command create_unit Metatron "shovar" 1
    console_command create_unit Metatron "assakii archers" 1
    console_command add_population Metatron -400
    terminate_monitor
    end_monitor
    Sorry if I didn't catch your main goal.

  4. #4
    Finder of Little Oddities Senior Member Makanyane's Avatar
    Join Date
    Jan 2006
    Posts
    2,220

    Default Re: Scripting problems

    @Squid, thanks that works now - I didn't realise you could put that anywhere else!

    @Monkwarrior
    originally mainly because I had no idea whatsoever what I was doing so was copying bits of other peoples scripts

    it's now got nested bits in it which is what I simplified out:
    monitor_event SettlementTurnEnd SettlementName Metatron
    and I_CompareCounter Metatron = 1
    and GarrisonSettlementRatio < 0.8
    and SettlementBuildingExists > militia_barracks

    if I_SettlementOwner Metatron = vandals
    and I_FactionBesieged vandals
    and I_FactionBesieging sarmatians
    and I_CompareCounter severin = 1
    set_counter Metatron 2
    console_command create_unit Metatron "archala infantry" 1
    terminate_monitor
    end_if

    if I_SettlementOwner Metatron = vandals
    and I_FactionBesieged vandals
    and I_FactionBesieging alemanni
    and I_CompareCounter lycans = 1

    set_counter Metatron 2
    console_command create_unit Metatron "archala infantry" 1
    terminate_monitor
    end_if

    end_monitor
    not sure if that is best way to do it or not, I want the besieging army paired with the compare counter condition that determines elsewhere if its human player or not. Seems to work if you are human player, I just need to check it doesn't trigger if you aren't.
    Not used mods before? Looking for something small and fun?!
    Download the:

  5. #5
    Finder of Little Oddities Senior Member Makanyane's Avatar
    Join Date
    Jan 2006
    Posts
    2,220

    Default Re: Scripting problems

    Next question; see I told you I'd be back....

    trying to use SettlementName function with double barrelled names, had heard there was a problem with that before, looked at LotR's script (I'm going to have to apologise to their script writer for cribbing)

    they use equivalent of
    monitor_event SettlementTurnStart SettlementName Fir·Reneh

    with dot instead of underscore, I can't persuade that or any alternative to work for Settlement internal name Fir_Reneh, though the underscored version works in other instances like
    if I_SettlementOwner Akna_Keil = ostrogoths

    the double name is definitely the only thing breaking it, if I switch to a single city name the event triggers.

    so does anyone know is Alex different from BI in this? And any ideas of solutions, hopefully other than re-naming half my regions in 5 different campaigns?!
    Not used mods before? Looking for something small and fun?!
    Download the:

  6. #6
    Bibliophilic Member Atilius's Avatar
    Join Date
    Oct 2005
    Location
    America Medioccidentalis Superior
    Posts
    3,837

    Default Re: Scripting problems

    Here's some code I wrote using vanilla RTW settlement names; this one is for Narbo Martius:

    Code:
    monitor_event GeneralCaptureSettlement region_id=43
        console_command set_building_health Narbo_Martius core_building 0
        console_command set_building_health Narbo_Martius barracks 0
        console_command set_building_health Narbo_Martius equestrian 0
        console_command set_building_health Narbo_Martius missiles 0
    end_monitor
    Doing the region_id comparison will work as long as your event exports the region ID. SettlementTurnStart and SettlementTurnEnd both do, so this ought to work for you. The region ID is displayed when you use show_cursorstat, so it's pretty easy to find.
    Last edited by Atilius; 11-15-2007 at 02:58.
    The truth is the most valuable thing we have. Let us economize it. - Mark Twain



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO