Results 1 to 14 of 14

Thread: Scripting Question

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Darkstar's Avatar Senator
    Join Date
    Feb 2007
    Location
    Massachusetts, USA
    Posts
    1,032

    Default Scripting Question

    Embarrassed to even ask this but I couldn't find it in a tutorial and none of the search terms I used came up with an answer.

    What is the difference between conditions that start with I_ vs those that don't. For example, I_FactionLeaderAttribute vs FactionLeaderAttribute.

  2. #2

    Default Re: Dumb Scripting Question

    Every question is a good question

    The I_ is generally used in an 'if' statement. If u use the docudemons (which is recommended) you may notice that any condition beginning with I_ has no requirements for it to be used, where as conditions without the I_ require specific requirements , such as 'WonBattle' requires the event to export 'charater_record'. You just need to use a little common sense with certain conditions tho and use it in monitors that it would make sense to use in. I generally use regular conditions to set the monitor up and then use the I_ conditions (if statements) to make the monitor more specific in what it is doing.

    If your conditions 'Trigger Requirement' is met you can generally use any I_ condition in an if statement and the monitor will fire without issue. Always check the trigger requirement the event is exporting makes sense with the I_ condition... (I_InBattle doesnt really make sense with the trigger requirement 'settlement'. Although if a monitor was set up correctly it may very well work as intended).

    It all depends on what your doing...

    I hope that helps...

    -EDIT-
    Note also that the condition inside the IF statement is not limited to the I_ conditions (it is just recommended), but the conditions used within the if statement must share the exact same trigger requirement as the initial condition and what the event exports. If you use multiple conditions prior to the if statement (even within it) then all must share the same requirement, if just one falters, the monitor will not fire. You will find it a lot easier to just use I_ conditions inside if statements. Less headache anyway.
    Last edited by Tsarsies; March 18, 2010 at 01:08 AM.
    ...longbows, in skilled hands, could reach further than trebuchets...

  3. #3
    Darkstar's Avatar Senator
    Join Date
    Feb 2007
    Location
    Massachusetts, USA
    Posts
    1,032

    Default Re: Dumb Scripting Question

    That makes sense. Looks like I was already using them in the correct way.

    One other question is I see a lot of example scripts that use a double equal sign:

    and I_EventCounter event_counter == 1

    Is this needed when using I_EventCounter and I_CompareCounter?

  4. #4
    Darkstar's Avatar Senator
    Join Date
    Feb 2007
    Location
    Massachusetts, USA
    Posts
    1,032

    Default Re: Dumb Scripting Question

    Quote Originally Posted by Tsarsies View Post

    -EDIT-
    Note also that the condition inside the IF statement is not limited to the I_ conditions (it is just recommended), but the conditions used within the if statement must share the exact same trigger requirement as the initial condition and what the event exports. If you use multiple conditions prior to the if statement (even within it) then all must share the same requirement, if just one falters, the monitor will not fire. You will find it a lot easier to just use I_ conditions inside if statements. Less headache anyway.
    Bumping an old question I asked in hopes to clarify the above statement posted by Tsarsies. I understand it's safest to only use I_ conditions inside if statements but I'd like to gain a better understanding of how I can use if statements.

    I've seen it written elsewhere that none of the requirements exported from the event are carried into the if statement. However, this contradicts what Tsarsies posted above which sounds like the requirements are carried if they match what the event is exporting as well as any other conditions being tested.

    Is there a set rule for what carries into an if statement or is it more trial and error depending on the specific condition I am trying to use?

  5. #5

    Default Re: Dumb Scripting Question

    the double == sign doesnt need to be used, a single = will suffice. Its generally done by people who are used to using other 'real' programming languages. You might even find some scripts written for M2TW that have both usages, i know ive done it on a few occasions.

    The bottom line is it doesnt make a difference how u do it within the M2TW scripting language.
    ...longbows, in skilled hands, could reach further than trebuchets...

  6. #6
    /|\/|\/|\/|\/|\/|\/
    Join Date
    Jun 2005
    Posts
    10,770

    Default Re: Dumb Scripting Question

    All 'I_' means to me is that it doesn't need an export from an event.

    Hence Tsarsies mentioning 'if' statements, since exports from the event tracked cannot be carried through if statements, we are forced to use 'I_' conditions.

    But basically any time the event does not export a report that I need, I check if there is a 'I_' way of writing the condition.

    Perhaps I have just repeated what Tsarsies said, my reading comprehension is not top-notch this morning... afternoon I mean...
    Last edited by Taiji; March 19, 2010 at 10:35 AM.

  7. #7
    Darkstar's Avatar Senator
    Join Date
    Feb 2007
    Location
    Massachusetts, USA
    Posts
    1,032

    Default Re: Scripting Question

    Yes, that makes sense now. Thanks guys.

    One more question for right now. What order do scripts and triggers get processed? For example if I have a trigger for faction standings, traits or ancillaries that gets tested at FactionTurnEnd, does this happen before or after my campaign script FactionTurnEnd monitors are run? I need to change some counters but not sure when to change it.

  8. #8
    konny's Avatar Artifex
    Join Date
    Jul 2007
    Location
    Germania Inferior
    Posts
    3,631

    Default Re: Scripting Question

    Interessting question, that I don't know the answer of. I have the impression that EDCT, EDA and the script are proceeded "at once", even though that would be impossible.

    Here is the order of TurnStarts / TurnEnds I had copied from someone else (don't know who is original author):

    02:02:45.968 PFTS launch
    02:02:45.968 CTS launch, then all faction characters start up one by one
    02:02:46.000 STS launch, one by one
    02:02:46.140 FTS
    02:02:48.718 CTE, one by one
    02:02:48.828 STE, one by one
    02:02:48.843 FTE

    Team member of: Das Heilige Römische Reich, Europa Barbarorum, Europa Barbarorum II, East of Rome
    Modding help by Konny: Excel Traitgenerator, Setting Heirs to your preference
    dHRR 0.8 beta released! get it here
    New: Native America! A mini-mod for Kingdoms America

  9. #9
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,751
    Blog Entries
    3

    Default Re: Scripting Question

    I don't know where scripts are done but EDA is definitely after EDCT.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  10. #10
    /|\/|\/|\/|\/|\/|\/
    Join Date
    Jun 2005
    Posts
    10,770

    Default Re: Scripting Question

    Quote Originally Posted by Darkstar View Post
    One more question for right now. What order do scripts and triggers get processed? For example if I have a trigger for faction standings, traits or ancillaries that gets tested at FactionTurnEnd, does this happen before or after my campaign script FactionTurnEnd monitors are run? I need to change some counters but not sure when to change it.
    If I understand correctly, the event has to be fired before it can be tested for. Events fired at the same point they would be tested for will not show up as events which have fired yet.

  11. #11
    Darkstar's Avatar Senator
    Join Date
    Feb 2007
    Location
    Massachusetts, USA
    Posts
    1,032

    Default Re: Scripting Question

    Quote Originally Posted by Taiji View Post
    If I understand correctly, the event has to be fired before it can be tested for. Events fired at the same point they would be tested for will not show up as events which have fired yet.
    Basically what I was thinking is:

    monitor event FactionTurnStart
    Conditions
    Set event counter to 1
    end monitor

    at FactionTurnEnd, fire trigger based on event counter being set to 1

    at FactionTurnEnd, set event counter back to 0 so the trigger doesn't fire next turn.

    In typing it out, I just answered my own question though. I can just set the event counter back to 0 at the end of the slave turn.

  12. #12
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,751
    Blog Entries
    3

    Default Re: Scripting Question

    Well only sort of, there's no real parallel processing in the world for practical purposes. Using your example when a FactionTurnStart event happens what likely happens is each trigger that fires on the event is queued up (this could actually be done on the loading of the game) and is the order in which the triggers fire would be determined by the order in which the triggers were added to the queue. Triggers are added to the queue from top to bottom in a file and certain files (such as EDCT to EDA) will occur before others.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  13. #13
    gracul's Avatar 404 Not Found
    Artifex

    Join Date
    Dec 2007
    Location
    Poland
    Posts
    2,009

    Default Re: Scripting Question

    Script -> EDCT -> EDA
    Of course if for example the event is CTE then it just means that first the script CTE will fire for the character then EDCT CTE and then EDA CTE, on a first finish one then start second basis, not first process all script CTE for all characters then EDCT all then EDA all.

    The main differences between EventCounter and Counter are:
    -Counters can only be used locally inside the script file
    -EventCounters can be used globally
    -Counters need a declare_counter first.
    Last edited by gracul; March 19, 2010 at 08:18 PM.

  14. #14
    /|\/|\/|\/|\/|\/|\/
    Join Date
    Jun 2005
    Posts
    10,770

    Default Re: Scripting Question

    Personally I've 'discovered' (through making the relevant mistakes) that only I_ conditions work in if statements. I'd like to hear of an exception, but I honestly doubt you'll find one.

    So I decided to make scripts to track whatever condition I want using counters, and then I can use I_CompareCounter instead of the condition I lack, and it's all working fine for me so far. So it's actually not a problem to concern yourself with at all really, because it's already been solved at least once

    But you check it out for yourself, if you like. I doubt it would take long to test every condition.
    Last edited by Taiji; February 14, 2011 at 05:16 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •