|Attention||Topic was automatically imported from the old Question2Answer platform.|
Based of my first question
Script ‘GlobalVariables’ with global variables
extends Control #Interface Player #PLAYER BASIC ATTRIBUTES (F.E. NO CLASS DEFINED) var PlayerLevel = 1 # Shows the players current level. var PlayerEXP = 0 # Shows the players current experience. var PlayerHealth = 40 # Shows the players health. var PlayerMana = 40 # Shows the players mana.
These variables are basically for being changed - means, that they will rise/fall with certain events. So I tried to increase the player’s level by one by pressing a fixed key defined by a InputEventKey
extends Label #DEBUG COMMANDS func _unhandled_input(event): if event is InputEventKey: if event.pressed and event.scancode == KEY_KP_0: GlobalVariables.PlayerLevel += 1 print("+ 1 Level to PlayerLevel")
The print command get displayed in the console - basically works - but is not changed in the label itself.
I assume that there is a setget function required, to update the latest to the newest int. Is that right?
How do I set up the setget function (which will be required also for item amounts, that withdraw or adds)? I guess, that you are checking the current int in the label and setting it to the latest - but how do you do that?
Many thanks in advance!