0 votes


Get an int from the user and output it.

in Engine by (93 points)
edited by

This is nowhere near the original question

Hi, sorry about that, I tried to simplify my ask.
I had some problems in my error checking too.
I got the correct int input once I fixed my conditional operators..
I ended up using stepify to round the float to 2 decimal places.
I got everything working.
Thanks for the feedback.

2 Answers

0 votes
Best answer


 func _on_CalcResult_pressed():
    # Get input from node
        QTY = int(get_node("../UI/QTY").text)
        # print output as int
by (93 points)
+1 vote
var value_float = rand_range(0, 10) # random float between 0 and 10
var value_int = randi() % 11 # random in between 0 and 10

to specify a range for the int version you could use a function like:

func rand_int(_min, _max):
    return (randi() % (_max + 1 - _min)) + _min
by (1,656 points)
reshown by

Thanks, however I am not looking to randomize anything here.

I wish to get input from the user and output it.

I solved the problem and provide the solution.

Not sure what is going on with all the down votes, but anyways... Maybe you could try using the stepify function: https://docs.godotengine.org/en/3.1/classes/[email protected]#class-gdscript-method-stepify

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.