Author Topic: Quick question on local variables and scripts  (Read 757 times)

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #30 on: August 27, 2011, 11:44:37 pm »


               <Keeps a sharp eye peeled...>

What he said :-) Though I would explicitly state in each trap whether it was set or not.
And, at the very least, I would first put traps in your Area's OnEnter.

<...for errant bits and pieces>
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #31 on: August 27, 2011, 11:58:22 pm »


                <shakes his head sadly...>

Sorry, no arrays in NWScript. And now that I've read Skywing's blog, I understand why :-/ R.I.P.
Unfortunately, that implies that pseudo-arrays would be unwieldy and inefficient. (Don't know that for sure, Funky might :-)

I would stick with integers. In fact, I *am* sticking with integers, but my travel is complicated even more-so as there are 8 versions of all the main areas... Yikes.

<...and holds his big, ugly, floppy hat over his shrivelled excuse for a heart>
               
               

               
            

Legacy_Alassirana

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #32 on: August 28, 2011, 12:03:44 am »


               Um, according to the nwn lexicon (v 1.69) there is a function entitled:  GetLocalArrayInt  And it seems to be saying that I am actually trying to get an array here...I just don't understand it all.
               
               

               
            

Legacy_Alassirana

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #33 on: August 28, 2011, 12:04:38 am »


               And, of course, it is paired by it's opposite:  SetLocalArrayInt.
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #34 on: August 28, 2011, 12:13:38 am »


               <biting down hard...>

Alassirana wrote...

Um, according to the nwn lexicon (v 1.69) there is a function entitled:  GetLocalArrayInt  And it seems to be saying that I am actually trying to get an array here...I just don't understand it all.


Yes, but that is a pseudo array. Using a naming convention to make it more convenient to manage variables, basically.

Although this is hardly an array, it can be accessed like one, and can even be
looped through. It works by creating a new local integer object on whatever
object you passed in through the parameters. This LocalInt is called sVarName +
nVarNum, so in otherwords if I called the following:...

IOW, it's using a function to name and manage variables... adding another layer of work for the script to do.

<... to see if it's gold>
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #35 on: August 28, 2011, 03:55:05 am »


               Actually I think your problem is much more simple. And I think Rolo mentioned it. The line in the conversation  should only show up if the variable is on the item right? Like if you've been to disneyland the variable gets set on your item and then when the conversation pops up you should be able to see the "disneyland" line? The highlighted TRUE and FALSE below need to be switched (I already switched them in the script).


int StartingConditional()
{
    // Get the PC who is involved in this conversation
    object oPC = GetPCSpeaker();
    object oPButton = GetItemPossessedBy(oPC, "panicbutton");
    int iFokual = GetLocalInt(oPButton, "Fokual");
    if (iFokual == TRUE)
        return TRUE;

    // If we make it this far, we have passed all tests.
    return FALSE;
}


For the life of me I could not wrap my head around starting conditionals for the longest time. And it wasn't until someone scripted one a certian way that I was able to understand them. Now I know how to do them a bit different but this way made it easy for me. Maybe it will help you:


int StartingConditional()
{
    if (some condition == whatever)
    {
        return TRUE;//Show this line in conversation
    }

    else
    {
        return FALSE;//Don't show this line in conversation
    }
}
               
               

               


                     Modifié par GhostOfGod, 28 août 2011 - 03:14 .
                     
                  


            

Legacy_Alassirana

  • Full Member
  • ***
  • Posts: 103
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #36 on: August 28, 2011, 01:02:33 pm »


               That fixed it...thanks.
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Quick question on local variables and scripts
« Reply #37 on: August 28, 2011, 04:03:43 pm »


               <blushes...>

GhostOfGod wrote...

Actually I think your problem is much more simple. And I think Rolo mentioned it. The line in the conversation  should only show up if the variable is on the item right? Like if you've been to disneyland the variable gets set on your item and then when the conversation pops up you should be able to see the "disneyland" line? The highlighted TRUE and FALSE below need to be switched (I already switched them in the script).

You ever scan something and your mind (because it *knows* what goes where) let you see something that *isn't* what was writtien?

How did I miss that? I *know* that's a common fault (of mine!) and I specifically scan for that (in my own debugging)... But this time I just skipped over it...

I'm getting old :-(

<...or *tries* to>