Results 1 to 17 of 17

Thread: Counters and Spawning

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Centenarius
    Join Date
    Jun 2012
    Location
    American president, Spanish conquistador, Italian cartographer
    Posts
    848

    Default Counters and Spawning

    I want to get my character to spawn and activate my counter, but the character doesn't spawn. I am transferring him from a spawnpool faction. Copy of my script:
    Click to view content: 
    declare_counter ImmortalRecruited
    set_counter ImmortalRecruited 0

    monitor_event FactionTurnEnd FactionIsLocal
    and if I_CompareCounter ImmortalRecruited 0
    spawn_army
    faction spawnpool
    character Immortal, named character, age 18, x 96, y 145
    unit Peasants exp 0 armour 0 weapon_lvl 0
    end
    give_everything_to_faction spawnpool england false
    inc_counter ImmortalRecruited 1

    end_monitor

  2. #2
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Counters and Spawning

    A missing = perhaps?

    Code:
     and if I_CompareCounter ImmortalRecruited = 0
    The log might be telling you about that error.

  3. #3
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Counters and Spawning

    Remove the 'if' - it's not needed and there is no 'end_if'
    Counters are always zero when they are declared, no need to do that.
    The counters are not needed at all if you are not resetting them back to zero, simply terminate the monitor.

    monitor_event FactionTurnEnd FactionIsLocal
    ; add more conditions here, eg turn number
    spawn_army
    faction spawnpool
    character Immortal, named character, age 18, x 96, y 145
    unit Peasants exp 0 armour 0 weapon_lvl 0
    end
    give_everything_to_faction spawnpool england false

    terminate_monitor
    end_monitor










  4. #4
    Centenarius
    Join Date
    Jun 2012
    Location
    American president, Spanish conquistador, Italian cartographer
    Posts
    848

    Default Re: Counters and Spawning

    Quote Originally Posted by Gigantus View Post
    Remove the 'if' - it's not needed and there is no 'end_if'
    Counters are always zero when they are declared, no need to do that.
    The counters are not needed at all if you are not resetting them back to zero, simply terminate the monitor.
    I plan to use the counter for something else later. Where do I place the 'end_if'?

  5. #5
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Counters and Spawning

    Quote Originally Posted by Gigantus View Post
    Remove the 'if'
    I didn't see that "if".

    No need for an end_if if you take the IF out...

    Code:
    monitor_event FactionTurnEnd FactionIsLocal
     and I_CompareCounter ImmortalRecruited = 0

  6. #6
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Counters and Spawning

    Before the end_monitor line, don't forget the equal sign in the condition.










  7. #7
    Centenarius
    Join Date
    Jun 2012
    Location
    American president, Spanish conquistador, Italian cartographer
    Posts
    848

    Default Re: Counters and Spawning

    I changed my script to put a use to the counter. New script:
    Click to view content: 
    declare_counter EnglandImmortalRecruited

    monitor_event FactionTurnEnd FactionIsLocal
    and if I_CompareCounter EnglandImmortalRecruited = 0
    spawn_army
    faction spawnpool
    character Immortal, named character, age 18, x 96, y 145
    unit Peasants exp 0 armour 0 weapon_lvl 0
    end
    give_everything_to_faction spawnpool england false
    inc_counter ImmortalRecruited 1
    end_if
    end_monitor

    monitor_event FactionTurnEnd FactionIsLocal
    and if I_compareCounter EnglandImmortalRecruited = 1
    and if not I_CharacterExists Immortal
    spawn_army
    faction spawnpool
    character Immortal, named character, age 18, x 96, y 145
    unit Peasants exp 0 armour 0 weapon_lvl 0
    end
    end_if
    end_monitor

    Error log:
    Click to view content: 
    15:09:45.650 [game.script] [error] Condition parsing error in mods/Bare_Geomod/data/world/maps/campaign/imperial_campaign/campaign_script.txt, at line 4, column 6
    Condition parser doesn't recognise this token: if
    15:09:45.650 [game.script] [error] Script parsing error at line 8, column 46 in mods/Bare_Geomod/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    Unrecognised unit data string ()
    15:09:45.650 [game.script] [error] Script parsing error at line 10, column 2 in mods/Bare_Geomod/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    Couldn't create a script from file mods/Bare_Geomod/data/world/maps/campaign/imperial_campaign/campaign_script.txt

  8. #8
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Counters and Spawning

    There is no need for 'and' as far as I know. The rest of the errors will be 'domino' effect.
    And the second monitor has a logic error. Two 'if' will need two corresponding 'end_if' - in this case the second if is not needed as it is part of the conditions of the first if.










  9. #9
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Counters and Spawning

    The correct syntax would be either:

    Code:
    monitor_event FactionTurnEnd FactionIsLocal
       and I_CompareCounter EnglandImmortalRecruited = 0  ; <-- no IF
    
     spawn_army
     faction spawnpool
     character Immortal, named character, age 18, x 96, y 145
     unit Peasants exp 0 armour 0 weapon_lvl 0
     end
     give_everything_to_faction spawnpool england false
     inc_counter ImmortalRecruited 1
     
     ;no END_IF because there is no IF
    
    end_monitor
    or:

    Code:
    monitor_event FactionTurnEnd FactionIsLocal
     
     if I_CompareCounter EnglandImmortalRecruited = 0
    
       spawn_army
       faction spawnpool
       character Immortal, named character, age 18, x 96, y 145
       unit Peasants exp 0 armour 0 weapon_lvl 0
       end
       give_everything_to_faction spawnpool england false
       inc_counter ImmortalRecruited 1
    
     end_if
    
    end_monitor

  10. #10
    Centenarius
    Join Date
    Jun 2012
    Location
    American president, Spanish conquistador, Italian cartographer
    Posts
    848

    Default Re: Counters and Spawning

    I changed my script so there is only 'if' in the first monitor and only one 'if' in the second. It still gives me an error. New script:
    Click to view content: 
    declare_counter EnglandImmortalRecruited

    monitor_event FactionTurnEnd FactionIsLocal
    if I_CompareCounter EnglandImmortalRecruited = 0
    spawn_army
    faction spawnpool
    character Immortal, named character, age 18, x 96, y 145
    unit Peasants exp 0 armour 0 weapon_lvl 0
    end
    give_everything_to_faction spawnpool england false
    inc_counter ImmortalRecruited 1
    end_if
    end_monitor

    monitor_event FactionTurnEnd FactionIsLocal
    if I_compareCounter EnglandImmortalRecruited = 1
    not I_CharacterExists Immortal
    spawn_army
    faction spawnpool
    character Immortal, named character, age 18, x 96, y 145
    unit Peasants exp 0 armour 0 weapon_lvl 0
    end
    give_everything_to_faction spawnpool england false
    end_if
    end_monitor

    Error log:
    Click to view content: 
    17:05:38.934 [game.script] [error] Script parsing error at line 8, column 46 in mods/Bare_Geomod/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    Unrecognised unit data string ()
    17:05:38.934 [game.script] [error] Script parsing error at line 11, column 2 in mods/Bare_Geomod/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    Couldn't create a script from file mods/Bare_Geomod/data/world/maps/campaign/imperial_campaign/campaign_script.txt

  11. #11
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Counters and Spawning

    Code:
    if I_compareCounter EnglandImmortalRecruited = 1
      and not I_CharacterExists Immortal
    Also, check your "unit" lines. There should be a tab between "Peasants" and "exp", not spaces. That might be the cause of the error.

  12. #12
    Centenarius
    Join Date
    Jun 2012
    Location
    American president, Spanish conquistador, Italian cartographer
    Posts
    848

    Default Re: Counters and Spawning

    I added the 'and' in the second monitor and fixed the spacing. Now it says:

    17:48:53.752 [game.script] [error] Condition parsing error in mods/Bare_Geomod/data/world/maps/campaign/imperial_campaign/campaign_script.txt, at line 16, column 5
    Condition parser doesn't recognise this token: I_compareCounter

    Edit: I should have noticed the lowercase. That part is fixed now, but the script still doesn't work. There is no error in the log.
    Last edited by Firey the Unorthodox; September 01, 2012 at 09:59 PM.

  13. #13
    Centenarius
    Join Date
    Jun 2012
    Location
    American president, Spanish conquistador, Italian cartographer
    Posts
    848

    Default Re: Counters and Spawning

    I decided to make my script simpler to at least make the character spawn. I used the files from the Unique names tutorial. I tried it with England and France but it didn't work. It doesn't give me an error in the log either. The spacing is correct in my script. Copy of script:
    Spoiler Alert, click show to read: 
    monitor_event FactionTurnEnd FactionIsLocal
    spawn_army
    faction spawnpool
    character spA, named character, age 18, x 96, y 145
    unit Peasants exp 0 armour 0 weapon_lvl 0
    end
    give_everything_to_faction spawnpool england false
    end_monitor

    As a side note, my English spy had some portrait problems. It would start out with no portrait in the unit selection and a black background where a portrait would normally be. Whenever I clicked a unit then went back to the spy, the spy would have that unit card picture and portrait.
    Last edited by Firey the Unorthodox; September 02, 2012 at 05:37 PM.

  14. #14
    Centenarius
    Join Date
    Jun 2012
    Location
    American president, Spanish conquistador, Italian cartographer
    Posts
    848

    Default Re: Counters and Spawning

    I forgot to add 'script' and 'end_script.' It still doesn't work, but at least it gives me an error.
    Full script:
    Spoiler Alert, click show to read: 
    script
    monitor_event FactionTurnEnd FactionIsLocal
    faction spawnpool
    spawn_army
    character spA, named character, age 18, x 96, y 145, direction S
    unit Peasants exp 0 armour 0 weapon_lvl 0
    end
    give_everything_to_faction spawnpool england false
    end_script

    Error:
    Spoiler Alert, click show to read: 
    08:58:52.271 [game.script] [error] Script parsing error at line 3, column 1 in mods/Bare_Geomod/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    don't recognise this token: faction
    08:58:52.271 [game.script] [error] Script parsing error at line 5, column 1 in mods/Bare_Geomod/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    Couldn't create a script from file mods/Bare_Geomod/data/world/maps/campaign/imperial_campaign/campaign_script.txt

  15. #15
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Counters and Spawning

    spawn_army
    faction spawnpool

  16. #16

    Default Re: Counters and Spawning

    If you let me join your thread i would like to ask about my very weird problem. I made very simply script which should add an army at start of a game:
    PHP Code:
    monitor_event FactionTurnStart FactionIsLocal
        
    and I_TurnNumber 0
            spawn_army
                faction egypt
    character    Jobst Friedrich Steffen
    named characterage 16x 256y 265 
        traits GoodCommander 2 
    Drink 1
                unit European bodyguard        exp 1
    armour 0weapon_lvl 0
                unit Musketerare            exp 1
    armour 0weapon_lvl 0
                unit Musketerare            exp 1
    armour 0weapon_lvl 0
                unit Musketerare            exp 1
    armour 0weapon_lvl 0
                unit Musketerare            exp 1
    armour 0weapon_lvl 0
                unit Swedish pikemen        exp 1
    armour 0weapon_lvl 0
                unit Swedish pikemen        exp 1
    armour 0weapon_lvl 0
                unit Swedish pikemen        exp 1
    armour 0weapon_lvl 0
                unit Kirasjerzy                exp 1
    armour 0weapon_lvl 0
                unit Kirasjerzy                exp 1
    armour 0weapon_lvl 0
    end
        terminate_monitor
    end_monitor 
    Log sayd:
    PHP Code:
    don't recognise this token: and 
    I thought i don't need line with the number of turn, so i erased this line. Unfortunately, script still doesn't work. This time log says:
    don't recognise this token: end_monitor
    I'm completly confused. I made hundreds of scripts similar to this and it allways worked, but i have no idea what's wrong now.

  17. #17

    Default Re: Counters and Spawning

    As usually. Making from scratch was very helpfull

Posting Permissions

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