Problem with counting up a global variable

Get help using Construct 2

Post » Sat Jan 21, 2017 1:36 am

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
____ https://www.dropbox.com/s/xfqfcplmpl2l8 ... .capx?dl=0 ____

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 ____
.
B
18
S
4
Posts: 10
Reputation: 1,074

Post » Sat Jan 21, 2017 1:43 am

ImageImageImage
B
71
S
22
G
249
Posts: 3,762
Reputation: 138,575

Post » Sat Jan 21, 2017 11:57 pm

blackhornet wrote:Have a look at this: viewtopic.php?t=186556&p=1092869#p1092869


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!
.
B
18
S
4
Posts: 10
Reputation: 1,074


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests