Create a simple Inventory system

2

Index

Attached Files

The following files have been attached to this tutorial:

.c3p

dictionary-inventory.c3p

Download now 174.95 KB
.c3p

array-inventory.c3p

Download now 176.47 KB

Stats

776 visits, 1,512 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 13 May, 2024. Last updated 29 May, 2024

Use Dictionary

Dictionary Manuals

construct.net/en/make-games/manuals/construct-3/plugin-reference/dictionary

Level 1: How to use Dictionary

[action] Dictionary: Add key

[expression] Dictionary.Get("Apple")

{"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"on-start-of-layout","objectClass":"System"}],"actions":[{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Apple\"","value":"1"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Orange\"","value":"0"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Pear\"","value":"0"}}]},{"eventType":"block","conditions":[{"id":"on-key-pressed","objectClass":"Keyboard","parameters":{"key":37}}],"actions":[{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Orange\"","value":"max(Dictionary.Get(\"Orange\") - 1, 0)"}}]},{"eventType":"block","conditions":[{"id":"on-key-pressed","objectClass":"Keyboard","parameters":{"key":39}}],"actions":[{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Orange\"","value":"min(Dictionary.Get(\"Orange\") + 1,  5)"}}]}]}

Level 2: How to Load Dictionary Data

[condition] Dictionary: For each key

[expression] Dictionary.CurrentKey

[expression] Dictionary.CurrentValue

Level 3: Display Dictionary Data

The key here is that by add an instance variable to Slot object, it is used to know whether the item already exists.

  • 1 Comments

  • Order by
Want to leave a comment? Login or Register an account!