So, I have this good bit o' GDScript code:
extends Label
onready var QuitLabel = get_node("/root/LevelTemplate/Quit")
func getPowerState():
if OS.get_power_state() == 1:
return("not on charge")
elif OS.get_power_state() == 3:
return("charging")
elif OS.get_power_state() == 2:
return("plugged into a socket")
elif OS.get_power_state() == 0:
return("doing weird things")
func _process(delta):
if OS.get_name() == "OSX":
QuitLabel.text = ("Press CMD + Q to quit. Battery is " + getPowerState())
else:
QuitLabel.text = ("Press CTRL + Q to quit. Battery is " + getPowerState())
Now, nothing SEEMS wrong right? Well, when the player plugs their laptop (<-- example) in, it shows charging and when they unplug it, it shows not on charge HOWEVER, if they plug it in again, the game would freeze with this error:
Invalid operands 'String' and 'Nil' in operator '+'.