Include a script but the included script makes refrances to the includer script godot

for example hello.gd

var hello = "Hello"
@onready var World = get_parent().get_node("/root/World")
print(World.world)
print(hello + " " + World.world)```

world.gd

```extends Node
var world = "world"
@onready var Hello = get_parent().get_node("/root/hello")
print(Hello.hello)
print(Hello.hello + " "+ world)```

for context this is a rpg like game where theres moves that do damage and stuff and one file and the main scene in the other file

both nodes won’t be ready at the same time if they are siblings. Generally a bad idea to use get_parent() in conjunction with @onready. You might have a better time with @export and/or not using such nodes on _ready

didnt know about @export ill go look it up real quick

looked it up but how would this help me? elif entity == "player": if Main.player.atk != 1: print(Main.enemy.hp) Main.enemy.hp -= (Main.player.atk / 2) Main.textudt("Nate used slap and did "+str(Main.player.atk / 2)+" damage!") print("plr dmg") print(Main.enemy.hp) Main.refreshbars() else: Main.enemy.hp -= 1 Main.textudt("Nate used slap and did 1 damage!") Main.refreshbars() this is a move where the Main class is the main script that all the other ones like the moves script get tied together

	match $non_shadowed/moves_menu/Move1.text:
		"Slap" :
			Moves.slap("player")``` thats the ```Main``` class referencing the Moves class

I do not understand what this has to do with the original script. Make sure to paste large scripts in a block, on a new line between three ticks like so.

```
type or paste code here
```

i have a few ideas ill try them first and post if i get any results i am not very good at making questions lol

1 Like

when you make a new class with class_name and then in a new script do this


var Newclass = classthing.new() 

is this a NEW copy of the class or is it referencing the same one

It is a new node

how do i get the same one?

@export is a very good option

@export var my_custom_node: classthing

If it is a child you can use the $ notation to get any named node

@onready var my_custom_node = $ClassThingNode

If you only have one, to be used globally, then an Autoload might be more useful

1 Like

thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.