diff --git a/scenes/power_station.tscn b/scenes/power_station.tscn index 1f0f70d..60c5f38 100644 --- a/scenes/power_station.tscn +++ b/scenes/power_station.tscn @@ -17,4 +17,8 @@ coins_required = 0 [node name="MeshInstance" type="MeshInstance" parent="."] mesh = SubResource( 1 ) +[node name="CointCount" type="Label3D" parent="."] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0275149, 0.721019, 1.58046 ) +billboard = 1 + [connection signal="coin_requirement_met" from="coin_machine" to="." method="_on_coin_machine_coin_requirement_met"] diff --git a/scripts/power_station.gd b/scripts/power_station.gd index c90b2c5..af0b532 100644 --- a/scripts/power_station.gd +++ b/scripts/power_station.gd @@ -3,11 +3,15 @@ extends Spatial export var max_charge_capacity : int = 1 export var time_to_generate : float = 120 -var current_holding : int = 0 +var current_holding : int = 0 setget set_current_holding var current_timer : float = 0 +func set_current_holding(new_value): + current_holding = new_value + $CointCount.text = "Charge Count: %d" % current_holding + func _ready(): - pass # Replace with function body. + set_current_holding(current_holding) func _process(delta): current_timer += delta @@ -18,12 +22,12 @@ func _process(delta): func generate_charge(): if current_holding >= max_charge_capacity: return - current_holding += 1 + self.current_holding += 1 print("power station: charge generated") func collect_charges_from_station(): var charges_to_return : int = current_holding - current_holding = 0 + self.current_holding = 0 return charges_to_return func _on_coin_machine_coin_requirement_met(player):