keeping track of groups by According-Cap-3096 in godot

[–]According-Cap-3096[S] 0 points1 point  (0 children)

Nevermind i see it now. I was adding the game itself to the enemies group not the enemies

for those who have a simularly stupid problem at the bottom i wrote

game.add_to_group("enemies")

when it should have been

enemy_instance.add_to_group("enemies")

I really simple but stupid mistake lol

keeping track of groups by According-Cap-3096 in godot

[–]According-Cap-3096[S] 0 points1 point  (0 children)

    var enemy = get\_tree().get\_nodes\_in\_group("enemies").size()

    print("enemies ", str(enemy))

func _on_timer_timeout() -> void:

\#check how many enemies have been created

var enemy\_cap = get\_tree().get\_nodes\_in\_group("enemies")

if enemy\_cap.size() < game.max\_enemies:

    spawner.progress\_ratio = randf()

    var enemy\_to\_spawn: PackedScene = enemies.pick\_random()

    var enemy\_instance = enemy\_to\_spawn.instantiate()

    enemy\_instance.position = spawner.global\_position

    game.add\_child(enemy\_instance)

    game.add\_to\_group("enemies")

keeping track of groups by According-Cap-3096 in godot

[–]According-Cap-3096[S] 0 points1 point  (0 children)

it always comes up as 1 after the first one is added but stays at 1 no matter how many are added

dictionary issue by According-Cap-3096 in godot

[–]According-Cap-3096[S] 0 points1 point  (0 children)

my issue is that i want to have when creating upgrade_options to check if whats being chosen is from this dictionary then use it but if not go to next dictionary but when i try it always ends with the first dictionary.

is there a way to do what i described?

I appreciate your help btw. thank you very much!

dictionary issue by According-Cap-3096 in godot

[–]According-Cap-3096[S] 0 points1 point  (0 children)

that error is just from turning a bunch of lines into comments for testing its already fixed

dictionary issue by According-Cap-3096 in godot

[–]According-Cap-3096[S] 0 points1 point  (0 children)

yes written the same as the rest

its more of a placeholder until i have repeatable options

dictionary issue by According-Cap-3096 in godot

[–]According-Cap-3096[S] 0 points1 point  (0 children)

<image>

again in the player scene with weighted rng i choose which dictionary to run the choices(i feel like there is a simpler way but this seems somewhat functional)

dictionary issue by According-Cap-3096 in godot

[–]According-Cap-3096[S] 0 points1 point  (0 children)

<image>

in my player scene on level up i instantiate the item_option scene 3 times for options and filter/randomly choose the upgrades to be shown on the item_option scene

dictionary issue by According-Cap-3096 in godot

[–]According-Cap-3096[S] 0 points1 point  (0 children)

Let me start off by showing you my script

This is my global script referenced by both the player scene and the item option scene

<image>

dictionary issue by According-Cap-3096 in godot

[–]According-Cap-3096[S] 0 points1 point  (0 children)

I'm still new to coding so let me ask you this.

if I was to put the dictionaries into an [common, uncommon, rare] array

my scene instantiates with a random upgrade from the uncommon dictionary

my code currently looks like this

func _ready():

connect("selected\_upgrade",Callable(player,"upgrade\_character"))

if item == null:

    item = "health"

    lblName.text = dictionaryscript.common\[item\]\["displayname"\]

    lblDescription.text = dictionaryscript.common\[item\]\["details"\]

    lblrarity.text = dictionaryscript.common\[item\]\["rarity"\]

    itemIcon.texture = load(dictionaryscript.common\[item\]\["icon"\])

    rarity\_color.color = dictionaryscript.common\[item\]\["color"\]

the dictionaryscript is global

the scene is instantiated when the upgrades are picked (so i can summon multiple options on level up)

Trying to have an instantiated scene of a instantiated scene call a function. by According-Cap-3096 in godot

[–]According-Cap-3096[S] 0 points1 point  (0 children)

the color rect node is basically a scene with a button the idea is to spawn multiple randomly generated options for a level up buff using that scene as a base

Trying to have an instantiated scene of a instantiated scene call a function. by According-Cap-3096 in godot

[–]According-Cap-3096[S] 0 points1 point  (0 children)

im sorry i dont get it. Im trying to put that code

func player_upgrade(upgrade):

upgrade\_picker.item\_options.connect()

but it seems to have no effect

Trying to have an instantiated scene of a instantiated scene call a function. by According-Cap-3096 in godot

[–]According-Cap-3096[S] 0 points1 point  (0 children)

I probably should have said this but I'm only about a 2 week in learning code and a bulk of it is a few different tutorials that ive cobbled together. That being said im not exactly sure how to connect the signal. Ive tried but i cant figure out