How to create a simple calculation with user input integers

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By _vindicator

Hi! I am very, very new to programming in general. I took up this mini project as my first one, but I’m unsure how to figure it out. Any pointers, tips, nudges in the right direction would be really appreciated.

I thought I’d make a little app that output the most complicated calculations for a tabletop RPG.

Example image

This is what I have so far. The calculation is 0.5y * (100-x). Nodes are TextEdits and Button…

Any tips for how to have it take in the numbers written in xTextbox and yTextbox, store them as x and y, and then carry out the Calculation with these values (and then display it underneath)?

I think studying this working code would really clear up a ton of things about Godot for me.

Thanks so much if you take a look at this!

:bust_in_silhouette: Reply From: jgodfrey

Generally, you’ll want to use the Expression class to do the heavy lifting here. There are some basic guidelines and examples of expression evaluation here - including passing variables to expressions.

Additionally, here’s a somewhat lengthy discussion from a similar question with some valid input and pointers.

Thank you so much! I’m still in the stage of “beginner” where I am struggling with what exactly to even Google search. :slight_smile:

_vindicator | 2022-12-13 00:57

You’re welcome.

jgodfrey | 2022-12-13 01:25