Sample Inky script showing new functions

Discussion in 'Ink NPC Dialogue Composition' started by Chris, Oct 30, 2021.

Thread Status:
Not open for further replies.
  1. Chris

    Chris Tech Lord Moderator Ambassador SOTA Developer

    Messages:
    2,470
    Likes Received:
    27,551
    Trophy Points:
    190
    Gender:
    Male
    Just updated the "LoadVariable" function to attempt to parse the value into an integer. If it succeeds, it returns it as an integer. If it fails, it returns it as a string. Will that solve your issues? I'll have it on QA in a few hours for testing.
     
    Paladin Michael, Time Lord and Xee like this.
  2. Owsley

    Owsley Bug Hunter

    Messages:
    345
    Likes Received:
    483
    Trophy Points:
    43
    Gender:
    Male
    I tried to test this on QA but as soon as I place the conversationalist (crafted male beggar) on my lot, it disappears. I had to retrieve it from the deco palette. I tried it on three different lots, same results, conversationalist doesn't render.

    UPDATE. That was weird. After I placed a crown shop conversationalist, the crafted one started to work.... but both were missing titles and their right click dialogs were wrong. They were missing the commands to stay, patrol, etc. Instead it was the deco object dialog.

    Additional update: I logged on to QA this morning and the crown shop conversationalist renders properly and has the correct dialog box. The crafted one is bugged again. I placed it and it disappears... again. Had to retrieve it from the deco palette. Tried several times.
     
    Last edited: Nov 6, 2021
    Time Lord likes this.
  3. Owsley

    Owsley Bug Hunter

    Messages:
    345
    Likes Received:
    483
    Trophy Points:
    43
    Gender:
    Male
    Here are the test results. It worked.....sort of.

    There is a "first time" issue.

    If you save the variable first and then load it, it works as expected: the data type is maintained and you get an integer.

    But normally you will load the variable, process it, and then save it. This introduces a problem. Loading a variable that hasn't yet been saved turns the variable into a string and we are back to the original problem.

    What we need is some way to know if the variable has been previously saved, i.e. some sort of ifSaved function so we don't attempt to load a variable that hasn't yet been saved.

    I believe such a function is critical because we don't want to attempt the loading of a variable that has not been saved.

    I envision a need for this almost every time we are sharing numeric data among conversationalist. We need to know the state of the variable (saved, unsaved) before we do I/O on it.

    A workaround would be to create separate "first time" string variables to track all the numeric variables, but that is messy. A Boolean function is a more practical solution.
     
    Time Lord likes this.
  4. Owsley

    Owsley Bug Hunter

    Messages:
    345
    Likes Received:
    483
    Trophy Points:
    43
    Gender:
    Male
    Here is a fully working script using workaround code to address the "first time" issue. It checks for the presence of a "saved" flag. If one exists, it loads the saved integer. Every time you talk to the conversationalist it will increment the integer and save the result.
    NOTE: Currently, this only works in QA

    EXTERNAL saveVariable(varName)
    EXTERNAL loadVariable(varName)
    VAR QACounter=0
    VAR QACounterSaved = "NO"
    VAR currentScene = ""
    VAR playerName = ""
    ~loadVariable("QACounterSaved")
    { QACounterSaved == "YES":
    ~loadVariable("QACounter")
    }
    Welcome to {currentScene}, {playerName}
    You have talked to me {QACounter} times
    ~QACounter = QACounter+1
    ~saveVariable("QACounter")
    ~QACounterSaved = "YES"
    ~saveVariable("QACounterSaved")
    ->END


    The script below illustrates the "first time" issue. It will implicitly convert the integer to a string, resulting in concatenation instead of addition.

    EXTERNAL saveVariable(varName)
    EXTERNAL loadVariable(varName)
    VAR testInt=0
    VAR currentScene = ""
    VAR playerName = ""
    Welcome to {currentScene}, {playerName}
    ~loadVariable("testInt") //if testInt has not been saved this will change the data type to string
    Saved data:{testInt}
    ~testInt = testInt+1
    Plus 1 = {testInt}
    ~testInt = testInt+1
    Plus 1 = {testInt}
    ~testInt = testInt+1
    Plus 1 = {testInt}
    ->END
     
    Last edited: Nov 6, 2021
    Time Lord likes this.
  5. Xee

    Xee Bug Hunter

    Messages:
    2,199
    Likes Received:
    2,993
    Trophy Points:
    153
    In a stream which the devs watched I explained what causes this issue. the npc's when first placed do not load up properly until you rezone. There is also some sort of limit bug to the number of npcs running scripts or loading up which is another issue if you are like me with a castle dungeon that has a lot of story to tell :)
     
    Time Lord likes this.
  6. Owsley

    Owsley Bug Hunter

    Messages:
    345
    Likes Received:
    483
    Trophy Points:
    43
    Gender:
    Male
    I tried zoning both before and after placing the conversationalist. same results. I also crafted a new conversationalist that contained no ink script, same results. The crown store conversationalist works, the crafted one doesn't.
     
    Time Lord likes this.
  7. Owsley

    Owsley Bug Hunter

    Messages:
    345
    Likes Received:
    483
    Trophy Points:
    43
    Gender:
    Male
    Currently the Inky editor gives a syntax error on the external calls and will not allow run time testing. Here is a way to simplify runtime testing in the inky editor by creating two functions that call loadVariable and saveVariable. The variable name is passed as the parameter. To test in Inky you simply comment out the two external calls. To use in SOTA, uncomment the two external calls.

    EXTERNAL saveVariable(varName)
    EXTERNAL loadVariable(varName)
    VAR QACounter=0
    VAR QACounterSaved = "NO"
    VAR currentScene = ""
    VAR playerName = ""
    ~LoadData("QACounterSaved")
    { QACounterSaved == "YES":
    ~LoadData("QACounter")
    }
    Welcome to {currentScene}, {playerName}
    You have talked to me {QACounter} times
    ~QACounter = QACounter+1
    ~SaveData("QACounter")
    ~QACounterSaved = "YES"
    ~SaveData("QACounterSaved")
    ->END

    ====function LoadData(varName)===
    //loading {varName} //uncomment for testing purposes
    ~loadVariable(varName) //comment out this line for testing in editor

    ====function SaveData(varName)===
    //saving {varName} //uncomment for testing purposes
    ~saveVariable(varName) //comment out this line for testing in editor
     
    Last edited: Nov 13, 2021
    Time Lord likes this.
  8. Owsley

    Owsley Bug Hunter

    Messages:
    345
    Likes Received:
    483
    Trophy Points:
    43
    Gender:
    Male
    Can we add the character's current title and sex to the list of available variables? Would love to personalize the conversations even more. (m'lady, Lord, etc.)
     
    Sean Silverfoot, Anpu and Time Lord like this.
  9. Owsley

    Owsley Bug Hunter

    Messages:
    345
    Likes Received:
    483
    Trophy Points:
    43
    Gender:
    Male
    @Chris, there is a bug with the NB prefixed exposed variables. They are returning a hexadecimal string in addition to the ASCII text (see below)

    [​IMG]

    Here is the test code that displays all the exposed variables:
    Code:
    VAR QACounter=0
    VAR currentScene = ""
    VAR playerName = ""
    VAR adventurerLevel = ""
    VAR producerLevel = ""
    VAR playTimeNumber = 0
    VAR playTimeString = ""
    VAR PVPFlagged = 0 //- returns 0 or 1
    VAR VirtueTruth = 0 //- returns -1 if less than -50, 0 if -50 to 50, and 1 if greater than 50
    VAR VirtueLove = 0 //- ""
    VAR VirtueCourage = 0 // - ""
    VAR NBDayOfWeek = ""
    VAR NBMonth = ""
    VAR NBSeason = ""
    VAR NBPeriodOfDay = ""
    VAR NBPhaseOfMoon = ""
    VAR NBWeatherName = ""
    VAR NBWindType = ""
    playerName {playerName}
    adventurerLevel {adventurerLevel}
    producerLevel {producerLevel}
    playTimeNumber {playTimeNumber}
    playTimeString {playTimeString}
    PVPFlagged {PVPFlagged}
    VirtueTruth {VirtueTruth}
    VirtueLove {VirtueLove}
    VirtueCourage {VirtueCourage}
    currentScene {currentScene}
    NBDayOfWeek {NBDayOfWeek}
    NBMonth {NBMonth}
    NBSeason {NBSeason}
    NBPeriodOfDay {NBPeriodOfDay}
    NBPhaseOfMoon {NBPhaseOfMoon}
    NBWeatherName {NBWeatherName}
    NBWindType {NBWindType}
    ->END
     
    Anpu likes this.
Thread Status:
Not open for further replies.