Estecka's Forum Posts

  • Thanks. I had completely misunderstood how Function.ReturnValue was supposed to work.

    Somehow I thought it was meant to work inside the function and that it couldn't work outside of it.

  • Solved:

    trouble-operating-returnvalue_p1064184?#p1064184

    Problem Description

    After triggering a chain of functions that does literally nothing, the one function that does an actual thing quits giving the right result.

    Attach a Capx

    https://filebin.net/g3iiun5rydcxsar7

    Description of Capx

    A function "Zéro" changes its return value twice: first to 100, then under a specific condition to 0. the final result is displayed onscreen.

    When pressing Space, a function "Wreck" is called, it then calls another function which does nothing.

    Expected Result

    The condition to change Zéro()'s result 0 should always be right and thus, the function Zéro() should always return 0

    Steps to Reproduce Bug

    After running the project, simply press Space to call Wreck().

    -> The result of Zéro() changes to 100, and remains this way.

    Observed Result

    • The event 2 needs to be comparing Function.ReturnValue in order for the bug to happen.
    • The function called by Wreck() doesn't need to exist, but there need to be at least two chained calls.

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES)
    • Edge: (YES)

    Operating System and Service Pack

    Windows 10

    Construct 2 Version ID

    r233

  • korbaach

    So, you mean that if being returned the returnvalue of "One" instead of "Two", it's because the returnvalue of two isn't yet calculated when I request it?

    But then :

    Shouldn't I be returned 3 in the second case as well, instead of 10 ?

    So the code is the equivalent of:

    ReturnValue = 2*ReturnValue

    Which of coarse gets confused.

    Why does it confuse Construct? It's a thing I use all the time and again, for as long as it doesn't involve a function it works perfectly fine:

    -Set return value to 10

    -Set return value to 2*returnvalue

    will properly work, it's

    -Set return value to somefunction

    -Set return value to 2*returnvalue

    that messes up.

    I don't really see the relation here.

    ---

    To be clear I have worked around this in my project, at this point what I want is understanding why it behaves in such a weird way.

  • Why is it working this way?! Why does waiting nothing suddenly makes it work?

  • The best way I can think of is to simply erase the value you've just called from the array.

  • I don't think it's possible to dynamically build a reference toward a variable. However it is possible to build references toward a dictionnary's keys this way.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So, I have a project with two levels of function:

    "One" is some basic math operation, here I want it to arbitrary return 10

    "Two" 's are different fashion of reusing the formula, here I want it to arbitrary return twice the previous result, so 20

    I set the return value of "Two" only once in the code, and yet, it does not return the same value at different point of the code:

    • If I call the function from the Outside, it will indeed return 20
    • If I request the return value from the Inside of the function, it returns me the same value as "One"? Why?!

    Even if put multiple "set returnvalue", the simple fact of requesting a result from another function locks the "inner" returnvalue to the result of that function. If I'd use raw numbers, then requesting the returnvalue from the inside would give me the right result.

  • I found an absolutely brutal optimization. 3.500% faster !

    A string that used to take 10mn to process is now nailed in 17s !

    Let's suppose my string looks like this, where - represents junk data :

    ----DATA1-------DATA2------------------------DATA3------

    There is an awful lot of junk in-between the datas I want to collect, I only have use of 1 caracter out of 14.

    So, what I'm doing before processing the string, is filtering out all of the junk code thank to a single regex test:

    RegexReplace(TextBox.Text, ".+?(DATA[0-9]).+?", "giu", "| $1 |")

    which returns me an amazingly shorter string:

    |DATA1||DATA2||DATA3|------

    There's still a bit of junk at the end somehow, but so little compared to before I barely even care.

  • Sure, currently rewritting the OP.

    The bugs affect r230, however, firefox seems safe from this bug, sorry I omitted this.

  • Thank for the sugesstion.

    I tried to avoid "actual" loop so I could display the process progress in real time (not processing everything in a single tick) but making up a "fake" loopindex shouldn't be too hard, so I'll look into it.

    Let's work out how to use that g flag .

    I'm heavily relying on Pode's HTML plugin into this project, so I don't know whether you could read it without the plugin installed.

  • Mmh, I didn't think my climbing with any sort of helper. Just detecting which areas around the player are overlapping or not the scenery, no tiles would be set as more climbable than others.

    How badly are the helpers needed? I'm not familiar with these so I don't know how they help exactly.

    In the meantime I'll try to put my code into exectution.

  • Glad to be on-topic !

    Sorry I took so long, I forgot my way in.

    Here's my attempt at making a character able to hang to cliffs. Again I didn't take the time to even code it so I only have theory:

    The character is facing right, and is represented by the violet box.

    In order to hang to a cliff, an element of the scenery must be present in the red area on the top right (Detects a wall), but NOT in the green area. (Detects a "hole" in the wall for the character to hang to.)

  • Have you thought about the conditions "on object created" and "on object destroyed" ?

    Though "on destroyed" will not allow you to animate their destruction, because it is triggered after they are removed, but you could work around this by animating their destruction into a separate object type that is spawned "on destruction" and then destroyed when its animation ends.

  • Thread requested by Ashley

    Problem Description

    Strings above a certain lenght are truncated depending on the context, to about half a million caracters.

    Attach a Capx:

    http://sta.sh/01qsh2vnd6j4

    The download contains two file: the capx project, and a text file of about one-million caracters that I used in the project.

    The text is made of a single line, at the beginning is a big "THIS IS THE BEGINNING", at the end a big "THIS IS THE TAIL".

    In between is simply some HTML code I've been processing, this part doesn't matter here

    I'll refer to the text as the "one-million string".

    Description of Capx

    The Capx contains only a text box, which has three instance variables:

    "Variable", a text variable into which I directly pasted the one-million string

    "Pasted_Lenght", a number programmed to reflect the length of the string pasted into the text box.

    "Variable_Lenght", a number programmed to reflect the lenght of "FullHTML"

    Additionally, I programmed "Variable" to automatically capture the exact content of the text box.

    Steps to Reproduce Bug

    Observed Result

    • Start the project with Chrome in debug mode

    • Look for "FullHTML" and "Variable_Lenght" in the debugger

    ==> You'll notice that "FullHTML is truncated in the middle of the html and doesn't display the TAIL. It's lenght is said to be 30.000 instead of the expected one million

    • Open the text file in the notepad, and copy-paste the one-million string into the text box.

    ==> While looking into the textbox itself, you'll see the ending TAIL, meaning the string was succesfully pasted as a whole

    • Look for "Text" and "Pasted_lenght" inside the debugger

    ==> You'll notice that the debugger does not display the pasted string whole. Again, it is truncated in the middle of the code. It's lenght is said to be 524.288

    • Go back into the text box an type/erase a few caracters.

    ==> The advertised length remains at 524.288. My guess is it can't go higher and won't go down until you actually erase enough caracters. As well, the "text" in the debugger won't move unless you change caracters early in the string.

    • Redoing the same within Firefox, all the numbers match the actual lenght of the One Million string, (1.095.764), which displays both head and tail in the debug window.

    Expected Result

    Being able to input and manipulate insanely long strings.

    Affected Browsers

    Chrome: yes

    Firefox: NO

    Microsoft Edge*: yes

    *wasn't able to paste the string into edge, too much lag. Only the truncated variable is confirmed.

    Operating System and Service Pack

    Windows 10 64bit

    Construct 2 Version ID

    r230

  • The source of the html is from a website I do not host, I need to get it into the app at running time.

    For now as a temporary solution I've been copy pasting the chunk I needed into a text box so I could still develop the processing side of the app; but I'm still open to any suggestion as to how to get the html from the site into the running app.

    I am able to paste the entirety of the string into the box (I can see the tail end), but when I ask construct to tell me the length of what it reads, it typically returns 524.288 caracters.

    At first I tried to use Pode's HTML plugin to load the site into an iFrame inside the app, but because of some cross-domain thingy I could read the iframe's inner HTML from the app...

    Now that I think about it, the site does provide this chunck bits after bits as you scroll down, so if I eventually managed to grab it directly from the iframe I wouldn't even need to manage huge strings in the first place.

    I just know nothing about these cross domain thing.