Goods managing system

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Andrea

i´m working on a RTS game, and currently trying to understand the best way to represent the many in game resources.
I´m tempted to use simple variables (var wood=100) but even if it´s quite simple to code it, i dont like it for two reason:

  1. I would like the resource variable to have more properties then the amount only
  2. Writing a list of variable is not the top in case this list is modified or new resources are added (re-write all the code to include the new resource)

Do you know a better way I can accomplish it? Is there any node it can help me here?

:bust_in_silhouette: Reply From: llama

Sounds like your looking for a dictionary

    var resource {
        name = "wood",
        str = 23,
        life = 10

  print("Type: ",, " Strength: ", resource.str, "Lifespan: ",

  if = 0:
      do stuff

how does this work with multiple resources?
I mean, do i need to declare resource1, resource2, resource3, etc, or can i somehow use the same template and change the value only?
(sorry, i´m pretty noob on this kind of stuff, but i couldnt find anything on the forum)

Andrea | 2018-06-04 02:35