User Info
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 02, 2010, 08:04:01 PM

Login with username, password and session length
Search:     Advanced search
News Box
New M&B Version

1.010 is out, and so is the module system. Get modding!

Key Stats
51617 Posts in 2003 Topics by 4425 Members
Latest Member: lovely13
Home Help Search Login Register
M&B Mod Community  |  About Modding  |  Discussion (Moderator: Fisheye)  |  What is this error about?
Pages: [1] Print
Author Topic: What is this error about?  (Read 575 times)
Cirdan
Craftsman
**
Offline Offline

Posts: 100


View Profile Email
« on: February 20, 2008, 08:47:24 AM »

This seemingly harmless and rather insignificant code snippet:

[anyone, "tavernkeeper_give_tournament_info", [(neg|eq, "$tournament_town", 0),
                                                                                                                   (assign, reg7, "$tournament_town"),      
                                                                                                                   (assign, reg8, "$tournament_fee"),
                                                                                                                   (assign, reg9, "$days_till_tournament"),
                                                                                                                  ],
           "The Lord and Lady of {reg7} have invited all knights of noble birth to demonstrate their prowess to them,\
            {reg9} days from now. The knights will be expected to wage {reg8} pounds on their success.",
           "tavernkeeper_pretalk",[]]


Has led me to this failed assertion:


I can stop the error by changing the formatting to this:
[anyone, "tavernkeeper_give_tournament_info", [(neg|eq, "$tournament_town", 0),
                                                                                                                   (assign, reg7, "$tournament_town"),
                                                                                                                   (assign, reg8, "$tournament_fee"),
                                                                                                                   (assign, reg9, "$days_till_tournament"),
                                                                                                                  ],
"The Lord and Lady of {reg7} have invited all knights of noble birth to demonstrate their prowess to them,\
{reg9} days from now. The knights will be expected to wage {reg8} pounds on their success.", "tavernkeeper_pretalk",[]],




However, I still have no idea whatsoever as to the reason why such a minor difference in formatting would lead to an error when starting the game, while Module System's compiler seems unaffected. Would someone please explain this to me?
Logged
Ron Losey
Master
*****
Offline Offline

Posts: 4481


View Profile Email
« Reply #1 on: February 20, 2008, 06:46:37 PM »

Probably the lack of a comma at the end of the line.  Thereby causing it to run the entire rest of the page into that one line, and so improperly process the entire rest of the script file.
This seemingly harmless and rather insignificant code snippet:

[anyone, "tavernkeeper_give_tournament_info", [(neg|eq, "$tournament_town", 0),
                                                                                                                   (assign,
....

            {reg9} days from now. The knights will be expected to wage {reg8} pounds on their success.",
           "tavernkeeper_pretalk",[]]
,


Leaving out that last comma will kill you every time ... and usually in ways that are hard to find, unless you knew exactly what you changed just before the error appeared.
Logged
Cirdan
Craftsman
**
Offline Offline

Posts: 100


View Profile Email
« Reply #2 on: February 21, 2008, 07:10:37 AM »

Urrr...sorry to disapoint, but that's actually a copy-paste error. I checked the backup of the buggy code I made (to paste here after I'd fixed it) and it definately has it, I just missed the comma when posting on the forums :-[ And yes, I know how stupid not even being able to ask for advice properly looks  :-[
Logged
Ron Losey
Master
*****
Offline Offline

Posts: 4481


View Profile Email
« Reply #3 on: February 21, 2008, 08:33:32 AM »

Oops, well, I tried.

Actually, in M&B Python code, most inexplicable errors boil down to a missing bracket or comma ... much more often than they are actually something complicated.  So that's usually the first place to look - or the place where someone fixes the problem accidentally and never figures out what they did.

But that is truly bizarre - it only prints the strings in the same order as they were assigned, but if you rearrange them, they go nuts?  This sounds like programming right out of a "Dilbert" cartoon - "it's a token LAN network, and the token fell out and is somewhere in the room"....

I guess we can chalk that one up to another inexplicable quirk.... Didn't Winter or somebody have a thread where they were collecting stuff like this?
Logged
Cirdan
Craftsman
**
Offline Offline

Posts: 100


View Profile Email
« Reply #4 on: February 21, 2008, 09:02:34 AM »

Eh--I've had my fair share and more of errors due to missing commas. In fact, that's the first thing I look for (unless I know what's wrong, of course) when I see an error; and in part that's why the above problem took me ages to fix. I couldnt see a missing comma (or bracket, or anything), so I selectively commented out portions of code I had added since my last successful compile and run, until I had located the error as being in that dialog and found the operations block to be innocent. Then I looked at it again...and again...and again...and the only difference I could find with Native's dialogs was longer lines of text and the fact that I had the last elements on another line from the string. So I just re-arranged them on a hunch. Must be some bizarre quirk preventing it from reading the last line in the first case, but yes, it's a totally Dilbertian error. I'd hire Dogbert to fix it, but I can't afford a consultant's wages :-\
Logged
Pages: [1] Print 
Jump to:  

Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Arcane Magic based on BlackDay by TechnoDragon.net | Buttons by Andrea