0 Favourites

Problem with counting up a global variable

  • Problem Description

    ____ i am creating a text based adventure but somehting really strange it happening to one of my global variables. ill need to explain a few thing to give the context so here we go... so i was attempting to create a system that could write out lines of text letter by letter, after many hours of frustration and researching i finally came up with a solution where i stored my text in a global variable called outputTextWriting, and then i would use the mid() function to pick out each letter one at a time. now the problem with this is that if i wanted a new line usually you would just type in: ""&newline&"" but because its stored in a global variable it would just type that out instead of recognising it a function. to counter this problem i would enter only the first paragraph into outputTextWriting and then set it up so that whenever it has finished writing, it would start a newline and then replace what was in the global variable to the next paragraph. i created a new global variable called eventMarker. the idea was that whenever a paragraph ended, it would add 0.01 to the variable. for example: if eventmarker = 1.11 then set outputtextwriting to"[insert something here]" . this meant that i could use this new global variable to write a paragraph then ad a newline then start the next paragraph. now... the stupid thing that i hope is just a bug and not an error in my code is that every now and then instead of transitioning from 1.11 to 1.12 for example it will instead got to 1.12000000000000001.......... which is a real problem as you can imagine..... just to add on to this it isn't completely random. there are 3 specific times that this happens as you will see in my capx.. please help____

    Attach a Capx

    ____ ____

    Observed Result

    ____ well instead of adding to the global variable in intervals of 0.01 but instead at very specific points it doesn't go up at an interval ____ of 0.01 but instead it will ad something like 0.010000000000001..... or 0.09999999999996.......

    Expected Result

    ____ the global variable should just count up in intervals of 0.01 ____

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Have a look at this:

  • Have a look at this:

    sorry but I've solved my problem while also actually cutting down on my coding but thanks so much for helping! i have to admit, your definitely better at coding than me XD. I found it quite hard to get my head around your coding but its very ingenious!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)