Page 1 of 2 12 LastLast
Results 1 to 30 of 33

Thread: Scripting problems

  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



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

  8. #8
    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?

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



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

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

  12. #12
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripting problems

    theoraticly I'd say that you're better of putting stuff in a single monitor with lots of if's, as long as whatever is in that monitor is similair stuff and you're not just calling that monitor for an entire script just cause someone said monitors are more demanding ... :D

    the game needs to continually(sp?) check up on monitors, where the if-statements are only being processed once the monitor is actually triggered

    (I dont think there is a single "black and white" answer here, just try not to spam monitors and keep things properly grouped)

    those "if character near .... " commands I have 2*198 in a single monitor, but all that monitor does is check up on generals near a tile and spawm some men if wanted/needed, anything else is again in its own monitors


    not too experianced scripting TW, but in other engines I always made sure that the if-statement least likelly to pass are checked first so there are as little follow-up checks as possible, though there will be little to even no diff. at all in how demanding a script is, at least not noticable, but every little bit helps specially if eventually your mod might be run by someone on a rather old system, or if you're using a zillion statements ... ;)


    btw;
    siege_assault_button, is that the "start siege on battlemap" button??
    also GarrisonSettlementRatio < 0.8, does that work??
    I've tried that one in M2 (or similair one) and it didnt "seem" to work there, does the current command basicly mean "if garrison is smaller than 80% of 20units" ??


    this is the start of my garrison bit of my script, just Rome in the example;
    Code:
    monitor_event ScrollOpened seige_scroll
    and ScrollOpened seige_scroll
    	if not I_SettlementOwner Rome = romans_julii
    		if I_CharacterTypeNearTile romans_julii family, 3 255, 155
    			set_counter Settlement_Besieged 1
    		end_if
    		if I_CharacterTypeNearTile romans_julii general, 2 255, 155
    			set_counter Settlement_Besieged 1
    		end_if
    		if I_CompareCounter Settlement_Besieged = 1
    			if I_SettlementOwner Rome = romans_senate
    				console_command create_unit Rome "roman praetorian cohort" 6 7 3 3
    				console_command create_unit Rome "roman praetorian cavalry" 2 7 3 3
    				console_command create_unit Rome "roman urban cohort" 4 6 3 3
    				console_command create_unit Rome "roman legion archer ii" 4 5 3 3
    			end_if
    			if not I_SettlementOwner Rome = romans_senate
    			and I_CompareCounter Settlement_Level = 3
    				console_command create_unit Rome "roman urban cohort" 6 6 3 3
    				console_command create_unit Rome "roman legion archer ii" 3 3 3 3
    				console_command create_unit Rome "roman urban cohort" 4 5 3 3
    				console_command create_unit Rome "roman legion archer ii" 3 4 3 3
    			end_if
    			if not I_SettlementOwner Rome = romans_senate
    			and I_CompareCounter Settlement_Level < 3
    				console_command create_unit Rome "roman legion cohort ii" 5 3 2 2
    				console_command create_unit Rome "roman legion archer ii" 3 2 2 2
    				console_command create_unit Rome "roman legion cohort ii" 5 4 2 2
    				console_command create_unit Rome "roman legion archer ii" 3 3 2 2
    			end_if
    			set_counter Settlement_Besieged 0
    		end_if
    	end_if
    end_monitor


    G
    Last edited by Red Spot; 11-18-2007 at 12:48.

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

    Default Re: Scripting problems

    thanks for answer, I'll have bit more of a look at permutations of how things could be grouped later...

    siege_assault_button, is that the "start siege on battlemap" button??
    also GarrisonSettlementRatio < 0.8, does that work??
    What I was trying to get (and works except laggy problem) was a couple of different results. If you siege city so it goes over its turn under siege as they have more time to prepare you get a stronger army appearing in there (and possibly some spawned relief forces appearing nearby), so thats set on SettlementEndTurn and combination of counters. But I also wanted something to trigger if you attacked city with cannons or 'elephants' and went straight for the assault, so that's linked to pressing the 'assault' rather than 'maintain' siege button.


    With your set up at moment does that keep triggering, if you re-open the scroll to see if ladders etc are built? I ended up putting terminate_monitors in to try and stop mine keep building troops.

    I think the settlement ratio thing works, at least when I had it lower <0.1 it didn't trigger, I was assuming it was working off the garrison level you see in the happiness rating in settlement view, and so related to population/army ratio - but haven't tested much....

    EDIT: just curious as well - won't your monitor trigger if say julii and senate are still allied but julii general is standing next to Rome when you open siege scroll somewhere else for different factions..? (I know mine overflows a bit as well but that was why I was trying to have FactionBesieging in and restrict it to firing if besieger was local player.
    Last edited by Makanyane; 11-18-2007 at 15:32.
    Not used mods before? Looking for something small and fun?!
    Download the:

  14. #14
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripting problems

    Quote Originally Posted by Makanyane
    just curious as well - won't your monitor trigger if say julii and senate are still allied but julii general is standing next to Rome when you open siege scroll somewhere else for different factions..? (I know mine overflows a bit as well but that was why I was trying to have FactionBesieging in and restrict it to firing if besieger was local player.

    yeah it does, brings a bit of "player-caution" into play, but it saves on some extra checks that only give a minor additional degree of certainty, like testing if the Julii are at war with the Senate and the Senate is actually besieged and the Julii besieging ... but that still doesnt garantee that the Julii are actually sieging settlement_x

    why I also asked about the siege button you are using, thought when I think about it I'd rather have some additional overflow in favour of knowing whats there to be killed ... :D


    G

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

    Default Re: Scripting problems

    why I also asked about the siege button you are using, thought when I think about it I'd rather have some additional overflow in favour of knowing whats there to be killed ...
    do you mean in terms of using assault button to view contents of enemy army without actually attacking? (it does add them if you do that but you also get to view them as soon as it displays enemy army) Surely creating units when you open siege scroll has same effect but earlier
    and also occurs if you just re-open it to check if siege engines are built?

    meh, I might switch over to adding default army on start of siege and then top up / spawn if you maintain siege over turn, but I think it needs the terminate monitors in either way (?)
    Not used mods before? Looking for something small and fun?!
    Download the:

  16. #16
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripting problems

    Quote Originally Posted by Makanyane
    do you mean in terms of using assault button to view contents of enemy army without actually attacking? (it does add them if you do that but you also get to view them as soon as it displays enemy army) Surely creating units when you open siege scroll has same effect but earlier
    and also occurs if you just re-open it to check if siege engines are built?

    meh, I might switch over to adding default army on start of siege and then top up / spawn if you maintain siege over turn, but I think it needs the terminate monitors in either way (?)
    actually I was, incorrectly, assuming that the siege_button would trigger the battle, but it ofcourse only triggers the deploment scroll(or what it is called)

    I'm not that bothered with extra spawn in such way that a settlement gets filled up, I already spawn 16units based on "global settlement level" wich pretty much fills up the settlement so an additional "viewing" might spawn 3 additional units but just as well none, anyway thats not really bothering me ...
    (I've taking lots of effort to try and get the AI up to a level where they can actually beat me on the campaign-map as well as battle-map without cheating all over the place, currently I get my behind kicked by the AI without cheating(well, AI eventually gets 2XP when training units, but only late in game) the only think I cant "balance out" is the fact that the AI doesnt respond to me paying a visit with ~3 to 5 stacks, 3 more units wont make much of a diff. in the big picture ... note that I play on VH/H in BI 1.6)


    G

  17. #17

    Default Re: Scripting problems

    looked at LotR's script (I'm going to have to apologise to their script writer for cribbing)
    I'm the lotr-tw scripter, and no apologise needed. Please, crib my scripts as much as you want, use freely all what you find useful, and share it here all what you think could be useful to others.
    Also, feel free to pm me if you want that I explain something about some script, or if you have any suggestion.

    As Athilus said: the Underscores in internal names aren't the problem, it's spaces in external names. We chose the middle dot to replace all the spaces from external names.
    Note: that I know, only the condition "SettlementName" uses the external name instead of the internal.

    Red Spot:also GarrisonSettlementRatio < 0.8, does that work??
    Makanyane: I was assuming it was working off the garrison level you see in the happiness rating in settlement view, and so related to population/army ratio
    I can confirm it works and I'm almost sure that Makanyane is right about the meaning.

    But, Makanyane, there where you have placed it in your lastest example it can't work because the event buttonpressed can't export the settlement record.

    monitor_event ButtonPressed ButtonPressed siege_assault_button
    and GarrisonSettlementRatio < 0.8
    monitor_event ScrollOpened seige_scroll
    and ScrollOpened seige_scroll
    I worked a lot in the development of my garrison script and I never though of using these kind of triggers .Thank you for point it out.
    I'll see if I can improve my garrison script with this info.
    Last edited by Bardo; 12-03-2007 at 13:06.

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

    Default Re: Scripting problems

    FATW uses indestructible buildings (marvels and regional buildings) to associate the script to (in addtion to one-word settlement names); not event scripting of course (we have none) but the traits and ancs coding...this was we do not need to worry about having settlements with more than one word in the name. Just a tip, though if you have a specific script on virtually every city then that system may not be robust enough.
    "One of the most sophisticated Total War mods ever developed..."

  19. #19
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripting problems

    you might want to go with Mak's method if you do end up using one, I'm tempting to change my script as well, it causes of lot of "sally out" scenarios ... a bit more than I actually like ...


    G

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

    Default Re: Scripting problems

    Thanks Bardo

    I did in the end use some events with the ScrollOpened seige_scroll event as well (though with terminate_monitor), and some done the way it works in LotR so you get garrison when siege lasts over turn, just to vary things for some cities to make result not as predictable for end user.

    If anyone's trying to use anything similar for M2TW its worth noting that, thankfully that does have an I_SettlementBesieged type condition (you'll need to check syntax) which removes the need for all the army placement checks. The little darlings also corrected the spelling of seige_scroll to siege_scroll, which was nice of them, but got me in trouble with friend who I gave text of RTW version to as an example, he figured out why it wasn't working after about 3 hours testing.
    Not used mods before? Looking for something small and fun?!
    Download the:

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

    Default Re: Scripting problems

    *bumps old thread* - am still trying to sort out possible script induced CTD mentioned in other thread.... in effort to try and simplify things I wondered
    should everything that works as an
    and....
    condition work as an
    if ....
    end_if
    condition?

    have got
    and SettlementBuildingExists > militia_barracks
    which works and detects building present or not correctly but stops event firing if put as
    if SettlementBuildingExists > militia_barracks
    ...
    end_if

    does that show that there is something dodgy about it? Or are there types of things you can't use in 'if'

    EDIT: that also only seems to work if its outside an 'if' as part of basic conditions for event and not as an 'and' inside an if clause. Using SettlementBuildingExists with = has exactly same problem.
    Last edited by Makanyane; 12-18-2007 at 20:33.
    Not used mods before? Looking for something small and fun?!
    Download the:

  22. #22
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripting problems

    In an other scripting-language you'd be absolutelly correct, though in this game as you noticed it doesnt work that way ..

    Rome's scripting-engine doesnt work with variables, so everything that needs a "reference" needs to be in some sort of "export of data" that contains both refrence as any data that you want available to you, or at least the coders once wanted available ..

    In the case of the condition "SettlementBuildingExists" you need the refrence [settlement] and get an "export of data" that is linked to/contains the settlement, the building data, and anything else you have available on the settlement, to get this "export of data" you connect the [setlement] to a command to get the export, in this case likelly the "SettlementTurnStart/End" events.


    G

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

  24. #24

    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.

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

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

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

  28. #28
    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..."

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

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

    Default Re: Scripting problems

    Quote Originally Posted by Monkwarrior
    From my experience it seems to me that it is not possible to do it when the advisor appears at the faction turn start...
    That's been my experience also.
    The truth is the most valuable thing we have. Let us economize it. - Mark Twain



Page 1 of 2 12 LastLast

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