TextBox: Special Configurations

  • 7 favourites

Attached Files

The following files have been attached to this tutorial:



Download now 172.26 KB


3,654 visits, 5,607 views



This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Let's presume that you want to create a very special textbox in order to create, for instance, a character sheet for a role playing game.

So that we will start with a very basic set up: Only a TextBox for a skill, let's say, dexterity.

Dexterity must be a value from 0 to 3 in our game.

We create a TextBox in the Layout and write down a code like this:

Note that the TextBox is set as a Number Type.

The needed code is this:

First of all, we call a principal condition: System: Every Tick

After that, we create a local variable (number type). We will call it Buffer. It will be useful for pick up values afterwards and send them to our character's creation algorithms.

Then, we get ride of the problem of what numbers do we get. So we define a multiple condition:

If TextBox.text is >= 0, and 0<= int(TextBox.Text)<=3 ---> Set text to TextBox.Text and buffer to int(1number.Text)


(If what has happened before is false, the program will go on this way) --> TextBox.Text = ""

Then we will have a special TextBox that only takes values from 0 to 3.

BUT it's important to point out that there is a very big failure in this approach. We will find that if we type 1, the textbox shows, obviously, a number 1. Since here, everything will be perfect.

But let's type again a valid number, for instance, 3. Then, the TextBox will show nothing but a blank space. We will be forced to write again the desired value to see it in our textbox. And this, it seems a limitation of Construct 2 that could be unavoidable.



Download now 172.26 KB

  • Order by
Want to leave a comment? Login or Register an account!