–2 votes

So I finally figure this out but I have a problem. This code here
if Global.Notation[0].length() > Global.MAX_DIGITS:
$Label.text = "Wasted Time: %se%s" % [String(Global.WTTN), String(Global.WastedTimeTotal).length() - 1]
$Label.text = "Wasted Time: " + str(Global.WastedTimeTotal)

Sits under _process which I though updates constantly but this code that is suppose to change WastedTimeTotal (My currency) into Scientific Notation once it hits 11 digits long
only works if I change the currency in the script to the 11 digit mark.
So if my WastedTimeTotal = 10000000000 then it will show 1e10 on load
but if I have WastedTimeTotal = 9999999999 and use a button to add one to push it to 11 digits long it doesn't change to 1e10. Just in case it's needed here is my full code.

This is my main code

extends Node2D

func t(time):
return gettree().createtimer(time)

func ready():
#Sets the Superhero Progress bar when swapping back to Game Screen

func process(delta):
#Checks if Time Wasted Total is greater than the maximum digit limit if so reduced to scientific notation
if Global.Notation[0].length() > Global.MAXDIGITS:
$Label.text = "Wasted Time: %se%s" % [String(Global.WTTN), String(Global.WastedTimeTotal).length() - 1]
$Label.text = "Wasted Time: " + str(Global.WastedTimeTotal)
#Allows the Superhero Progress to increase
Global.SuperheroTotalProgress = $Superhero/SupheroProgress.get
#Resets Superhero Progress to 0 when bar is full and disables the
#Superhero Button until process is done
if $Superhero/SupheroProgress.getmax() == Global.SuperheroTotalProgress:
$Superhero/SupheroButton.disabled = true
tree().createtimer(.05), "timeout")
$Superhero/SupheroButton.disabled = false

func SupheroButtonPressed():
#This adds Wasted Time for each click of the Suphero Button
Global.WastedTimeTotal = Global.WastedTimeTotal + Global.WTPerSuperheroClick
#Sets the value of the Superhero Progress bar to + "1" for each click

Switches to Upgrades Screen

func onUpgradespressed():
scene("res://Game Screen/Upgrades.tscn")

Switches to Upgrade Screen

func onMicrotransactionspressed():
scene("res://Game Screen/Microtransaction.tscn")

My Global Code
extends Node2D

Total amount of Wasted Time (Main Currency)

var WastedTimeTotal:float = 10

Amount of Wasted Time from clicking the Superhero Button

var WTPerSuperhero_Click:float = 1000000000

Turns the total amount of Wasted Time into a string

var WTT = str(WastedTimeTotal)

Uses the string above to pull the first number from the float

var WTTN = float(WTT[0])

Stops player from desyncing Supherohero Button and Progress

var timer

How much the Superhero progress bar is at out of max

var SuperheroTotalProgress:float = 0

How much the Superhero Button Increases per click

var SuperheroIncrease:float = 1

Used to turn Wasted Time into a String then used to count all places after the first number for Scientific Notation

var Notation = String(WastedTimeTotal).split(".", false, 1)

How many total numbers are allowed before being turned into notation

const MAX_DIGITS: int = 2

Don't know really copied this guessing it's for scene change

var current_scene = null

func ready():
#Both lines are for scene change
var root = get
scene = root.getchild(root.getchild_count() - 1)

func goto_scene(path):
# This function will usually be called from a signal callback,
# or some other function in the current scene.
# Deleting the current scene at this point is
# a bad idea, because it may still be executing code.
# This will result in a crash or unexpected behavior.

# The solution is to defer the load to a later time, when
# we can be sure that no code from the current scene is running:
#Scene change again
call_deferred("_deferred_goto_scene", path)

func deferredgotoscene(path):
# It is now safe to remove the current scene

# Load the new scene.
var s = ResourceLoader.load(path)

# Instance the new scene.
current_scene = s.instance()

# Add it to the active scene, as child of root.

# Optionally, to make it compatible with the SceneTree.change_scene() API.
Godot version 3.2.3.stable.mono
in Engine by (16 points)

PS: In the future, please use more a descriptive title for your questions instead of "Why isn't this working?".

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.