Heptagono's Forum Posts

  • Hello,

    I've been trying to show only two decimals from a variable.

    To do so, I use :   int(NUMBER*100)/100

    But it do not work.

    Image

    <img src="https://www.dropbox.com/s/fln9seqkyn1mata/codigo.jpg" border="0">

    And the project file is:

    dropbox.com/s/81gfxs6xxuvzhd3/Decimal-Test.capx

    project

    Why it do not act as suposed?

  • Yes, and I have made a new version of my input Box, But still needs improvement:

    The idea is show in the project:

    https://www.dropbox.com/s/o7xvlptfyuyrf1v/textbox.capx

    And the code is there:

    image of the code

    Any idea on how it doesn't work?

  • It's being rather crazy to create an specialized input system that only takes numbers and show them on the TextBox.

    As you can see in this image, I've coded this:

    <img src="https://www.dropbox.com/s/2hcwoji8p9enbf3/code.png" border="0">

    dropbox.com/s/2hcwoji8p9enbf3/code.png

    And the project is:

    input.capx

    dropbox.com/s/nx1w9zls9j5o8k5/input.capx]input.capx

    But no decimals are shown in the textbox.

    (Sorry for the inconvenience, but the system doesn't shows images by now)

  • I would like to know how to make a TextBox act as an input just to certain extent. Let's say that I only want to take float numbers from 0.00 to 10.00, and while they are being typed by the user into the box, I want it to show not more than two decimals and no other numbers but these between those limits.

    So, if I write 5.04 in the textbox will be shown 5.04

    If........     5.04564 in the textbox will be shown 5.04

    If........    H5.00023 in the textbox will be shown nothing due it's not a number.

    If........    45.4523 in the textbok will be shown 10.00, due it's the max value of the rank I would define.

    Any idea on how to implement this?

    By now I'm using these instructions:

    clamp(float(replace(TextBox.Text,",",".")),0,10)

    But it seems only useful in order to avoid the problem of using commas instead of dots and to define the limits of my desired rank...

    Any help would be welcome. With this effort we could better the way construct takes data, and perhaps create a good tutorial.

  • Tanks! It works

  • mindfaQ, thanks a lot for your answer. It has given me the key to solve the problem. Two thumbs up!

  • Hi!

    I am trying to make this buttons change the values of some gobal variables.

    By now, all the buttons are the same object, and I'm calling each instance of them by looking at each's instance UID.

    So, the code looks like:

    <img src="https://www.dropbox.com/s/5rdxcz4u8ya7vkk/code.png" border="0">

    code

    And the project's layout is:

    <img src="https://www.dropbox.com/s/bxnukiv0kbabqba/layout.png" border="0">

    layout

    Unfortunately, the idea doesn't works and even clicking on the buttons and the variables don't change. Perhaps the code isn't correct.

    Here is the project file:

    test_instances.capx

    I presume that picking an instance n? is the same as select its UID.

    Any advice on why buttons don't change the variables as they're supposed to do?

  • Quote:

    -------------------------------------------

    If I recall correct, it is not enough to clamp them into the value range, they need to be integer values. Have you tried to set the (range corrected) values with

    "rgb("&int(red)& ... etc.?

    -------------------------------------------

    THAT WAS THE KEY!!!!!!

    GREAT!!! IT WORKS PERFECT.

    Thanks a lot, I was looking for a solution for this for weeks!

  • Hi!

    I've just tried this

    "red green and blue need to be integer values in the range [0, 255]. Setting green and blue to loopindex give them values above 255, which is invalid"

    changing the values of blue and green to make them remain between 0 and 255. But this still doesn't works and the result is a grey box.

    What else could be happening?

  • Hello,

    I'm involved in a project where the aim is to show a variable color pattern depending on a formula values. Although my efforts, I'm only obtaining a constant value of grey in the zone supposed to show a variable pattern from red to black. And I can't guess why.

    Here is the code:

    <img src="https://dl.dropboxusercontent.com/u/87172782/Patterns/crop.png" border="0">

    And the result:

    <img src="https://dl.dropboxusercontent.com/u/87172782/Patterns/Result.png" border="0">

    And, of course, the project:

    https://dl.dropboxusercontent.com/u/87172782/Patterns/Pattern.capx

    Anyone could give me a clue to find out why this is not being drawn as it's supposed to?

  • Hi mindfaQ,

    I've prepared this clear version of the test. Below the waves box you will see a black box, which is aimed to represent a pattern of vertical lines with different color values, from white to black, depending on the point of the wave represented alog the x axis: maximum point white, minimum point black.

    The x represents in the formula the whole lenght of the box, although I suspect it's aimed to be used only to show a point. If so, I fear all this effort could be in the wrong direction.

    By now, the version of the proyect is here:

    Test.capx

    What do you think?

  • Not sure what you mean with that. The code already does that, no? The slider is not a necessity.

    Ok, I've worked out a better explanation for this:

    Well, I mean that if we have two formulas to pick up the value of Amplitude and Period, let's say the ones I'm trying to implement:

    Amplitude: 4 * cos^2(Pi*X/Period)

    Period: Omega * Distance1 / 2 * Factor

    Omega and Factor are given by two sliders.

    They result in two real values, if they are introduced as variables in Draw Line:

    Having a sinus in the Y term, we can find ourselves with a wave that doesn't depicts the numbers from our mathematical formulae.

    That's the issue. I Hope this has been clearer. Tell me what do you think.

  • Here you have an example of System's Loop's misunderstoodment. It's probably the reason of seeing nothing shown at the screen:

    Code

    Project

    It's supposed to work because it's a loop and inside it there are some graphic instructions, isn't it?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • mindfaQ, there is something that I want to ask you.

    Can I use an Amplitude and a Period value to draw a wave with the code you have showed me?

  • Wonderful solution!

    Now I can see that the appoach that I was using was not the best way to pick up a proper result. I'm goint to test It and tell you how it has been.

    Thanks and cheers!