Godot Version
4.5
Question
The purpose of “Globals.cities[Globals.selected_city][1] += 1” is to increment the value of the array entry, but that doesn’t seem to happen. Also, neither of my print statements show in Godot’s output for some reason. Code below:
func create_airship_icon():
#Used to determine airship's speed
var random_num_generator = randi_range (1, 10)
if random_num_generator == 10:
speed_multiplier = 0.08
#Generates airship button
var airship = Button.new()
#Spawns new airship button in World Map
airship.icon = load("res://sprites/Airship_icon.png")
airship.flat = true
var origin_vector = Vector2(map_to_local(Globals.cities[Globals.selected_city][0]))
airship.position = origin_vector
add_child(airship)
#Replace the random selecting of cities with a menu of available cities the player can choose from
var destination_vector = Vector2(map_to_local(Globals.cities[Globals.selected_destination_city][0]))
var final_distance = origin_vector.distance_to(destination_vector)
#Moves the spawned airship button from the origin to the destination cities
var tween = airship.create_tween()
tween.tween_property(airship, "position", destination_vector, final_distance * speed_multiplier)
await tween.finished
#Updates airship count at destination city after airship arrives
Globals.cities[Globals.selected_city][1] += 1
print(str(Globals.cities[Globals.selected_city][1])) #<---Doesn't print
#Resets variable value
speed_multiplier = 0.1
#Updates balance with income
Globals.balance += int(Globals.cargo_amount)
cumulative_income += Globals.cargo_amount
#Calculates passenger income
if Globals.passenger_enabled == true:
var passenger_count = randi_range(10, 300)
cumulative_income += (passenger_count * 10)
if Globals.cities[Globals.selected_city][3] == 1:
var hotel_income = 200
#Assumes 25% of passengers boarding came from the hotel
cumulative_income += (passenger_count * 0.25 * hotel_income)
income()
#Updates balance with fuel expenses
var fuel_cost = Globals.monthly_expenses["Fuel"] * final_distance
cumulative_fuel_cost += fuel_cost
Globals.balance -= fuel_cost
fuel_amt.text = str("$ " + str(int(cumulative_fuel_cost)))
airship.queue_free()
update_balance()
print ("Does print even work?")