which is the number of items in the inventory

  • #1, z andrea_visTuesday, 08. November 2022, 12:26 hodinky 2 years ago
    How to display the number of items that are in the inventory of a character?

    Specifically, some investigation games (e.g., the Case of the Golden Idol) display how many clues you collected. This helps to give a sense of progress, especially if this value is shown as a fraction of the total number of clues that can be collected. In other words, I am looking for the value of nRecordedClues in "v=nRecordedClues>/20" (where 20 is the total number of clues).

    Bažant

    11 Posts


  • #2, z afrlmeTuesday, 08. November 2022, 13:23 hodinky 2 years ago
    A'llo, you would need to use code to amount of items currently held in the active characters inventory.

    Values["nRecordedClues"].Int = #game.CurrentCharacter.Items

    I'm assuming you already know how to display the value in a display text/object text, etc? If not inside of the text you would write: <v=nRecordedClues>/20

    Imperátor

    7285 Posts

  • #3, z andrea_visTuesday, 08. November 2022, 17:50 hodinky 2 years ago
    Many thanks for your prompt answer.
    You correctly assume that... I'm a newbie so I am stuck despite your answer smile

    This is what I did but it doesn't work (i.e., the text shows '?'). In the inventory of the character 1 I created a 'called by other action' action:
    1) the action first executes the script (Execute script 'Values["nRecordedClues"].Int = #game.CurrentCharacter.Items') 
    2) the second line of the action is a Display text where the text is <v=nRecordedClues>

    I am sure that I am doing something very silly (i.e., some errors in the syntax), but I can't find it...

    Bažant

    11 Posts

  • #4, z afrlmeTuesday, 08. November 2022, 21:14 hodinky 2 years ago
    Are you including those apostrophes in your script, or are you just demonstrating that you used what's in between them?

    Anyway, I really would recommend joining our Discord server if you aren't already on it. It's much easier & faster for getting & providing help than on here.

    Imperátor

    7285 Posts