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

    I'd realised a while ago about needing the export from SettlementTurnEnd (had temporarily forgotten - been round in so many circles)

    but same thing applies to that so if its

    Code:
    monitor_event SettlementTurnEnd SettlementName Rajah
       and I_CompareCounter Rajah = 1
       and GarrisonSettlementRatio < 0.8
       and not SettlementBuildingExists > militia_barracks
      if I_SettlementOwner Rajah = vandals
          and I_FactionBesieged vandals
             set_counter Rajah 2
        	 console_command add_money vandals, 1000
             console_command create_unit Rajah "semin" 1
    terminate_monitor
      end_if
    end_monitor
    it works
    Code:
    monitor_event SettlementTurnEnd SettlementName Rajah
       and I_CompareCounter Rajah = 1
       and GarrisonSettlementRatio < 0.8
      if I_SettlementOwner Rajah = vandals
          and not SettlementBuildingExists > militia_barracks
          and I_FactionBesieged vandals
             set_counter Rajah 2
        	 console_command add_money vandals, 1000
             console_command create_unit Rajah "semin" 1
    terminate_monitor
      end_if
    end_monitor
    with building check moved inside 'if' doesn't work - so 'if' statement breaks link to the returned information from the event????

    if that is general principle it might help explain other problems, as I've probably got ifs checking a lot more that they are meant to be, I was trying to reduce monitors by having more things as ifs inside, might not be the way to go!
    Not used mods before? Looking for something small and fun?!
    Download the:

  2. #2

    Default Re: Scripting problems

    'if' statement breaks link to the returned information from the event?
    Yes. The information returned by the event is only used by the conditions of the event (the main condition plus the additional "and" lines).
    With "if" statments you can only use conditions that starts by "I_", because they do not need any reference.

    I agree it seems you win some efficiency in the scripts when you reduce the monitor conditions by using "ifs" instead, because the "if" is only checked when all the other conditions are true.
    However, I guess that the conditions of the monitor are also checked in order, I mean that the 2nd condition should not be checked if the first is already false (this is how they usually work in other programing languages). If this is true, I suggest to place the conditions that are easy to check first, and conditions harder to be checked at the bottom. Although I have not verified it.
    Last edited by Bardo; 12-20-2007 at 01:16.

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

    Default Re: Scripting problems

    Not quite, most programing/scripting language make a choice about they want their language to "shortcut" and/or connectors by default, which only evaluate extra conditions if required.

    Take VB for example it doesn't use shortcut connectors if you use a simple OR between condition, you need to use ORELSE in order for it to shortcut the condition after it. Meanwhile c/c++ users are typically taught to use the shortcut && and || by default. So really it may or may not be impelemented as a shortcut connector and unless you check you really don't know.

    -Trait/Ancillary/Building Editor

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

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

    Default Re: Scripting problems

    thanks for responses

    though Squid, you lost me after first paragraph!

    Re Red Spot's earlier question
    also GarrisonSettlementRatio < 0.8, does that work??
    not so sure it does now, it seemed to be when I first tested it but have gone back to test on a simple end of settlement turn trigger and it now doesn't seem to be doing anything.

    EDIT: think we might be using the wrong bit for that docudemon entry is
    Identifier: GarrisonToPopulationRatio
    Trigger requirements: settlement
    Parameters:
    Sample use: GarrisonSettlementRatio > 0.35
    Description: Calculate the ratio of soldiers to civilians
    Battle or Strat: Strat
    Class: GARRISON_TO_POPULATION_RATIO
    Implemented: Yes
    Author: Guy
    writing it as
    and GarrisonToPopulationRatio < 0.1
    definitely works and goes on straightforward ratio, eg: if population is 5000 that will only trigger if less than 500 men are in the garrison troops.

    .....goes away to re-design script again......

    EDIT 2: just realised; that makes most sorts of calculation useless unless you also set it according to which unit size user is using.
    Last edited by Makanyane; 12-20-2007 at 17:22.
    Not used mods before? Looking for something small and fun?!
    Download the:

  5. #5
    EB Traitor Member BozosLiveHere's Avatar
    Join Date
    Jan 2006
    Location
    Uqbar, Tlön
    Posts
    3,662

    Default Re: Scripting problems

    That's why we have the UnitSize trait and scripts in EB. Check our campaign_script to see how we handle it.

  6. #6
    Axebitten Modder Senior Member Dol Guldur's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,550

    Default Re: Scripting problems

    Might as well post this here - does anyone know how to create a new advisor message that will appear without having to click the advisor portrait first? I've never really looked into this area much. Everything works fine, but that advisor will not open automatically. If I change the verbosity to anything other than 0 it does not appear at all when triggered...I just cannot see any difference between my version and those that do open automatically...

    I will post the code if necessary.
    "One of the most sophisticated Total War mods ever developed..."

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

    Default Re: Scripting problems

    Quote Originally Posted by Dol Guldur
    Might as well post this here - does anyone know how to create a new advisor message that will appear without having to click the advisor portrait first? I've never really looked into this area much. Everything works fine, but that advisor will not open automatically. If I change the verbosity to anything other than 0 it does not appear at all when triggered...I just cannot see any difference between my version and those that do open automatically...

    I will post the code if necessary.
    I have the same problem, but sometimes the message is open and sometime (the most) not. From my experience it seems to me that it is not possible to do it when the advisor appears at the faction turn start, and I feel that it is due to some interference of the incoming faction messages (the images falling from the top). When the advisor appears directly after some event or circumstances (city captured, for example) then the message appears with the typical simulate click orders.

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