Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | HarryCourt | |
Old Version | Published before Godot 3 was released. |
Why doesn’t the RichLabelText not change when I change an int in another script? I’m out of ideas.
Using Godot 3.0beta1
ItemBuy.gd:
extends Button
# Variables
onready var counter = get_node("/root/World/Counter")
onready var counterInt = get_node("/root/World/Counter").get("counter")
onready var timer = get_node("/root/World/Counter").get("timer")
func _ready():
pass
# The Buy Button
func _on_Button_pressed():
if (counter.powerCandy == false):
counter.powerCandy = true
print("Candy Bought!")
self.set_text("Bought!")
func _on_Timer_timeout():
# Add money!
if (counter.powerCandy == true):
counterInt += 10
print("Added money (Candy)")
RichLabelScript.gd:
extends RichTextLabel
# Things that actually make the game work
onready var counter = 0
onready var timer = 0
onready var pressed = false
# Power Up Varibles
onready var powerSign = false
onready var powerCards = false
onready var powerEmployees = false
onready var powerDrinks = false
onready var powerCandy = false
func _ready():
# Tell what to do when the "Play" button is pressed.
set_process_input(true)
self.set_text("Money: $0")
func _process(delta):
# Tap, Gain, Repeat...
var press = Input.is_action_pressed("Press")
if press and not pressed:
print("Tap")
counter += 1
self.clear()
self.add_text(str("Money: $", counter))
pressed = press
func _on_Timer_timeout():
counter =+ 1
self.clear()
self.add_text(str("Money: $", counter))