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 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:

  2. #2
    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:

  3. #3
    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



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

    Default Re: Scripting problems

    That works thanks Atilius

    Looks like the region ID is numbered by game starting at top left corner - not according to descr_regions anyway, which means if you added new region to map whilst working on script you'd break the intended effect! Guess this is good lesson not to use underscored internal names.
    Not used mods before? Looking for something small and fun?!
    Download the:

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

    Default Re: Scripting problems

    Sorry for "kidnapping" your thread a little, Mak but I have a doubt about scripting.

    I remember that somebody, somewhere, told that the condition FactionBuildingExists doesn't work, but I've been unable to find the post where it was told.

    Can anybody confirm this point?

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

    Default Re: Scripting problems

    Quote Originally Posted by Monkwarrior
    Sorry for "kidnapping" your thread a little, Mak but I have a doubt about scripting.

    I remember that somebody, somewhere, told that the condition FactionBuildingExists doesn't work, but I've been unable to find the post where it was told.

    Can anybody confirm this point?
    no problem having a lot of similar questions in same place would be better anyway

    I don't know anything about that one, but I seem to have accidentally discovered trigger for Worldwide BuildingExists
    monitor_event SettlementTurnEnd region_id=15
    and I_CompareCounter Nagada = 1
    and GarrisonSettlementRatio < 0.8
    and SettlementBuildingExists > militia_barracks
    using the region_id instead of settlement name is making it return > militia_barracks result for whole map
    Quote Originally Posted by Atilius
    Underscores in internal names aren't the problem, it's spaces in external names.
    Ah, thanks again, I think a lot of our place names are about to acquire ~ or - in that case!
    Not used mods before? Looking for something small and fun?!
    Download the:

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

    Default Re: Scripting problems

    Another question, sorry, could anyone give any general advice on efficiency when running a script? Is there any difference in game performance between having lots of separate monitor_events or a few larger ones with lots of if's?

    I just managed to write a smallish script that made strat map grind to a halt - I'm hoping reason was I had a lot of
    if I_CharacterTypeNearTile sarmatians general, 2 145,97
    set_counter Roubair_slave 1
    end_if
    statements that weren't contained in monitors, which worked but must have meant it was checking them continuously
    am trying to fix that at moment.

    Am now getting things like:
    Code:
    monitor_event ButtonPressed ButtonPressed siege_assault_button
       and GarrisonSettlementRatio < 0.8
    
       if I_SettlementOwner Roubair = slave
             and I_FactionBesieged slave
             and I_FactionBesieging sarmatians
             and I_CompareCounter Roubair_slave < 1 
             and I_CompareCounter severin = 1 (that bit is local player check for sarmatians)
    
          if I_CharacterTypeNearTile sarmatians general, 2 145,97
             set_counter Roubair_slave 1
          end_if
          if I_CharacterTypeNearTile sarmatians family, 2 145,97
             set_counter Roubair_slave 1
          end_if
    
           if I_CompareCounter Roubair_slave = 1
             set_counter Roubair_slave 2
         	 console_command add_money slave, 1000
             console_command create_unit Roubair "west swordmen" 1
             console_command create_unit Roubair "west archers" 1
             console_command create_unit Roubair "west archers" 1
       	 console_command add_population Roubair  -300
             if RandomPercent < 40
             console_command create_unit Roubair "west swordmen" 1
       	 console_command add_population Roubair  -100
             end_if
             if RandomPercent < 40
             console_command create_unit Roubair "west archers" 1
       	 console_command add_population Roubair  -100
             end_if
          end_if
    terminate_monitor
          end_if
    end_monitor

    which works but I'm not sure how efficient that is - does it make any difference what you put as the first part of the if? ie. if you put the thing least likely to occur at the top does it stop it checking through more of the map?
    Not used mods before? Looking for something small and fun?!
    Download the:

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

    Default Re: Scripting problems

    Quote Originally Posted by Makanyane
    Guess this is good lesson not to use underscored internal names.
    Underscores in internal names aren't the problem, it's spaces in external names.
    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