hello, like most, very new user, and know only the most basic of code, so pardon me if the words i’m using do not abide by programming syntax.
i’m trying to make a roguelike poker / balatro game essentially where you collect random cards and try to make unique hand compositions. the main problem i was struggling with was storage and access of the random cards, so i was hoping for some clarification or inventory and display alternatives.
the basic draft idea was to create a random card by creating an array with 3 indexes, each storing a basic int related to the card. it’s durability, face value, and suit. basically like a serial code
var card_array = [durability, face, suit]
i can create these values and store them easily with randi functions,
var face = randi range (1,13)
and can send them to an array in an autoloaded inventory script / scene,
autoloaded_inventory_array.append(card_array)
but the struggle comes when trying to fetch them from this inventory for gameplay. on the either end i can display them with some probably clunky code
if suit int = 3: 2dsprite.texture = clubs
but i’m not worried about that right now.
this works fine for the card array creation, display, and basic / flawed inventory system. the problem happens when i try and fetch the stored randomly generated arrays and use them or even display them in another scene.
i’ve tried calling for premade card arrays that i stored in the autoload inventory by their expected index. i’m assuming that [0] will always return something if the array is populated
array_to_be_textured = autoloaded_inventory.variable_inventory[0]
but i it returns
“invalid get index[ 0 ] (on base array)”
which i think means that the code can’t find anything in the designated autoloaded inventory, which also confuses me. it doesn’t even find , so i guess can’t make the connection in the first place? like i said, i dont know how to code.
so this is the initial problem, as far as i can figure, im struggling to fetch data from an autoload, specifically a nested array therein. if i can solve this, onto the next struggle, but i’m open to alternatives.
i’ve done some research on dictionaries and i cant tell if they’re better than arrays here. they are popular, but seem stricter, and some people say that they can get clunky if you only need to store small bits of data, and 3 int seems like not a lot. most people seem to go with dictionaries, custom resources, and class names for their item systems, but i all of the examples i’ve seen are for premade, simple items with few or no fluid properties, and i don’t quite understand how to make any of these mesh with my prelim idea, assigning random numbers to them as i please and saving that unique set of 3 numbers as it’s own callable instance.
i want to keep these values pretty fluid, as i might be able to just swing them into the scoring system, and also i definitely want to be able to change them in-game at later points. reduce card hp so they break eventually, make it so the suits can be forged or changed by shops, that kind of thing. as such, since the properties of each individual item will be changing regularly and dynamically, so it makes me really not want to make every conceivable of a card as an individual scene and try to call and pass that custom resource.
like i said, i’m very new and probably burnt out from trying to understand so many articles, but i havent been able to find any topics that cover this exact problem, probably because it’s inefficient and everyone knows to avoid it.
basically, i need someone with a lot of patience to explain this to me like im a baby. any help and advice is appreciated, have a good one