Skip to content

What is wrong with my syntax?

karnagekarnage Member Posts: 92
I have looked, compared, and tried several variations, but I keep getting "syntax error" or "trigger not recognized".

// =========== REJOINED AFTER KICKED OUT =====================
// This series of exchanges describes rejoining the party after being kicked out.

IF ~Global("zkwHughBooted","LOCALS",1)~ THEN BEGIN CameBack
SAY ~Hi! Have you changed your mind?~
IF ~~ THEN REPLY ~Yes. We have had a change of heart. We would like you to join our party.~ GOTO Rejoined
IF ~~ THEN REPLY ~Yeah, but I still don't want you in the party.~ GOTO RefusedAgain
END

Comments

  • TwaniTwani Member Posts: 640
    You'll probably want GLOBAL instead of LOCALS for that variable, and you're using the long, old cold when you could be using the newer code. (just THEN, not THEN BEGIN', just ++ rather then IF ~~ THEN REPLY.) I'd take a look at Branwen's code, on pocket plane group, if I were you. This way is more typing for yourself.

    I don't think either of that should crash the game, though. If the syntax error is in the first line, often the error is actually with the block before it. Are you perhaps missing an END, or forgetting a quotation mark in an exit variable?
  • karnagekarnage Member Posts: 92
    I pulled up Branwen on PocketPlane.net; happy to have found such a mod as I wanted Branwen in BG2; this sure saved me the work and may teach me a thing or two as well.

    Funny thing is, I compared my syntax above to Keldorn's script and I am at a total loss still ...

    Thanks for your input!
  • karnagekarnage Member Posts: 92
    Also, thinking about your suggestion about making the variable "global" rather than "local"; This part of the script is in the zkwhugh file. Another part of the script, which sets the variable to 1 when he's kicked out, is, of course, in the zkwhughp file. So as different files are involved, does that precipitate to the variable needing to be global?

    I understand when variable need to be local or global when different subroutines need to access the same variable and I understand the passing of variables (I am quite good at programming with Visual Basic for Applications) but using that knowledge for WeiDu eludes me.
  • WispWisp Member Posts: 1,102
    Global variables are stored in the GAM file and can be accessed by anything everywhere. Local variables are stored in the CRE structure of the creature that sets the variable and can only be accessed by the same creature. I'm pretty sure using local variables for your NPC is fine (so long as no one and nothing else needs to check on them), provided you never destroy the instance of your creature and create another (because the new instance will not contain the local variables).
  • karnagekarnage Member Posts: 92
    Okay. Now THAT makes sense.

    I had assumed that GLOBALS could be accessed by any script, etc. (as that is the rules with most freeform programming languages, like C++, and this is C++ based).

    LOCALS, however, had me thrown a bit. As LOCALS are seeable only by the subroutines that created/defined them, those remain slightly unclear ....

    So, as "locals" are stored with the CRE file, does that correspond to the CRE's dialog files as well?

    In short, can the LOCAL defined in the J file be seen by the D file as well?

    btw, I think the Branwen mod is going to be very helpful. The one who put that together explained everything; I think they spent more time tutoring than they did programming, LoL.
  • karnagekarnage Member Posts: 92
    edited January 2014
    ... I think I answered my own question ...

    yes, because the locals are stored with the creature itself, not with a script ...

    ... Correct?

    My script:
    IF ~Global("zkwHughBooted","LOCALS",1)~ THEN BEGIN CameBack

    Keldorn's Script:
    IF ~Global("KeldornMove","GLOBAL",1)
    Dead("bheye")
    ~ THEN BEGIN 11 // from:
    SAY #8428 /* ~Welcome to the guildhouse of my Order, old friends. It seems you fared better than I in those sewers -- I felt the evil below me fade, which is well. Tell me, how might I be of service to you?~ [KELDOR83] */

    Branwen's Script:
    IF ~Global("O#BranToBKickedOut","GLOBAL",1)~ b2


    Where is the difference!?

    I don't see it.

    Refuses to compile.

    ~syntax error
    ~trigger ~global~ not recognized
    Post edited by karnage on
  • karnagekarnage Member Posts: 92
    ... except "global" vs. "locals" ...
    ... I'll try that ...
  • karnagekarnage Member Posts: 92
    Nope.

    But this time, it's not giving me much to go on, but enough that maybe, my syntax error isn't where I thought it was:

    [zkwmods\Hugh\zkwhugh.d] PARSE ERROR at line 74 column 1-60
    Near Text: (
    syntax error

    [zkwmods\Hugh\zkwhugh.d] ERROR at line 74 column 1-60
    Near Text: (
    Parsing.Parse_error
    ERROR: parsing [zkwmods\Hugh\zkwhugh.d]: Parsing.Parse_error
    ERROR: compiling [zkwmods\Hugh\zkwhugh.d]!
    Stopping installation because of error.

    I'll try again tomorrow, beginning by commenting out sections then uncommenting until the corrupt block is located/confirmed.
  • karnagekarnage Member Posts: 92
    @twani @wisp
    Ach! I found my errors. (Yes, plural). They weren't in the block posted, but in the next block.

    1. Old habits die hard! I had SAY ~blah blah blah"
    2. I had a command after SAY ~blah blah blah~ Do xxxx

    Silly me. Thanks for your patience, and sorry to be a bother ...
  • TwaniTwani Member Posts: 640
    Believe me, that happens all the time. I once spent four hours going crazy over a syntax error only to find that I had simply missed an END after a block (which is why I asked about that, as it's one of the more simple mistakes to make). By the time you're done with your NPC, you'll have found a dozen syntex errors, especially if you go from CHAIN (to make other NPC's interject) to the normal APPEND/SAY. It's just the way coding works, but you'll solve em all in time. :)

    Good luck with your NPC!
  • karnagekarnage Member Posts: 92
    Yeah, and the "learn by error" system drives me nuts, LoL. I can't find anywhere where the syntax rules are spelled out for beginners, like you would find in a textbook at a programming class. Instead, I just keep stumbling along ... I can't say that I'm enjoying the process, but I am enjoying the end results.
  • TwaniTwani Member Posts: 640
    Have you seen this tutorial?

    https://docs.google.com/document/d/1ZNVRttHGVV8GOQ-CYWyTMHh-3MErQ1T_KusJkCtYtk0/edit?pli=1#heading=h.2y496ribckav

    More specifically, the Syntax Highlighter for Notepad++? It's been a major help for me. Using it, you'll notice the font will go different if you make obvious screwups, like leaving out a ~ somewhere or even missing a quotation mark. It won't solve everything, but it does sense your most common mistakes, and once you see, say, your comment text no longer turning green, you'll know that you messed up on a syntax somewhere before it. It's helped me a lot.

    There is no real textbook/tutorial, I agree. Sometimes simple things, like trying to check for class throw me back in desperately searching NPC mods/the regular dialog files to find an instance of it, because no one's just made a tutorial that fully explains how to race check, class check, alignment check, gender check, race check all in one place. And then there's the whole CHAIN/APPEND. If Branwen NPC hadn't explained it so well in her first dialog file, I'd probably still be lost with that.
  • MacMonkeyMacMonkey Member Posts: 6
    Just found this post. Thank you for the link! Big Help!!!!
    Between this and Branwen my NPC might have a chance. ;)
    MM
Sign In or Register to comment.