Page 1 of 3 123 LastLast
Results 1 to 20 of 51

Thread: Script Validator

  1. #1

    Default Script Validator

    Hey all,

    This tool will help you when you're working on a script for RTW (maybe I'll do an M2 version later). It checks your script for any errors. And if it found some error(s), it will tell you where to find them, so you can easily fix it.
    Of course the tool doesn't know what you intend to do with your script, so even if you didn't make any syntax errors, it can still be that the script doesn't work as you had in mind it should be working.

    here's how it looks:



    The tool is still a work in progress, which I will update every now and then. So this means it doesn't fully support all possible script combinations yet. However it does check the basics of a script already including:

    • Version 1.0:
      • Spelling of commands
      • Spelling/presence of events
      • Spelling/presence of conditions
      • If a counter has been declared before use
      • The syntax of inc_counter and set_counter commands
      • Console commands
      • Syntax of monitors
      • Syntax of Ifs
      • Syntax of Whiles
      • Syntax of Ands
      • Syntax of the spawn_army section

    • Version 1.1:
      • Allows to check for factions names in most circumstances:
        • Names are loaded from descr_sm_factions.txt
        • Console_commands not yet supported
        • You can not yet manually edit the factions. So the list with factions you get to see is just for your own reference...
        • Even though the slave faction is not listed amongst the other factions, it won't be forgotten in the check

      • Now properly checks the spawn_army section so it allows multiple units in one army
      • It now properly remembers your previously loaded script
        (and descr_sm_factions.txt as well of course)

    • Version 1.2:
      • Now properly recognizes every comparison token (eg ">=" is now allowed as well)
      • You now can change the factions by editing them in the textboxes
      • Some more minor fixes

    • Version 1.3:
      • You can now check for region name errors by loading descr_regions.txt. (Thanks to HouseOfHam and his Settlement Coordinate Locator)
        (only for the conditions: I_SettlementExists and I_SettlementOwner)
      • Fixed a bug with the "Script continues for x lines after being ended" while there were no lines after the "end_script" command anymore.


    I hope to add a lot lot lot more in future... But I have the basics ready now (like the full lists of possible commands, events, conditions and console commands) so it's just about adding very minor things like a function to check the syntax of a command like "engage_armies" or checking the syntax of the add_money console command etc.

    As you can see on the screen above, there are three bullets which you can select: "Check entire script", "Check script from line X to line Y" and the last one "Check an entire monitor starting at line X".
    The first two are fully working already, so you can savely use those. However about the last one I'm not entirely sure yet if it does what it's supposed to do. The purpose of that one was so you can quickly check one monitor which you are working on without having to check the entire script. But better not use this one yet.
    The check is pretty fast anyway, so while you're at it, I think it's just as easy to run a full scan

    Oh, I almost forgot... With the button in the top-right ("...") you can select the script you want to check and with the button next to it ("->") you can reload it after you made changes to it so you can continually check your script while you're working on it.
    The bar/drop-down menu next to it doesn't fully work yet unfortunately... I hope to be able to fix that soon

    DOWNLOAD (v1.3)

    Have fun
    Last edited by Pat89; September 18, 2010 at 05:49 AM. Reason: Update for v1.3

  2. #2

    Default Re: Script Validator

    Very, very nice!

  3. #3
    hannibalcaesar's Avatar Mostly Retired Modder
    Join Date
    Jun 2009
    Location
    USA
    Posts
    853

    Default Re: Script Validator

    This should help a unexperienced script like me get mine working .

  4. #4

    Default Re: Script Validator

    Awesome Pat !

    Though I did get an undefined line :

    [509]|Line: ??? - 2 if statement(s) found with no matching end_if
    Last edited by Killerbee; February 21, 2010 at 04:29 AM.

  5. #5

    Default Re: Script Validator

    Thanks

    I actually did that intentional... Because you never know for sure which end_if belongs to what if. If the toll finds an if statement, it doesn't know if the end_if should be directly at the first line or all the way down at the last line of the script.

    And if you for example have this script:
    Code:
    if Santa = 50 years old
        if I_TurnNumber = 30
            ; effects
        ; accidentally commented out end_if
        concole_command toggle_fow
    end_if
    Then the validator would think the blue end_if belongs to the green if because it is the first end_if after that if statement. However in fact the green end_if belongs with the green if.

    However if you have this script:
    Code:
    if Santa = 50 years old
        if I_TurnNumber = 30
            ; effects
        end_if
        concole_command toggle_fow
    ; accidentally commented out end_if
    Then you will get the same error as with the above example. So I don't know how I can make this more user-friendly to at least give an indication where the error should be somewhere...

    Suggestions are mostly welcome of course

  6. #6

    Default Re: Script Validator

    Yes, already thought it was something of that kind, but thanks for the backup

    Will have to take a look at the script manually then. *gasp* 8051 lines *gasp*

  7. #7

    Default Re: Script Validator

    Sorry

    Btw:
    [509]|Line: ??? - 2 if statement(s) found with no matching end_if
    Did you really have 509 errors?

  8. #8

    Default Re: Script Validator

    So, we all have our talents, and mine obviously isn't scripting !

    No, on a serious note, those are all the same "error", and I'm pretty sure they're not errors. This is my error :

    [1]|Line: 6649 - unrecognized command: unit
    And this is the line and the command involved around it :

    Code:
    console_command kill_character "Brennus"
    spawn_army
    faction britons
    character Brennus, general, age 27, x 241, y 100
    unit spartan generals bodyguard, exp 2 armour 1 weapon_lvl 0
    unit hippeis xenophontos, exp 5 armour 1 weapon_lvl 1 ; 6649
    unit spartan hoplite, exp 1 armour 2 weapon_lvl 2
    unit spartan hoplite, exp 1 armour 2 weapon_lvl 2
    unit spartan hoplite, exp 1 armour 2 weapon_lvl 2
    unit spartan metoikoi hoplite, exp 1 armour 2 weapon_lvl 2
    unit spartan metoikoi hoplite, exp 1 armour 2 weapon_lvl 2
    unit spartan ekdromoi hoplite, exp 1 armour 2 weapon_lvl 2
    unit spartan heavy phalangites, exp 1 armour 2 weapon_lvl 2
    unit spartan heavy phalangites, exp 1 armour 2 weapon_lvl 2
    unit spartan heavy phalangites, exp 1 armour 2 weapon_lvl 2
    unit spartan perioikoi phalangites, exp 1 armour 2 weapon_lvl 2
    unit greek levy pikemen, exp 1 armour 2 weapon_lvl 2
    unit thureophoroi, exp 1 armour 2 weapon_lvl 2
    unit thureophoroi, exp 1 armour 2 weapon_lvl 2
    unit agema elite phalangite, exp 1 armour 2 weapon_lvl 2
    unit agema elite phalangite, exp 1 armour 2 weapon_lvl 2
    unit greek archer, exp 1 armour 2 weapon_lvl 2
    unit greek archer, exp 1 armour 2 weapon_lvl 2
    unit onager, exp 1 armour 2 weapon_lvl 2
    end
    console_command kill_character "Brennus"

  9. #9

    Default Re: Script Validator

    Ah, that makes sense why you have so many errors if that counts as one

    Hmm... Very strange, because I don't receive that as error...

    Oh!
    I didn't thought of that fact that someone might actually list more than one "unit"

  10. #10

    Default Re: Script Validator

    Quote Originally Posted by PatricianS View Post
    Ah, that makes sense why you have so many errors if that counts as one

    Hmm... Very strange, because I don't receive that as error...

    Oh!
    I didn't thought of that fact that someone might actually list more than one "unit"
    Already thought so, since it always was the second unit in the list

  11. #11

    Default Re: Script Validator

    I uploaded v1.1

    It should now properly check the spawn_army section. I also added the function to check the factions in the script plus some other changes listed in the OP.

    Oh and some UI improvements but I didn't list those because it's just for the eye/user-firendlyness

  12. #12

    Default Re: Script Validator

    aweomse work Pat ! Only have 1 error now

    It's actually 2, but I'm not sure if this counts :

    Code:
    [2]|Warning - the script continues for another 1 line(s) after the script has been terminated at line 8085

  13. #13

    Default Re: Script Validator

    No, that warning is not an error... It's just so you know something is wrong if it says 500 for example

    (Though if you want to get the message that no errors have been found (good for you ego ), then you should have to remove that line after the end_script thing as well )

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

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

    Default Re: Script Validator

    Quote Originally Posted by PatricianS View Post
    Thanks

    I actually did that intentional... Because you never know for sure which end_if belongs to what if. If the toll finds an if statement, it doesn't know if the end_if should be directly at the first line or all the way down at the last line of the script.

    And if you for example have this script:
    Code:
    if Santa = 50 years old
        if I_TurnNumber = 30
            ; effects
        ; accidentally commented out end_if
        concole_command toggle_fow
    end_if
    Then the validator would think the blue end_if belongs to the green if because it is the first end_if after that if statement. However in fact the green end_if belongs with the green if.

    However if you have this script:
    Code:
    if Santa = 50 years old
        if I_TurnNumber = 30
            ; effects
        end_if
        concole_command toggle_fow
    ; accidentally commented out end_if
    Then you will get the same error as with the above example. So I don't know how I can make this more user-friendly to at least give an indication where the error should be somewhere...

    Suggestions are mostly welcome of course
    If you're trying to get the program to behave more logically in terms of if/end_if lines, etc, then you'll need to parse the files as if they are a context-free grammar. For the second example it will still not find the missing end_if until the end of the code block its in (i.e. the current monitor or script, etc), but this is normal for most programming languages.
    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

  15. #15

    Default Re: Script Validator

    Finally!! A script Validator! Thank you very much for this tool!

    I have just downloaded and used with my scripts, and it detects these 2 errors:

    1- "unrecognized comparison sign: <=", in this line:
    Code:
    and I_NumberOfSettlements romans_julii <= 5
    Latest time I tested this condition was working, and I use this sign "<=" many times in my scripts without problems. Do you know any possible cause for the error?

    2- "and statment has no conditions or events listed", in many lines like this one:
    Code:
    and GarrisonSettlementRatio < 0.8
    I have no idea if this condition is really working, I'll verify it. But it is listed in the docudemon.

    I'll keep checking this topic
    Last edited by Bardo; February 24, 2010 at 01:19 AM.

  16. #16

    Default Re: Script Validator

    Ok thanks for the note!

    The first one is a bug in the validator for sure. And the second as well btw...

    I'll look into it

  17. #17

    Default Re: Script Validator

    I think something went wrong when compiling the docudemon list. Because for that command it sais the following:
    Code:
    ---------------------------------------------------
    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
    ---------------------------------------------------
    So what is it? "GarrisonToPopulationRatio" or "GarrisonSettlementRatio"


  18. #18

    Default Re: Script Validator

    I uploaded v1.2. Please see the OP for the details

    (I fixed the first error Bardo mentioned, but not yet the second one, because I'm not sure yet if that's an error in the validator or in the docudemon list)

    Sorry for the triple post btw

  19. #19

    Default Re: Script Validator

    Take the 'sample use' one methinks

    But it's mostly testing I assume. Like :

    Code:
    if GarrisonSettlementRatio < 1 ; and just give that city a population of 15000 or so.
    console_command add_money 10000
    end_if
    or

    Code:
    if GarrisonToPopulationRatio < 1 ; and just give that city a population of 15000 or so.
    console_command add_money 10000
    end_if
    Oh, and could you please add the line of the if ? I has this :

    [1]|Line: ??? - 1 if statement(s) found with no matching end_if
    Wouldn't it be easier if I could see which 'if' it was ?
    Last edited by Killerbee; February 24, 2010 at 08:55 AM.

  20. #20

    Default Re: Script Validator

    Great work

    I wonder whether this is a bug:

    "unit statement found without matching spam_army section"

    This probably ought to be "spawn_army"


    Under patronage of Spirit of Rob; Patron of Century X, Pacco, Cherryfunk, Leif Erikson.

Page 1 of 3 123 LastLast

Posting Permissions

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