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 tested the following on 1465 and works as expected! I did notice that the Inky editor seems to not like EXTERNAL declarations. Not sure if that is expected or not. It has no way to know about them but I would have thought it would have just ignored them. Instead, it just shows nothing in the right panel.

    The VAR statements create the variables and then the Shroud client fills in the data at run time.

    Here is a quick youtube video showing it off:

    Full list of variables:

    • playerName
    • adventurerLevel
    • producerLevel
    • playTimeNumber
    • playTimeString
    • PVPFlagged - returns 0 or 1
    • VirtueTruth - returns -1 if less than -50, 0 if -50 to 50, and 1 if greater than 50
    • VirtueLove - ""
    • VirtueCourage - ""
    • currentScene
    • NBDayOfWeek
    • NBMonth
    • NBSeason
    • NBPeriodOfDay
    • NBPhaseOfMoon
    • NBWeatherName
    • NBWindType

    Functions that currently work:
    • printStringToConsole - just logs an error string to your log file for debugging
    • saveVariable
    • loadVariable
    • playEmote

    Code:
    EXTERNAL playSound(soundName)
    EXTERNAL printStringToConsole(stringToPrint)
    EXTERNAL playEmote(emoteName)
    EXTERNAL saveVariable(varName)
    EXTERNAL loadVariable(varName)
    -> Castle1
    
    VAR doorUsedLastTime = "none"
    VAR playerName = "NONE"
    VAR adventurerLevel = 0
    VAR playTimeString = "NONE"
    
    
    === Castle1
    
    = CourtYard
    
        ~ loadVariable("doorUsedLastTime")
        Hi { playerName } who is level { adventurerLevel } you have played { playTimeString } and last time you chose { doorUsedLastTime}
        Now I'm going to pretend to be an aeroplane!
        ~ playEmote("AeroPlane")
    
        What are you going to do? You feel quite drousy and your clothes are tattered.
        *Go through the Front Door... Confidently!
            -> FrontDoor
        *Search for another entrance...
            -> Entrance2
        *Leave the area, I don't want to go into the castle!
            ->LeaveArea
     
    -> FrontDoor
    
    = FrontDoor
    GUARD: "Oi!"
        ~ doorUsedLastTime = "front door"
        ~ saveVariable("doorUsedLastTime")
        * Act cool...
            As you try to act cool, the guard strikes you with his mace, killing you with a devestating blow.
            -> GameOver3
        
        * Run away as fast as you can...
            You turn and run... as you are running down the stairs, you feel a cold sharp pain and realise, you have a throwing dagger in your heart... Woops!
            -> GameOver3
    
    = Entrance2
        ~ doorUsedLastTime = "Entrance2"
        ~ saveVariable("doorUsedLastTime")
        Slowly, you make your way towards the side of the castle and after several minutes of searching, you find a small window which you manage to fit through and discover that you have landed in a treasure room!
     
            What will you loot?
            **As much as you can carry!
                While you are loading your arms with treasure you fail to hear the guard coming into the room and slamming an axe into your skull.
            
                The last thing you remember is seeing a shadow that looked an awefull lot like an axe...
                    -> GameOver3
        
            **Take one item only...
                You spend a moment choosing a piece of tresure and leave through the window in which you came.
                    ->GameOver2
     
     
    = LeaveArea
        ~ doorUsedLastTime = "left area"
    
        ~ saveVariable("doorUsedLastTime")
        You leave the strange looking castle and within a few days it slips from your memory forever...
        -> END
    
    = GameOver2
        You escaped with the treasure!
        -> END
     
    = GameOver3
        You have foolishly died.
        -> END

    NOW, what other stuff do you guys want exposed?
     
  2. Paladin Michael

    Paladin Michael Bug Hunter

    Messages:
    2,650
    Likes Received:
    4,202
    Trophy Points:
    153
    Gender:
    Male
    Location:
    Perennial Coast
    I tried the script - and (as bug reported yesterday) no emote is played.
    Everything else works fine - but no (AeroPlane) emote is shown.
    I also tried other emotes like bow or cry.

    @Chris: What could be wrong?

    I tried with two different Conversationalists.


    Somebody else tried the script? :)
     
    Time Lord likes this.
  3. Chris

    Chris Tech Lord Moderator Ambassador SOTA Developer

    Messages:
    2,470
    Likes Received:
    27,551
    Trophy Points:
    190
    Gender:
    Male
    The emotes will only work on a humanoid NPC, like a human or elf.
     
    Time Lord likes this.
  4. Paladin Michael

    Paladin Michael Bug Hunter

    Messages:
    2,650
    Likes Received:
    4,202
    Trophy Points:
    153
    Gender:
    Male
    Location:
    Perennial Coast
    I tried Conversationalist Female 1, Female 2 and Male 4.

    Won't work :(
     
    Time Lord and Anpu like this.
  5. Chris

    Chris Tech Lord Moderator Ambassador SOTA Developer

    Messages:
    2,470
    Likes Received:
    27,551
    Trophy Points:
    190
    Gender:
    Male
    Hrm... that is puzzling. Here is a video of me using the female 1 with the sample script and adding in a second emote for backflip as well! If it isn't working for you guys still then I might need some help finding the "special sauce" that is making it behave differently.
     
    Time Lord and Paladin Michael like this.
  6. Paladin Michael

    Paladin Michael Bug Hunter

    Messages:
    2,650
    Likes Received:
    4,202
    Trophy Points:
    153
    Gender:
    Male
    Location:
    Perennial Coast
    Thank you @Chris for this second video!

    O.K. I got it :)

    I tried it in a house, where I only have Co-Owner rights.

    Emotes don't work, if I'am only a Co-Owner.

    On my own lot it works fine :)

    What would be great to create more interesting quests is the possibility to receive items or just the variable to check, if someone has a special item in inventory.

    How about items, which already exists in game?

    For example: a book, a note, a letter, a painting?

    And last but not least: would it be possible to provide a reward, a few xp and a few gold pieces?
    [As we know, there are alot of chests providing items and a few gold, so this wouldn't be a kind of unfair "gold automaton" ;)]


    Well, last one is secondary, but to use in game items would be fine :)
     
    Sean Silverfoot and Time Lord like this.
  7. Ravalox

    Ravalox Chief Cook and Bottle Washer Moderator SOTA Developer

    Messages:
    1,731
    Likes Received:
    4,954
    Trophy Points:
    125
    Gender:
    Male
    Location:
    Dallas, TX

    @Chris This would close the loop on player driven quests. Have a "questComplete" variable that then delivers the items in a "loot table" in the script which would pull from the conversationalist's inventory (via a right click option to the menu to add items to the NPC's inventory) Player would specify in the script what items, and how many to give to the player via a trade window. Once the flag is set, then the player can't repeat the quest, or alternatively the conversationalist could have a function to clear all the quest variables after the reward is distributed, so if the player wants to redo the quest they have to start from the beginning.

    The only sticking point I can see is what happens if the conversationalist runs out of stuff to give out. (should have a trap required in that function, (else empty type of thing) to say something like "I must consult with my employer to arrange for your reward". From here, another "idea" comes to mind ... link Inky to the in game mail system to notify the conversationalist player that it needs re-stocking. (linking to the mail system could also provide statistics/logs etc to the conversationalist's player (for instance)

    so in summary:

    * A quest complete flag that delivers a reward from the NPC's "inventory"
    * The flag prevents players from repeating quests and depleting the inventory
    * A function to send mail to the owner of the NPC (would need to pull the engaged players character name to be put in the subject line (mail should arrive from the NPC's name)
     
  8. Chris

    Chris Tech Lord Moderator Ambassador SOTA Developer

    Messages:
    2,470
    Likes Received:
    27,551
    Trophy Points:
    190
    Gender:
    Male
    Good ideas. This is a short release due to Thanksgiving but I'm hoping to 1 week on Inky, one on PVP, and one on bugs!
     
  9. craftymethod

    craftymethod Avatar

    Messages:
    1,133
    Likes Received:
    2,001
    Trophy Points:
    113
    haha awesome, Chris updated my Inky pick a path script. The guard says ' OIIIII!!!"
     
    Time Lord likes this.
  10. Widsith [MGT]

    Widsith [MGT] Avatar

    Messages:
    714
    Likes Received:
    646
    Trophy Points:
    93
    Observations:

    Had trouble with playEmote at the start due to using the spellings in the 'O' window, many of which are incorrect for the / commands. Sotawiki list is more useful. (Maybe add the / string to 'O'?) Still haven't gotten the following to work: breathefire, floatmeditate - though I haven't tested the list exhaustively.

    Suggestions:

    How about exposing avatar name (first / last), sex, and guild affiliation so dialog can be tailored to fit?
     
    Last edited: Nov 2, 2021
    Time Lord likes this.
  11. Xee

    Xee Bug Hunter

    Messages:
    2,199
    Likes Received:
    2,993
    Trophy Points:
    153
    found issue with emotes. its related to if the npc fully loaded ie has a name or if he is an unloaded which shows no name up top. this is the issue I have been having with some npc's not fully loading.
    @Chris @Ravalox
     
    Time Lord likes this.
  12. Anpu

    Anpu Avatar

    Messages:
    7,944
    Likes Received:
    9,015
    Trophy Points:
    153
    Location:
    Hemut
    I was attempting to test this on one of my lots, but the crafted Conversationalist, Beggar Male 1 has a too small limit on the number of characters on the script. The above scrip Chris posted cannot be put on a crafted NPC conversationalist.

    [​IMG]
     
    Paladin Michael and Time Lord like this.
  13. Xee

    Xee Bug Hunter

    Messages:
    2,199
    Likes Received:
    2,993
    Trophy Points:
    153
    Yeah I talked with Devs on my stream they will normalize the scripts lengths to be the same. they had it so store ones had more which I told them its not good as I now cant just move my scripts between all npc's so they instead will consider the store to maybe only be the ones that play emotes or something... so we will see what they decide after they discuss further
     
    Paladin Michael, Time Lord and Anpu like this.
  14. Xee

    Xee Bug Hunter

    Messages:
    2,199
    Likes Received:
    2,993
    Trophy Points:
    153
    @Chris need your programming help

    I understand the all your code above but how do we do if else statements in inky? trying to use variable in if x = 0 than say this instead else -> this conversation path.

    I tried to look at some 3rd party inky stuff but none of it worked for me.... anyone who may have logic for this pm or paste here thanks :)

    ok tried another route but found something that maybe an issue:
    in the partial code below when I run the whole thing it should spit out:
    this is the party info: zero

    but looks like nothing is being spit out for {been_here} based on the code I have set the
    variable to = zero to start. so it should state that if I am not wrong...

    UPDATE: so looks like on load the variable is blank even with the below. not sure if that is issue related to the npc's that dont load properly or if the declared variable does not exist until first saveVarible?


    EXTERNAL playSound(soundName)
    EXTERNAL printStringToConsole(stringToPrint)
    EXTERNAL playEmote(emoteName)
    EXTERNAL saveVariable(varName)
    EXTERNAL loadVariable(varName)

    VAR playerName = "NONE"
    VAR been_here = "zero"

    ~ playEmote("Wave")
    ~ loadVariable("been_here")

    this is the party info: {been_here} which is not working
    +yes
    ->ending
     
    Last edited: Nov 3, 2021
    Time Lord likes this.
  15. Owsley

    Owsley Bug Hunter

    Messages:
    345
    Likes Received:
    483
    Trophy Points:
    43
    Gender:
    Male
    Try a switch with one item:
    {x:
    -1: {The answer is One}
    -else: -> wrongAnswer
    }
     
    Time Lord likes this.
  16. Owsley

    Owsley Bug Hunter

    Messages:
    345
    Likes Received:
    483
    Trophy Points:
    43
    Gender:
    Male
    Is there a way to use loadVariable and saveVariable with a number?
    When the following is run on successive interactions you end up with string concatenation: 1, 11, 111, etc.
    Also, where is the variable data actually stored?

    EXTERNAL saveVariable(varName)
    EXTERNAL loadVariable(varName)
    ->start
    VAR testCount=0
    ===start
    ~loadVariable("testCount")
    {testCount}
    ~testCount = testCount+1
    {testCount}
    ~saveVariable("testCount")
    ->END
     
    Time Lord likes this.
  17. Xee

    Xee Bug Hunter

    Messages:
    2,199
    Likes Received:
    2,993
    Trophy Points:
    153
    will give this a try.

    yeah I would like to know if there is an xml or text file somewhere with the var list would be handy to look at for verifying writes when the output is not showing :)
     
    Time Lord and craftymethod like this.
  18. Owsley

    Owsley Bug Hunter

    Messages:
    345
    Likes Received:
    483
    Trophy Points:
    43
    Gender:
    Male
    I just wrote a simple test script to control branching based on a saved variable. A variable can contain ink script but the saveVariable function appears to only work with strings, so I'm reusing the variable "branch" to contain both the branch pointer and the string representation of the branch destination. The "else" clause is used the first time the routine is run since there is no valid data in the loaded variable

    EXTERNAL saveVariable(varName)
    EXTERNAL loadVariable(varName)

    VAR currentScene = "NONE"
    VAR playerName = "NONE"
    VAR branch = -> Act1
    ~loadVariable("branch")
    {branch:
    -2:~branch = -> Act2
    -3:~branch = -> Act3
    -else:~branch = -> Act1
    }
    ->branch

    =Act1
    {"Welcome to "+ currentScene}
    ~branch = "2"
    ~saveVariable("branch")
    ->END

    =Act2
    {"Welcome back "+ playerName}
    ~branch = "3"
    ~saveVariable("branch")
    ->END

    =Act3
    {"I have nothing more to say. Goodbye"}
    ->END
     
  19. Owsley

    Owsley Bug Hunter

    Messages:
    345
    Likes Received:
    483
    Trophy Points:
    43
    Gender:
    Male
    In doing some research there doesn't appear to be any easy way to convert a string to integer or vice versa.

    loadVariable appears to be implicitly converting the variable to a string, making it impossible to do math on it.

    @Chris, is it possible for you to create two new external functions (loadInteger and saveInteger) to handle numbers?
     
    Paladin Michael, Time Lord and Xee like this.
  20. Chris

    Chris Tech Lord Moderator Ambassador SOTA Developer

    Messages:
    2,470
    Likes Received:
    27,551
    Trophy Points:
    190
    Gender:
    Male
    Yes! I'll get on that ASAP.
     
Thread Status:
Not open for further replies.