i need it to do if it equals the pack number it sets the pack cost to that specific packs cost but it just prints it as a quote instead of getting the number
var Pack_selection = {
pack = 1,
pack_cost = 0,} ← trying to set this number to pack cost
var Card_pack1 = {
pack_number = 1,
this_pack_owned = 0,
pack_cost = 0,} ← thist is the pack cost of selected pack
func _process(delta: float) → void:
Pack_selection.pack_cost = “Card_pack” + str(Pack_selection.pack) + “.pack_cost” ← the idea **
print(str(Pack_selection.pack_cost))** ← this just prints “Card_pack1.pack_cost” instead of the cost 0**
pass**
Worked like a charm thanks I felt like it could have been something simple but I didn’t understand the get function when looking it now I can sorta understand it more
would happen too know how to figure this out i thought it would be similar to this but i was wrong
var Pack_selection = {
pack = 1, ← getting this pack
pack_cost = 0,}
var Card_pack1 = { ← this pack is the one selected
pack_number = 1,
this_pack_owned = 0, ← then add increase this number
pack_cost = 0,}
func _on_purchase_button_pressed() → void:
if str(stats.money) == str(Pack_selection.pack_cost):
get(“Card_pack” + str(Pack_selection.pack)).get(“this_pack_owned”) += 1 ← i thought this would it does not
pass
if you do know or do not wish to respond it is perfectly fine i will make another post on help soon
But as you can see, it gets pretty ugly real quick. You’re trying to use Dictionaries as objects, which I would advise against it.
Make a CardPack its own class of type Resource and assign properties to that class that you can adjust. Otherwise your codebase will quickly become an unreadable spaghetti.
BTW, please format your code snippets as preformatted text with triple backticks ``` at the beginning and end of the snippet.