Forum rules - please read before posting.

Questions about item properties

I've never really used item properties before, but they look straightforward enough if you treat them as read-only. I'm just not entirely sure how they work if you change them at runtime. Basically, this is what I want to accomplish:

  • Eggs are stackable items, so that the player can carry many of them and also put them in various storage containers if desired. No issues here.
  • In one special container, however, eggs can't be stacked: a nest with 4 slots. I'm pretty sure I know how to write custom code to prevent item stacking here. No issues.
  • For every in-game day, each egg in the nest will have its "age" property increased by 1. I haven't tried doing this yet, but I'm assuming it will be as simple as setting the InvInstance property through code?

My questions are:

  • If I select an egg that is older than default and move it to a different slot in the nest, will it keep its property? I'm assuming yes.

  • If I move it to the player inventory, will the property remain? Also assuming yes.

  • What if I select the old egg and add it to an existing stack? I'm assuming the property won't be kept and the stack's property will prevail. But what if I select an the stack and add it to the old egg? Will ALL eggs become old? I think that if this is an issue, I might create two items, stackable and non-stackable eggs, and write some code to delete a non-stackable egg and add a stackable one when the player tries to combine them.

  • Lastly, what if I save and load the game? Are the changed properties saved?

Sorry about all the questions! I would generally just test it out, but runtime inventory properties aren't very transparent in the editor, so I'd have to write a script just to know what is going on.

Comments

  • If I select an egg that is older than default and move it to a different slot in the nest, will it keep its property?

    If the slot is empty, yes.

    If I move it to the player inventory, will the property remain?

    Yes - again, if

    What if I select the old egg and add it to an existing stack?
    But what if I select an the stack and add it to the old egg?

    When comparison checks are made for stacking two items atop each other, AC currently only checks that they are of the same type. If they both have different property values, they will merge - both taking the values of the item in the existing slot.

    You raise a good point, though. In the event that they differ, the addition should fail - or at least the InvCollection script should make this optional. I will look into providing this, thanks for the feedback.

    Are the changed properties saved?

    Yes.

  • Thanks for adding the matchPropertiesWhenMerging parameter! So if I understand this correctly, if this parameter is true, then both items will take the value of the item in the existing slot. What if it is false? Will it prevent the addition, or will they all take the value of the item that is being added?

  • If matchPropertiesWhenMerging is true, then AC will compare the properties of similiar item types, and prevent them from merging if they differ. Depending on what function you're calling, AC will see about placing the added item in a different slot.

    If the parameter is false, then AC will bypass these checks and merge items of the same type regardless of their property values. This matches the old behaviour before the introduction of the parameter.

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.