Godot Version
4.2 1Question
Hello, I'm very new at programing and I'm making a simple RPG game following a few tutorials. I currently have some problems with the code because I'm trying to call a script that I called "global" to another script and it just keeps telling me that "global" isn't declared in the current scope and I don't know what to do because in the tutorial this problem doesn't happen, can someone please help me?Here’s the code I used (the script that I’m trying to call is named “global.gd”):
extends Node2D
func _ready():
pass # Replace with function body.
func _process(delta):
change_scene()
func _on_bar_transition_point_body_entered(body):
if body.has_method (“LeazarSprings”):
global.transition_scene = true
func _on_bar_transition_point_body_exited(body):
if body.has_method (“LeazarSprings”):
global.transition_scene = false
func change_scene():
if global.transition_scene == true:
if global.current_scene == “Mundo 1”:
get_tree().change_scene_to_file(“res://bar.tscn”)
global.finish_changescenes()
And here’s the global script:
extends Node
var current_scene = “Mundo 1” #Mundo 1 bar
var transition_scene = false
var player_exit_bar_posx = 0
var player_exit_bar_posy = 0
var player_start_posx = 0
var player_start_posy = 0
func finish_changescenes():
if transition_scene == true:
transition_scene = false
if current_scene == “Mundo 1”:
current_scene = “bar”
else:
current_scene = “Mundo 1”