Forum rules - please read before posting.

Custom speech token for amount of an inventory item?

I'm new to custom tokens, but I've been looking through the tutorial: https://adventurecreator.org/tutorials/creating-custom-tokens and I'm having a little trouble figuring this out. I assume the custom token script needs to be on a gameobject in scene, but I'm not sure how to reference the inventory item I'm looking at, or if I should just hard code it for a specific item ID (in this case, money).

So, if looking at the money inventory item, I want to write something like "I have [count] coins" for greater than 0, and "I have no coins" for 0; should the grammar )coin/coins) be a branch in the action list that counts the item amount and displays the grammatically correct line? I'm really looking forward to learning about writing custom tokens as I love dynamic dialogue possibilities, but I just need to make sure I'm on the right track with this!

Comments

  • It seems to me that the grammar would only be different if you have 1 coin, since then you'd have no pluraly.  For 0 or >1 coins, you're still going to say "I have X coins", even if X="no".

    You can use the Inventory: Check Action to determine how many coins you're carrying, and play one of two Actions accordingly.

    To get the amount carried of a particular item, right click on the Quantity on start? field in the Inventory's properties.  You can temporarily check Carry on start? to show it if it's not visible.  After right-clicking, you'll be able to get a script reference to modify it through script, e.g.:

    AC.KickStarter.runtimeInventory.GetItem (0).count


  • Yeah, that was the method I was going to use, I just wasn't certain about how to put the amount number in the dialogue itself as a token ( "I have [count] coins" - I'm not sure how to get [count] to populate the amount)

    As for speech, I'm not sure if its possible to dynamically retrieve sounds; if I had an actionlist:
    • with the first part of the dialogue line being "I have" that triggers an "I have" speech clip
    • A second part that that checks the amount and retrieves it as a line "[count] and retrieves a clip based on the amount (1 would retrieve 1.mp3, 2 would retrieve 2.mp3, etc)
    • And finally a branch to add the correct grammar.
    Again, I'm not sure if AC has the possibility of building one sentence in three parts, or playing back audio clips dynamically based on the name of the clip?
  • See the tutorial: a custom token is declared by number, not by text.  You'd use [token:0] instead of [count].

    As for dynamically building audio clips: it doesn't - but if you're going to go to the trouble of recording audio for each possibility, it's easiest to just make a dedicated speech line for each.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.