QuincyDK's Forum Posts

  • Hi all, I am doing a project in which I use pure JS, and execute this by using the CallJS plugin. This went okay for one event sheet, but on the other I always get an error in my console log

    [quote:1374n9ny]CHROME: Uncaught TypeError: Cannot call method 'toString' of undefined

    FIREFOX: TypeError: x is undefined

    I have an export on improvive.net/export_quincy

    In the first text field enter the following string:

    33d-j8ZpFFDdr+QQ4RUWxA

    The following is the code that produces the return value:

    var returnstring;
    function retrieveStorylist(){
    input = prompt('Voer hier het unieke gebruikersnummer in');
    $.ajax({
        type:    'GET',
        url:     'http://ihj.improvive.net/view/'+input+'/',
        success: function() {
    	   setting = window.open('http://ihj.improvive.net/view/'+input+'/');
    	   setTimeout(function(){setting.close()}, 1000);
    	  	  $.ajax({
    			type:	'GET',
    			url:	'http://ihj.improvive.net/view/'+input+'/list',
    			xhrFields: {
    				withCredentials: true
    				},
    			success: function(text){
    				if (text === ''){
    					alert('Er is iets fout gegaan .... Meldt dit bij Improvive (Roel, Quincy of Tariq).');
    					exit();
    				}
    				else {
    					/*text = JSON.parse(text);*/
    					numlist = text.length;
    					var inb = {
    						'c2array': true,
    						'size': [text.length, 3, 1],
    						'data': text.map(function(frame){
    							return [
    								[frame.id],
    								[frame.title],
    								[frame.shared]
    							];
    						})
    					};
    				returnstring = JSON.stringify(inb, null, 4);
    						   };
    									},
    								error: function(){
    									alert("Er is iets fout gegaan, controlleer het nummer en probeer het opnieuw");
    									}
    								});
    					}
    	   }
    )
    return returnstring;[/code:1374n9ny]
    
    What goes wrong? :c
    
    (I chose not to include an capx because the event sheet is basically
    ON LAYOUT START: 
    CallJS.Execute("retrieveStorylist()");
    returnvalue = CallJS.ReadExecutionReturn
  • Good day!

    I've got a list of wav files that I want to play stored somewhere. I already got to the point that my application reads the correct link out of this list, however the Audio object doesn't allow me to externally load these files during runtime. I also tried some javascript, but that didn't get me much further. Is there any way to archieve this?

  • ^Oops, sorry Ashley! I will make sure that this won't happen again!

  • Have you installed an addon?

    Only the CallJS plugin. I got around it by reverting to an older project from last week, so let's hope that this doesn't happen again.

  • Hi all,

    I am doing a project in construct, which was going fine before the weekend, last test export working and all.

    However, as I did an test today (without changing anything) I got an javascript error in the console:

    Uncaught TypeError: Cannot read property 'poly_pts' of undefined.

    Using FireFox' console, I get the folowing:

    TypeError: this.type.animations[0].frames[0] is undefined

    I have absolutely no idea where this came from, and I am lost as I don't know what could be the issue..

  • Good for you

    Just putting it here, because you never know when someone may run into the same problem. One love, man!

  • The problem is solved. I was using XYZ index when I should've been using XY

  • Hey there. I have the following project:Image is too big to post here (over 3k x 1080)^Not yet permited to post urls^

    qdekoster.nl/Naamloos2.png

    ^Cant post urls yet

    As you can see on the right side

    I get two alerts: The first one is out of my .JS file, and shows the file path.

    The second one however, is "This is 0".

    The data should be loaded out of a JSON file, and I can confirm that that is working, but that 0 should be the file path. Does anyone see what is going on/wrong?

  • I'm sorry I couldnt help you. Please inform me about your progress!

    Here is the update: I came across callJS (plugin) and that has allowed me to use my own script file.

    With CallJS.execute("function();") I can execute a function, and then by using the CallJS.ReadExecutionReturn I can retrieve the return value

  • QuincyDK

    Hey, sorry I wasn't of more help either to your problem in the other post. What you just said made me ask myself : are those static data ? If so, the problem isn't the same. Executing code through execJS won't be a problem as it will only be for development. Once you've got the static data loaded in you array(s), you can use the "download" action to get there content as a C2 formated JSON file, that you will then be able to use in replacement of the execJS, for the real game.

    Hey there! It isn't static data, as we grab the data from one of our servers. This data differs per "file". Hence the function we've written to convert to a C2 JSON string.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm sorry I couldnt help you. Please inform me about your progress!

    It's no problem! Now things do get interesting, as we probably are going to run each input file through the converter manually

  • There's one problem with construct about this: You can't create associative arrays. Maybe you'll have a look at ReyRainbows HashPlugin. It's awesome to store JSON data. Maybe you could extend this plugin to fit your needs.

    The data-structure is already working, and the converter we currently use is also working, we just want to merge them

    But, thanks anyways. It's nice to see that noobs like me have no reason to be afraid to ask something

  • The SDK documentation is not really helping me in this one. Could you perhaps share this plugin you're talking about, maybe I could implement my own function in there

    To be a little bit more percise: Here is what I want to do.

    I have a JSON file, I want to select this from my hard-disk during runtime (file-dialogue). The function sees this, and reads the file > Converts it into C2JSON > Pastes this in an array called "PicProperties"

    Seeing that I am pretty new to C2, I have absolutely no idea how to do this plugin-wise. This function should ONLY be called during runtime (Thus eliminating the need for edit-time stuff.) Does this mean that I could comment out the whole edit-time part except the plugin details and such?

    EDIT (again): I am figuring that this is an ACT. How would I go and add an "File select" dialogue in C2?

    And: How could I return values to an already existing C2 array?

  • var content="";
    var input="";
    var output="";
    var outputJson="";
    function readBlob(opt_startByte, opt_stopByte) {
    
        var files = document.getElementById('files').files;
        if (!files.length) {
          alert('Please select a file!');
          return;
        }
    
        var file = files[0];
        var start = parseInt(opt_startByte) || 0;
        var stop = parseInt(opt_stopByte) || file.size - 1;
    
        var reader = new FileReader();
    
        // If we use onloadend, we need to check the readyState.
        reader.onloadend = function(evt) {
          if (evt.target.readyState == FileReader.DONE) { // DONE == 2
            document.getElementById('byte_content').textContent = evt.target.result;
            document.getElementById('byte_range').textContent = 
                ['Read bytes: ', start + 1, ' - ', stop + 1,
                 ' of ', file.size, ' byte file'].join('');
                 content = evt.target.result;
    			 input = JSON.parse(content);
    			 output = {
        "c2array": true,
        "size": [input.frames.length, 4, 1],
        "data": input.frames.map(function(frame){
            return [
                [frame.image || ""],
                [frame.title],
                [frame.mediatype || ""],
                [frame.thumb || ""]
            ];
        })
    };
    
                    
    // the "null, 4" part is just to pretty-format the json (indent 4 spaces)
    var outputJson = JSON.stringify(output, null, 4);
          }
        };
    
        var blob = file.slice(start, stop + 1);
        reader.readAsBinaryString(blob);
      }
      
      document.querySelector('.readBytesButtons').addEventListener('click', function(evt) {
        if (evt.target.tagName.toLowerCase() == 'button') {
          var startByte = evt.target.getAttribute('data-startbyte');
          var endByte = evt.target.getAttribute('data-endbyte');
          readBlob(startByte, endByte);
        }
      }, false);
    
    /*
    {
      "name": "werwer",
      "frames": [
        {
          "title": "[Nieuwe Dia]",
          "image": "\\files\\cacc0075a0c044cbc9ec.jpg",  //without the filepath
          "thumb": "\\files\\cacc0075a0c044cbc9ec.jpg",  //thumb could be neglected
          "mediatype": null, //same as thumb
          "media": [] //same as thumb
        },
        {
          "title": "[Nieuwe Dia]",
          "image": null,
          "thumb": null,
          "mediatype": null,
          "media": []
        },
        {
          "title": "[Nieuwe Dia]",
          "image": null,
          "thumb": null,
          "mediatype": null,
          "media": []
        },
        {
          "title": "[Nieuwe Dia]",
          "image": null,
          "thumb": null,
          "mediatype": null,
          "media": []
        }
      ]
    };
    */
    
    var output = {
        "c2array": true,
        "size": [input.frames.length, 4, 1],
        "data": input.frames.map(function(frame){
            return [
                [frame.image || ""],
                [frame.title],
                [frame.mediatype || ""],
                [frame.thumb || ""]
            ];
        })
    };
    
                    
    // the "null, 4" part is just to pretty-format the json (indent 4 spaces)
    var outputJson = JSON.stringify(output, null, 4);
    console.log("test");
    console.log(output);
    document.getElementById("out").innerHTML = outputJson;[/code:11qmusfh]
    
    This following code, it is by the way.
  • I really recommend you to write a plugin and forget about the Browser object.

    For only one function, isn't that a bit of a lot of work?