Ok, i'm really bad at coding. I'm especially new to GODOT and am trying to make a 2d game. I've been able to set cant_move to false when dialog is playing, the problem I'm having is making cant_move true again. I don't even know where to put done = true on the dialog script (I kinda just put it in a random place and hoped it would work). Here is my dog-shit code. (the solution is probably easy im just really dumb)
npc script
`extends Area2D
var done = true
func _ready():
Global.npc1 = self
func _exit_tree():
Global.npc1 = null
var can_interact = false
const DIALOG = preload("res://dialoguebox.tscn")
func _physics_process(delta):
$AnimatedSprite.play()
func diaplay():
if done == false:
Global.player.can_move = false
print("test")
if done == true:
print("test2")
can_interact = false
Global.player.can_move = true
func _on_Area2D_body_entered(body):
if body.name == "player":
$Label.visible = true
can_interact = true
func _on_Area2D_body_exited(body):
if body.name == "player":
$Label.visible = false
can_interact = false
func _input(event):
if Input.is_key_pressed(KEY_E) and can_interact == true:
done = false
diaplay()
$Label.visible = false
var dialog = DIALOG.instance()
get_parent().add_child(dialog)
dialog.position = $Position2D.global_position
dialog script
extends Control
var dialog = [
'sampletext',
'sampletext2',
]
var done = false
var dialog_index = 0
var finished = false
func _ready():
load_dialog()
Global.DialogBox = self
func _exit_tree():
Global.DialogBox = null
func _physics_process(delta):
$"Ind".visible = finished
if Input.is_action_just_pressed("ui_accept"):
load_dialog()
func load_dialog():
if dialog_index < dialog.size():
finished = false
$RichTextLabel.bbcode_text = dialog[dialog_index]
$RichTextLabel.percent_visible = 0
$Tween.interpolate_property(
$RichTextLabel, "percent_visible", 0, 1, 1,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT
)
$Tween.start()
if dialog_index >= 0:
Global.npc1.done = true
else:
queue_free()
done = true
dialog_index += 1
func _on_Tween_tween_completed(object, key):
finished = true