1. SPS Accounts:
    Do you find yourself coming back time after time? Do you appreciate the ongoing hard work to keep this community focused and successful in its mission? Please consider supporting us by upgrading to an SPS Account. Besides the warm and fuzzy feeling that comes from supporting a good cause, you'll also get a significant number of ever-expanding perks and benefits on the site and the forums. Click here to find out more.
    Dismiss Notice
Dismiss Notice
You are currently viewing Boards o' Magick as a guest, but you can register an account here. Registration is fast, easy and free. Once registered you will have access to search the forums, create and respond to threads, PM other members, upload screenshots and access many other features unavailable to guests.

BoM cultivates a friendly and welcoming atmosphere. We have been aiming for quality over quantity with our forums from their inception, and believe that this distinction is truly tangible and valued by our members. We'd love to have you join us today!

(If you have any problems with the registration process or your account login, please contact us. If you've forgotten your username or password, click here.)

Global Variables

Discussion in 'Neverwinter Nights (Classic)' started by Pyro, Jan 29, 2003.

  1. Pyro Gems: 5/31
    Latest gem: Andar


    Joined:
    Mar 8, 2002
    Messages:
    119
    Likes Received:
    0
    I dont understand how to make, set and check "if" with global variables, I know how to do with locals, can anyone explain this to me?
     
  2. Errol Gems: 23/31
    Latest gem: Black Opal


    Joined:
    Oct 23, 2001
    Messages:
    1,547
    Likes Received:
    0
    Gender:
    Male
    [​IMG] Okay, make a conversation like this:

    [OWNER] - Hello, I've spoken to you once.

    Select it, goto Actions Taken tab, and press the Wizards hat. Now choose Set Local Variables, and name your Variable. Give it the number 1.
    Make another line of Conversation above.

    [OWNER] - Hello again!
    [OWNER] - Hello, I've spoken to you once.

    And for the top line, click the Text Appears When tab. Wizards Hat. And now choose Local Variable. Give the name of your saved variable(int) and say its gotta be equal to 1, which you set it to earlier.

    Save that.

    Now that when you speak to the person, he will say the "Hello, I've spoken to you once." line. And set a Variable to 1. He will not say the "Hello again!" line, because there is no variable set at 1 which it needs.

    Next time however, you will have already set the variable to one, so he will speak the top line.

    Understand?
     
  3. Thorin Gems: 9/31
    Latest gem: Iol


    Joined:
    Jan 3, 2002
    Messages:
    303
    Likes Received:
    0
    Gopher that is one type of local variable. Once you become proficient in making scripts you can create and store your own variables. This is a basic version of one. They are mainly used for major plot parts.

    //To Store An Int on a Player
    //Created by Thorin
    object oPlayer = GetFirstPC();
    //declares the object oPlayer to be the first Pc
    string sKey = "key";
    //sets the string sKey to the value of key
    int iKeyValue = 1;
    //iKeyValue value is 1
    SetLocalInt(oPlayer,sKey,iKeyValue);
    //stores the value of ikeyValue on the first pc, with the access word of key

    //To Return a Stored Int Value
    //Created by Thorin
    object oPlayer = GetFirstPC();
    //declare agian the target of where you stored the variable
    int iValue;
    //an Integer to contian the value you want
    iValue = GetLocalInt(oPlayer,"key");
    //sets iValue to the value that was stored with the string key
     
  4. Errol Gems: 23/31
    Latest gem: Black Opal


    Joined:
    Oct 23, 2001
    Messages:
    1,547
    Likes Received:
    0
    Gender:
    Male
    [​IMG] :rolleyes:
    There's always one trying to be better than the rest. :p
     
  5. Pyro Gems: 5/31
    Latest gem: Andar


    Joined:
    Mar 8, 2002
    Messages:
    119
    Likes Received:
    0
    Yeah, I know of all that already, thats local variables. Isnt there any global variables like I though? Can all variables stored on the PC be read from all objects? Im doing a conversation and the script on the last NPC line has this script:

    SetLocalInt(GetPCSpeaker(), "Daerenustalk1check", 2);

    In another area I have a one-way area transistion which has been used when you get there the first time, so there is only a way to the area and not from, and this script should get around that:

    object oJumpTarget = GetObjectByTag("WP_Backfirstarea");
    if(!(GetLocalInt(GetPCSpeaker(), "Daerenustalk1check") == 2))
    ActionSpeakString("You are not supposed to go there, maybe some other time");
    if((GetLocalInt(GetPCSpeaker(), "Daerenustalk1check") == 2))
    ActionJumpToObject(oJumpTarget);

    BUT, this does not work, any idea as to why?
     
  6. Thorin Gems: 9/31
    Latest gem: Iol


    Joined:
    Jan 3, 2002
    Messages:
    303
    Likes Received:
    0
    True nwn global varaibles should really not be used for going between areas. Gobal variables where ment for major events. The commands anyhow are GetGlobal, Global, SetGlobal.

    LocalVaraibles on the PC, are pratically what you need as they are really gobal varaibles, they stay when saving, and dying.

    try extracting the varaible from the pc before checking it. Second if I remember you cant jump to an object if it is in a different area. You will have to a getobjectlocation, and jump the pc to the objects location.

    (it's late and I am tired so exuse the spelling)

    [ January 30, 2003, 08:23: Message edited by: Thorin ]
     
  7. Pyro Gems: 5/31
    Latest gem: Andar


    Joined:
    Mar 8, 2002
    Messages:
    119
    Likes Received:
    0
    You are wrong actually, Ive tried to do a jumpto script from a dialogue displaying first an effect and then doing a jumpto a waypoint in another area and it worked.
     
Sorcerer's Place is a project run entirely by fans and for fans. Maintaining Sorcerer's Place and a stable environment for all our hosted sites requires a substantial amount of our time and funds on a regular basis, so please consider supporting us to keep the site up & running smoothly. Thank you!

Sorcerers.net is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to products on amazon.com, amazon.ca and amazon.co.uk. Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.