Asynchronous function in Cnds (conditions)

For developers using the Construct 2 Javascript SDK

Post » Thu Jan 10, 2013 5:51 pm

@Ashley
Gotcha! for the conditions :)
I have to work with expressions now - Thank you so much Ashley, without your help, the plugin won't never come !

Thanks again.
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Thu Jan 10, 2013 10:31 pm

@Ashley
I begin to understand correctly this way of working, I want to thank for that. My expressions work perfectly now. There is something like a SDK bug though, let me know what do you think about it.

My expression checks (before returning something) if the file exists by checking some var. After that, either it returns the string, either it sends a log to the console.

It works perfectly, BUT, if the file doesn't exist, instead of doing nothing it returns the 'path' variable O_o ....

Here is my actual code:
[code]Exps.prototype.getFileContent = function (ret, path)
{
   if (this.triggeringFile == path && this.error_ret != 404)
        { ret.set_any(this.fileContent); }
   else
        { cr.logexport ("The file may not exist."); return false; };
};[/code]
     
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Fri Jan 11, 2013 1:00 am

@septeven - your code is wrong. "return false" makes no sense in an expression - you must *always* return a value through 'ret'. In that case you should say ret.set_int(0) or some other value otherwise you'll leave undefined data in the return value.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Fri Jan 11, 2013 1:32 am

@Ashley, it works perfectly now :)
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Fri Jan 11, 2013 7:54 pm

@Ashley
Here is the dropbox plugin, thanks for your help !
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Previous

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest