Action If Character Has Item In Inventory

  • #10, by esmeraldaTuesday, 19. June 2018, 10:06 6 years ago
    I don't know if you want to cover every possibility and give a different output for every item combination.

    You have to consider which items the character can have at that moment.
    One possibility to do it is this:

    Key Killer

    513 Posts


  • #11, by snowWednesday, 20. June 2018, 02:50 6 years ago
    Thank you Esmerelda.

    One small bug I noticed.

    When I have the loaded gun, but not the money bag. It will say, "I need to load the gun". Then right after it will say "I need my things."

    Kind Regards

    Newbie

    23 Posts

  • #12, by esmeraldaWednesday, 20. June 2018, 08:31 6 years ago
    That sounds like there is still a bug in the engine in the "else if" statements.
    I thought Simon fixed that bug in the latest update, but I haven't tested is. Are you using the updated version?

    Key Killer

    513 Posts

  • #13, by snowWednesday, 20. June 2018, 08:53 6 years ago
    yes, version 5.0.5

    Newbie

    23 Posts

  • #14, by afrlmeWednesday, 20. June 2018, 12:26 6 years ago
    That sounds like there is still a bug in the engine in the "else if" statements.
    I thought Simon fixed that bug in the latest update, but I haven't tested is. Are you using the updated version?
    No, they are working. Just tested with a value, 3 different if queries & an else statement added at the end. Each one returned the display text I specified, I haven't tried mixing & matching different types of if queries though, maybe that's confusing the engine as multiple queries could be returning true.


    This works, but it's not 100% perfect because there are multiple possible combinations that you could query, such as do they have the bag, but not the gun or the bullets, etc.

    What I've done is seperate the 2 query blocks & if the first query block returns true at any point then it will stop iterating through the actions immediately after saying the relevant display text. If it doesn't return true at any point then it moves down to the next query block.

    I didn't use any elseif queries at all for this. To be honest what would have been more useful is the ability to query and & or like I can with Lua script as it makes writing complicated if queries much simpler.

    A potential good solution might be to combine what Sebastian said about using conditions - along with a for loop to iterate through the characters iventory to set conditions for the items to true if found, then write a bunch of if queries with Lua to set a value, which you could use to query which display text to say or which called by other action to call. I dunno, I just hate creating if queries with action parts as they end up looking like a confusing mess when you end up having to create loads in the same action block.


    Imperator

    7278 Posts

  • #15, by SimonSWednesday, 20. June 2018, 16:03 6 years ago
    No there was an issue with the elseif queries and nesting, I fixed it just now.

    Thread Captain

    1580 Posts

  • #16, by snowThursday, 21. June 2018, 05:31 6 years ago
    Thank you AFRLme for the valued guide and the "Quit current action" part is most useful.

    Esmerelda there was a bug in the engine, they have just released 5.0.6 which fixes the issue we were having.

    I'm certain I will be referring back to these threads often.

    Simion I just saw your reply, thank you for the update.

    Kind Regards

    Newbie

    23 Posts

  • #17, by minds_Sunday, 24. June 2018, 16:35 6 years ago
    Hi
    i have similar problem. Why this isnt working for me ? roll

    I need to change outfit when my char has item in his inventory.
    Overall i need 3 items and then change outfit. But even 1 item doesnt work... roll

    Newbie

    4 Posts

  • #18, by esmeraldaSunday, 24. June 2018, 19:03 6 years ago
    You are using "called by another action" as execution type. Could you explain when/how you are calling this action? (or post a screenshot). Maybe that's where the problem lies.

    Key Killer

    513 Posts

  • #19, by minds_Sunday, 24. June 2018, 20:53 6 years ago
    Hi! Thanks for reply.

    I think i didnt find better execution type ..
    Which one should i choose?
     My character just picks up objects and when he collect 3 of them, then outfit should change.

    I dont know how to do this and where should i put actions. I have put them in current character actions. Is it ok or should it be on scene

    Please help roll
    Thanks

    Newbie

    4 Posts

  • #20, by esmeraldaSunday, 24. June 2018, 21:23 6 years ago
    "called by another action" means this if query where you change the outfit is only executed when it is called (like by the action part: call action)

    In your case I would recommend calling the action you allready created in the actions tab of your character when picking up one of the 3 items. You can give the action a different name so you can identify it better. (double-click on name)
    (Or you could create if queries in every pick-up-action of the 3 items, but that would be more work)

    pick up item - action:
      - add item to inventory
       - call action "your action in character tab"

    your action in character tab:
      if character has item1
        if character has item 2
          if character has item 3
            change outfit
          end if
        end if
       end if


    Edit:
    just to be clear: the pick-up-action should be in the actions of the scene-object your are picking up. But I guess this part is working for you, is it?
    The other action that you are calling can be in the characters actions or in the scene or where you like.

    Key Killer

    513 Posts