Skip to content

Need help with scripting. Huge noob

Hey guys, I'm working on a small PW and I'm stumped on how to make item variables work as a condition for text appearing in conversations and so on. Does anyone happen to know how to do this or have a script on hand? Thanks in advance for any help. :)

Comments

  • ProlericProleric Member Posts: 1,316
    Sounds like you know how to make a conditional script, and obtain object variables using GetLocalInt() etc? Items are no different. Do you have a specific example that you're stuck on?
  • tizzdelawizztizzdelawizz Member Posts: 3
    Proleric wrote: »
    Sounds like you know how to make a conditional script, and obtain object variables using GetLocalInt() etc? Items are no different. Do you have a specific example that you're stuck on?

    Basically I want to use variables on an item to persistently save quest progress instead of having a separate token item for every part. I've played on a few PWs before and they all seem to use a single character token, which I assume is where all that is stored. Sadly I can't find a way to do this with the script editor - I can add the variables but not use them in a "text appears when" check
  • ProlericProleric Member Posts: 1,316
    edited April 2022
    Something like this:
    int StartingConditional()
    {
      object oItem = GetObjectByTag("whatever");
    
      return (GetLocalInt(oItem, "variable_name") == 7);
    }
    
    will be TRUE if the item with that tag has a variable with that name set to 7.

    If the tag is not unique, you might need to use GetItemPossessedBy(GetPCSpeaker(), "whatever") instead of GetObjectByTag().

    GetLocalString() can be used for string variables.

    See Lexicon for more detail on functions.

    I'm not an expert on making item variables persistent, as it's a PW-specific issue. It has been discussed many times, but if you have issues with that, try asking in the PW sub-forum or Neverwinter Vault.
  • tizzdelawizztizzdelawizz Member Posts: 3
    This script doesn't seem to work for me - what am I doing wrong? I've tried taking a search on this forum but I can't find any information on how to set this up. Thanks again!
  • ForSeriousForSerious Member Posts: 466
    Send me a personal message, and I'll help get you where you want to be.
  • sunxresunxre Member Posts: 23
    Int StartingConditional()
    {
      object pc = GetLastSpeaker(); object item = GetFirstItemInInventory(pc);
      while(GetIsObjectValid(item))
      {
        If(GetTag(item) == "whatevertagyouset")
        {
          switch(GetLocalInt(item, "gibitaname"))
          {
             default:
              return FALSE;
              break;
             case TRUE:
               return TRUE;
              break;
             case whatever number you think is relevant:
              break;
                return TRUE;
          }
          break;
        }
        item = GetNextItemInInventory(pc);
      }
      return FALSE;
     
    }
    
    

    Is that what you are looking for?

    You can is if/else instead of switch(I try to make myself use switch, because I know it takes less CPU, and I want to get in the habit)
Sign In or Register to comment.