Fengist's Forum Posts

  • I'm running a SetInterval in an HTML element in order to do a countdown. Here's the problem:

    if (hours1 > 0) {
     if (hours1 === 1) { 
     document.getElementById("hours1").textContent = hours1 + ":Hour ";
     } else { 
     document.getElementById("hours1").textContent = hours1 + ":Hours ";
     }
    } }
    

    I load up the HTML via AJAX at start of layout. If, I go to a different layout, the interval keeps running but it's no longer able to find the textContent (obviously) and floods the console with errors.

    Ultimately, I'd like for the interval to keep running so that I don't have to do ajax calls each time the layout is loaded and can do them only when needed. Any way around this?

    Thx

  • > <i onclick="clickTrain(17)">Train</i>
    
    <script>
    function clickTrain(x) {
    parent.c3_callFunction("name", ["param1", "param2"]);
    }
    </script>
    

    Ty!

  • Any way to do this?

    This is what's currently in my HTMLElement

     <i class="fa fa-lightbulb-o" onclick="clickTrain(17)">&nbsp;&nbsp;Train</i>
    
    function clickTrain(x) {
     let text = "Do you wish to train this skill?";
     if (confirm(text) == true) {
     //call a C3 function and pass the value of x which will in turn do an AJAX request.
     } 
    }
    

    Thanks

  • One of the reasons I quit developing in C3 and am seriously debating whether I wanna try again is UI issues.

    The whole method of scaling and how to handle browser resizing is just a nightmare. The only solution I found for a web based app (and this would probably apply to phone apps as well due to their vast number of sizes) is to manually detect screen sizes, browser sizes, etc and then create a browser.onresize function that rearranges everything on the layout into what you hope is the proper place.

    I wish you luck.

  • There would be another way but a bit more convoluted. You could use links in the html to send posts or gets to a php script then use Ajax to send requests back to the php. If you're interested I just posted in tools earlier a html element that loads news via Ajax requests to a website.

  • Well... after looking over their info real quick I will say it's likely doable. They do have an OAUTH system in place it appears to access the databases but their methods seem pretty lame compared to other methods.

    Their OAUTH instructions are here

    manual.bubble.io/help-guides/the-bubble-api/using-the-api

    And db commands are here.

    manual.bubble.io/core-resources/api/data-api

    I'm betting that previously you could get C3 for 119 DR Pesos, which would likely have come out to around 2.19 because currently 119 pesos = 2.10 USD.

    Now, in the DR, 119 pesos may be a fair chunk of change but here in the US (or the UK) that won't even buy you a decent cup of coffee. The prices were likely previously listed in pesos which didn't get converted into USD.

    So, for less than 15 minutes of minimum wage work here in the US you were getting access to a full year of C3. Be happy, that was one incredible bargain.

  • Ok, now sure how much visibility this will get in this forum but here goes.

    https://twistedvoid.com/C3/NewsTest/index.html

    If the link to the app is TLDR then here's the basics:

    This is formatted HTML news that can be placed in any C3 app that was automagically produced from posts on a WordPress website.

    So, how much interest would there be in something like this?

    Tagged:

    Doesn't seem to happen here, Fengist...

    Check this file.

    You don't need any "wait" for the functions to be executed in the correct order.

    Without seeing your file is hard to tell the problem, but something must be messing up your logic...

    Cheers!

    Change your code. Add just a Wait 0 here:

    * On function 'doLotsOfStuff'
    -> System: Wait 0 seconds
    -> Text: Append " Starting to execute doLotsOfStuff" & newline
    ----+ System: Repeat 10 times
    -----> Text: Append " Doing " & LoopIndex +1 & " stuff" & newline
    
    ----+ (no conditions)
    -----> Text: Append " Finished executing doLotsOfStuff" & newline
    

    which completely changes the order of your output. THAT is what I was experiencing and it was totally unexpected.

    *grabs popcorn*

    I don't understand why you'd use this weird setup with return value. Why not just do

    FunctionA

    FunctionB

    FunctionC

    ...

    And maybe use signals/wait for signals if needed?

    The reason I inserted waits into my functions was because I was doing a bunch of functions. The purpose of the waits were to temporarily stop loops and whiles (which I've also learned can't be done without making an infinite loop) to update a progress bar or some such. And that is something that was suggested to me in a previous thread as a way of pausing a loop to show progress. So I stupidly assumed that if Wait 0.1 worked then Wait 0 should work the same way only faster.

    That return value was inserted as a result of debugging because was trying to force it to wait for the previous functions to complete before executing the code below it, which it was having none of because a single Wait 0, buried 4 functions deep, was causing it to return that 1 regardless of whether everything else had been completed or not.

    Yea, signals would have worked, I was trying to be expedient.

    It's common that people run in to a problem and then they immediately blame Construct. I would discourage you from doing this - not only is it somewhat tiring, it's also not the best way to investigate and diagnose a problem and will probably just send you on a wild goose chase which will only increase your frustration. A better approach is to basically take a debugging approach. For example you could add console logs frequently through the events, with messages like "Starting funcA", "Finishing funcA", "Step1", "Step2" etc. Then you can easily see in the console the specific order that everything ran in. This then helps figure out where things are diverging from what you expect, and helps you hone in on why. Chances are it's working as designed (but remember events are a pretty different paradigm to traditional programming languages, so in some cases the intended design may not be identical to other typical languages). Even if you become convinced it's a bug, you then have a project ideally set up to either share on the forum to ask about why it's working that way, or post to the bug tracker as a project demonstrating what you believe to be a bug.

    Where the hell did this bitch slap come from?

    If you read my posts, nowhere did I blame Construct. I did ask if this was a bug which is not an indication of blame. When I was told the reason, I blamed JS.

    The way I discovered this WAS through a debugging approach whereby I inserted a breakpoint at the start of the event sheet and watched as it sent back a return value from a function without completing the function. In my coding experience I have NEVER seen a language that has anything I can insert in the middle of a function that tells it to both complete AND break out of the function at the same time, which is what Wait 0 is doing. While I do see the potential benefit of doing that in rare circumstances, it's not something I've encountered ever before and therefore is not something I would habitually look for as a coding error which is why it took me hours to finally track down. Furthermore, IMHO, the fact that Wait 0 and Wait 0.01 do two VASTLY different things (if what I'm seeing is correct) is also absurd.

    And if you keep reading my posts, you'll also see that I did create a test project, which I shared and which demonstrated why the Wait 0 in a function is nothing short of illogical. By simply turning it on or off, I can completely change the order in which functions are completed.

    On the other hand, if you just keep making random changes to an event sheet, and always want to blame something other than the logic of your events, then yeah, you'll probably have a hard time making progress!

    What? Where the hell did you get that I was making random changes? My logic? Is that some petty insult? You're accusing me of being stupid and illogical in my approach to solving this? Well, I know how to respond to that. I can take me and my stupid illogical wallet back across the pond.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads

    As a rule of thumb, I steer clear of "Wait 0". Rarely do I really want to postpone actions back to the end of a tick.

    Yea, I see that now. Here's the problem. The list of things I'm learning to avoid (loops, while, etc.) is growing at an exponential rate. By the time my subscription comes around for renewal, I'll be coding on paper with a pencil.

    Are you a JavaScript programmer usually?

    Nope, several other languages but not JS.

    Ok, so, setting the wait to 0.1 does solve the problem but. Having wait 0 and wait 0.1 do two different things???

    Where did this JS language come from any way?

    Oh, I figured it out and this is even crazier than I thought.

    + System: On start of layout
    ----+ System: Functions.Function1 = 1
    -----> Text: Append newline&"Function1 complete"
    
    * On function 'Function1'
    -> Functions: Call Function2
    -> Functions: Set return value 1
    
    * On function 'Function2'
    -> System: Wait 0 seconds
    ----+ System: For "" from 1 to 5000000
    -----> (no actions)
    
    ----+ System: 0 is Number
    -----> Text: Append newline&"Function2 complete"
    

    Do you see the difference? At the start of function2, I added a wait 0. With the wait 0 enabled, function 1 completes first. With it disabled, function 2 completes first.

    Wow, just.... wow. So, the method that was described to me earlier on one way to update say a progress bar in the middle of a loop by inserting a wait, completely breaks the chain functions should follow.

    Ok, I have no clue what's going on. I just did a test.

    + System: On start of layout
    ----+ System: Functions.Function1 = 1
    -----> Text: Append newline&"Function 1 returned"
    
    * On function 'Function1'
    -> Functions: Call Function2
    -> Functions: Set return value 1
    
    * On function 'Function2'
    ----+ System: For "" from 1 to 50000000
    -----> (no actions)
    
    ----+ System: 0 is Number
    -----> Text: Append newline&"Function 2 finished"
    

    And this works as intended. Function 2 completes before function 1. So I have no idea now why my code, which is essentially the same but a lot more complex, is not doing this.