Default comment sets for specific inventory items

  • #1, by tall-story-gamesFriday, 23. October 2020, 16:06 3 years ago
    Hi, I don't know if this is the right place to post this, or if it will be helpful to anyone, but I found it quite hard to find a solution to this without mashing together a load of other suggestions on related subjects.

    In my game I wanted to extend the default comment set so that I could add default comments for each individual item in a character's inventory.

    For example:

    If I selected "Use Glue with..." + "Dog" unless I wrote a custom response for that object/item combination I would have just got the default "I can't use that." or "That doesn't work." (classic!).

    What I wanted was something like "I don't want to stick that." which would act as a default for that item only.

    There is probably a way of doing this with a mouse click listener, which would make it more efficient, but the way I have managed to do this without too much Lua experience is with the following.

    I created a comment set for each item that I wanted to customise, and named it appropriately (e.g. "Glue_comment_set"). I have about 20 custom sets in my game demo as not all of the items required one.

    I then created the following looping action called "update_comment_sets" within my first scene (which is the main menu), and set it to "Called by other action".

    ---------------------------------------------
    1. Pause for 50 milliseconds (quick enough to update between mouse clicks in different screen locations, but not over-intensive...I hope).

    2. If lua result containing the following script: return game.UsedItem:getName() == "Glue"

    3. Change comment set of 'CharacterName' to 'Glue_comment_set'

    4. You can then add multiple Else If variations with different item names and comment sets as required.

    5. Else

    6. Change comment set of 'CharacterName' to 'Default_comment_set'

    7. Jump to action part #1 (to loop this action every 50 milliseconds)
    ---------------------------------------------

    This action is then called from within the Start action in the Game properties tab.

    It essentially keeps looping in the background and changes the comment set based on the current selected item. You should also only need to include combined command comments within the new comment sets (like "Use with" or "Give to").

    I've not tried this for multiple characters carrying the same item (e.g. One character might say "I don't want to stick that." and another might say "I don't want to make a mess."), but I'm guessing that you would just need to add multiple comment sets for those characters and just add in more "Change comment set" parts within the If statement for that item (remembering to put the default comment set for each character within the final "Else" statement).

    I hope this helps someone, and if anyone has any improvements to this approach, please let me know smile

    Newbie

    42 Posts