Results 1 to 6 of 6

Thread: Really annoying source of script problems

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Really annoying source of script problems

    I thought to share an experience that may help in some situations. I've been working on a long background script that recently started causing a problem. The advisor started popping up in the beginning of battles (in campaign map) with vanilla advice even if unscripted advice is suspended with "suspend_unscripted_advice true". I knew something was wrong.

    I tried and tried to find an error in the script, but couldn't. Squid's TW script editor did not find any problem. I removed big chunks of rows to go "back in time" when there was no problem. Testing was not easy, as the non-wanted advice did not appear every single time a battle was about to start, perhaps 50 % only.

    I had tested the script extensively up to a certain point earlier and there had not been any problems. This time this problem with the advisor remained even when I removed all the parts I had written myself and only the parts copied directly from HouseOfHam's background script tutorial remained!

    So I thought that the problem has to be elsewhere. I looked at the advice, ancillaries and traits I had added, and the descr_strat.txt, but could not find any problem in those parts I had added recently (before the problems started).

    Finally I went through the files with hidden characters displayed and I found out that a few rows in export_advice.txt were separated only with "LF" instead of "CR LF". I repaired that and now the whole srcipt functioned without problems again! (well not quite, but that is not so important, see last parts *** of this message)

    I don't have any idea what had caused the problem. I'm using Notepad ++ and had included this part by copying another existing part and modifying it. I am sure that I had copied it either from Notepad ++ or the plain Notepad, not from any other word processor. I could not repeat the problem with either of them, when tried to copy-paste afterwards.

    I would have never found this problem if I had not checked the new parts with hidden chars visible. I thought to do that, since I had notice something similar at some point earlier. But had then thought that it was just something rare. Apparently this may happen quite easily and cause really a trouble with scripts.

    Any thoughts on this?

    *** And another observation: after discovering this problem, there was still one problem in the script. I had accidentally declared the same counter twice in separate locations (and set it to zero in both locations). When I removed the latter part (declaration + setting to zero), the full script functioned well. But Squid, this problem was not detected by your editor, is it a "bug"?

  2. #2
    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: Really annoying source of script problems

    For the LF instead of CRLF that could happen for any number of reasons none of which is you setting it that way. As for the counter issue, the editor currently does not check for duplicate counters. For the most part it just checks that script/console commands are spelled correctly and that the conditions have appropriate values. Adding more checking to other areas is forthcoming, but it is slow.
    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

  3. #3

    Default Re: Really annoying source of script problems

    Quote Originally Posted by Squid View Post
    For the LF instead of CRLF that could happen for any number of reasons none of which is you setting it that way. As for the counter issue, the editor currently does not check for duplicate counters. For the most part it just checks that script/console commands are spelled correctly and that the conditions have appropriate values. Adding more checking to other areas is forthcoming, but it is slow.
    OK, I was hoping though that I had done something wrong (so that I could avoid it in the future :-).

    I understand that the editor cannot take everything into account (at least yet). Just thought to let you know in case you had not ran into this problem. It is a great editor anyway!

  4. #4

    Default Re: Really annoying source of script problems

    This problem with LFs is really annoying! I get it every now and then and spend huge amounts of time trying to figure out what is wrong in script. And there are a few LFs in advice files and nothing wrong with the script... Why do they appear sometimes, and sometimes not? Using Notepad++/Win7.

  5. #5
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Really annoying source of script problems

    Mmm... could be save options and/or if you copy-n-paste from other programs.

    Default line terminator:
    Windows - CRLF
    Unix - LF
    Mac - CR
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  6. #6

    Default Re: Really annoying source of script problems

    Quote Originally Posted by HouseOfHam View Post
    Mmm... could be save options and/or if you copy-n-paste from other programs.

    Default line terminator:
    Windows - CRLF
    Unix - LF
    Mac - CR
    I've not changed the defaults and I'm not using other program to copy-paste. I only write new lines and sometimes copy-paste sections from the same file to another place in the same file and edit the new text then. Strange... and annoyint since there seems to be no logic...

Posting Permissions

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