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

655 visits, 1,308 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

This tutorial introduces several ways to manage data structures to make a simple inventory system.

Which one is better dictionary or array inventory?

They each have their own advantages, depending mainly on the functionalities required in your game, proficiency in manipulating such data structures, and simply using whichever fits the bill. They're just different ways to help organize your data.

Array have a natural advantage when it comes to sorting. If you want to design a sorting feature, arrays make it convenient to sort certain data. Arrays also have actions like Push and Pop, which can implement task queues like queues and stacks.

dictionary have a huge advantage in retrieval because they can quickly find the corresponding value based on a name. If you need to find a value among thousands of items, a dictionary is definitely much faster than an array because it doesn't need to scan the entire dictionary.

When dealing with complex data, using JSON would be a better choice as it encompasses functionalities of both arrays and dictionaries, allowing for storage of various data types.

  • 1 Comments

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