gibbon's Recent Forum Activity

  • Hi brother! don't you happen to have the ZIGZAG behavior for construct3? or any tutorial to pass that behavior to c3 file?

    ?? Sorry, not a clue what your on about?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have done a bit more digging and found that the data may actually be correct, I was receiving some odd numbers but found the other systems I was using to check/validate actually had filters that would omit data it deemed as inaccurate.

    So I have put in similar filters and now getting better results.

    However, I still cant work out the final issue of why I cant run the function loop as fast as possibly allowed in order to read the lines of data, but instead HAVE to have:

    "wait for previous action to complete" before reading the next line for it to work and load all the lines without breaking?

    Thanks

  • It's difficult to tell exactly what is happening, but since you said you are using some javascript, is it possible that some of those snippets are using the await keyword?

    If that is the case, the javascript is asynchronous and needs to be waited for before continuing if you want to keep things running sequentially.

    https://www.construct.net/en/make-games/manuals/construct-3/scripting/using-scripting/scripts-in-event-sheets

    I have double and triple checked and all the JS I have written certainly doesn't and the 1 JS library that I'm using also doesnt appear to be doing.

    I will see if I can do a stripped back version of the issue and upload/send it over to you guys over to have a look. I cant quite fathom whats causing the issue despite doing some deep data analysis comparing the outcome of the line reads in C3 to other systems, very odd.

    As a test I changed the "wait for previous action to complete" to a wait for 0.5 seconds (between each line read) and loaded a file, but got the same results? Surely that would have given enough time to do everything, there only simple calcs and storing numbers in global arrays.

    What I don't get is why If I remove the "wait for previous action to complete" I cant fully load a file that has over 500 lines in? Its never the same line either, it just breaks at anything between 400 - 1000.

  • I am trying to figure out why I am getting some odd results and I'm sure its a lack of understanding with what's going on at certain points so I was wondering if someone could maybe explain the following which Im sure will lead me in the right direction.

    To help undertsand: I am loading a text file which contains lines of data, some have 500/600 lines and some might have 3000+ lines. What I ORIGINALLY did was create a loop to go through each line, read it, token it up, process some of the data (run the lines data though some calcs and functions) and then display it in a nice way at the end. The issue with this though was the "hang time" caused from all of the above happening in one tick.

    To solve this I did the following (which maybe the start of the issue)

    I crated a function with a line index parameter, which did all the reading and processing of a line at n index. At the end of the function I would simply call the function again with the next line index, until at the last line. This "function loop" works with some of the SMALLER files (upto around 500 lines) but what I found was anything over that and the function loop seemed to break... So I tried putting a "wait for previous action to complete" just before I call the function again with the next line index. Whilst this slowed the whole read process down, it seemed to work, read all lines just fine and does not hang the project. However, it is the start of some strange results from the data.

    In each function call, I grab the line of data (just comma delimited numbers and string's) (and sometimes the previous line) and I run them through various EVENT functions AND some JavaScript functions. But I'm finding some data to not be quite right, and its almost like its processing some lines at the wrong time in the function call, but they all use the same index var as the line ref.

    Here is a photo which shows the function loop I describe above.

    So is this because some of the functions I am calling are not finishing before it gets called again? Is there anything I need to do to these functions (both event funcs and JS funcs) to make sure they finish before continuing? The Event functions are NOT set to async nor are the JS functions.

    What I find strange is, nothing inside the function call actually has the little "wait" symbol (indicating a wait is required), yet putting the "wait for previous action to complete" before calling the function again does slow the loop down and loads all the lines, as apposed to if its not there only smaller files get loaded and big ones seem to break half way through reading the lines (500+)

    Thanks.

  • HI, i Have an issue with the scrollview and the new HTML element as part of the latest Beta.

    When you have the HTML element as a child to the scrollview content and then "scroll up" the HTML Element stops when it gets to the top of the viewport?

    Thanks

  • Thanks, and please don't think I'm being negative or not trying. But as noted in my original post, I have unfortunately already tried this.

    Thanks

    Andy

  • It depends on the specific library. Until fairly recently there wasn't a language-standard way to access the global object or use modules in JavaScript. Construct is based on the modern approach of using JS Modules and globalThis for global access. Modern scripts that are based on modules should work fine. But older scripts may need tweaking to work.

    For example if an old script tries to declare a global variable with var myGlobal = ..., that will need changing to globalThis.myGlobal = .... Also if the script doesn't actually export anything, you won't be able to use it with an imported name - you'll have to rely on global variables.

    Thanks Ashley, I have given up on trying to get the Chartish JS library to work which is very disappointing, its not a old library and in fact quite modern and highly used but I cannot fathom why it gives the "global not defined error"...

  • To continue on from this, im still very confused...

    Im not sure if is because I come from a HTML, JS and PHP dev background where you can just include and call any JS library with ease, but why this isn't the same in C3 is very frustrating and disappointing.

    With C3 now having the vanilla HTML Element, and the already JS capabilities I feel we C3 is missing a trick in not being able to use the thousands of JS libraries already out there...

    For instance..

    I am trying to add Chartish JS library (a light weight single file charting library), just a JS file and CSS, in standard HTML works a treat.

    Add the files to C3 project, import the JS file inside "importForEvents" and I get a error on preview and the console states the following:

    	Uncaught ReferenceError: global is not defined
     at chartist.min.js:8:9794
     at chartist.min.js:8:180
     at chartist.min.js:8:184
    domSide.js:25 [C3 runtime] Failed to load JavaScript code used in events. Check all your JavaScript code has valid syntax.
    

    What has to be done to get this working? I have tried changing all ref of global inside the JS file to globalThis but no luck.

    If we could easily include all the readily available JS libraries the scope for lovely looking interfaces ETC is huge.

    Worker is also Off

  • I have managed to (and very easily) add openlayers.js to my project and get it working nicly with the new HTML element.

    I did this simply by importing the ol.js and ol.css files, putting the JS file in scripts and I set its purpose as "importforevents". Then I found that in my events I can initialise the map and make changes to it ETC. Great!

    My next step was to add another script for "charts", so I did the same but realised that when I set the chart JS file to importForEvents it removes this purpose from the OL.js.

    So did some reading up and read I need to import these JS script into main and into a seperate "importForEvents.js" file to make them available inside events.

    So to keep things simply I thought I would attempt this with JUST the ol.js but I am having no luck whatsoever.

    Current "non working" situation is:

    Main.js (purpose set to main)

    	import * as myMaps from "./ol.js";
    

    importForEvents.js (Purpose set to importForEvents)

    	import * as myMaps from "./ol.js";
    

    When I try to initiialise the map from within an event script using the following

    	var map = new myMaps.ol.Map({
     target: 'map',
     layers: [
     new ol.layer.Tile({
     source: new ol.source.OSM()
     })
     ],
     view: new ol.View({
     center: ol.proj.fromLonLat([37.41, 8.82]),
     zoom: 4
     })
     });
    

    I get the following colse error:

    Unhandled exception running script Event sheet 1, event 17, action 2: TypeError: Cannot read properties of undefined (reading 'Map')

    If I remove the "myMaps." from "var map = new myMaps.ol.Map" in the above code then it works, but surely that is then not referring to the imported script?

  • Answer...

    globalThis.variable...
  • Hi, I am trying to add elements to an array using a script in an event loop.

    The array variable is declared also via another script in the "layout start" event.

    But the console reports when inside the loop that the variable isn't declared?

    So how can I access variables declared in one event (via script) from other events (via script)?

    Andy

  • Whilst I cant offer any help, I too am trying to do the same.

    Is there anyone with some knowledge on importing and using scripts that could help?

    Its frustrating that it was once quite easy to do but now not.

    It doesn't matter how I import the script, at runtime I just see this in the console:

    Uncaught TypeError: Cannot set properties of undefined (setting 'L')

    If I set the leaflet.js to import for events, I get an error at runtime and the following in the console...

    	scriptsInEvents.js:5 Uncaught TypeError: Cannot set properties of undefined (setting 'L')
     at scriptsInEvents.js:5:145
     at scriptsInEvents.js:5:150
    domSide.js:24 [C3 runtime] Failed to load JavaScript code used in events. Check all your JavaScript code has valid syntax.
    _InitDOM @ domSide.js:24
    
gibbon's avatar

gibbon

Member since 18 May, 2016

Twitter
gibbon has 1 followers

Trophy Case

  • 8-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

13/44
How to earn trophies