Fengist's Recent Forum Activity

  • var emailObject = runtime.objects.EmailBodyInput.getFirstPickedInstance();

    var emailBody = emailObject.Text()

    you need to get an instance first.

    Thanks.

  • console.log(runtime.objects.EmailBodyInput.Text); // Log the whole object to see what it contains
    var emailBody = runtime.objects.EmailBodyInput.Text;
    
    if (emailBody) {
     emailBody = emailBody.replace(/\r\n/g, '\n'); // Normalize line endings
     runtime.globalvars.emailBody = encodeURIComponent(emailBody); 
    	consol.log(emailBody);
    } else {
     console.error("EmailBodyInput.Text is undefined.");
    }

    And I get EmailBodyInput.Text undefined. Know full well it contains text. Trying to clean up some line endings that aren't working as intended when I ajax them to my server.

    Thanks.

    Tagged:

  • Welll.....

    Manually entering data into an array would be tedious. And, any time you need to make changes or add things... ick.

    Manually creating a JSON would be even more tedious. Just making sure you got the syntax right.

    Assuming you don't have a lot of experience with MySQL or PHP, what I would do is something like this. And keep in mind, this is not an ideal solution but it would be a good starting place to learn about databases.

    First, I would download SQLite Studio (google it) and use it to create a database of the objects in the game. Depending on how you structured it, it would be dead easy to add levels, add new objects, etc. just by adding a new item to the table.

    After you have the database I would then look at using an SQLite to JSON converter like this one: mygeodata.cloud/converter/sqlite-to-json

    SQLite creates a db file that you'd upload to it. I've never used that site before so I can't promise it would work.

    Then, bring your JSON into the game, parse the crap out of it and stuff all that into an array.

    The advantage of that is, you could have a table for enemies, a table for asteroids and a table for drops and you could load each into separate arrays.

    That being said, if you have gobs of stuff to add, arrays do have limitations.

    I'm sure you could do it in firebase but, I've never worked with it so I couldn't tell you where to even start there.

  • Loopindex doesn't work in For Each element loops. Either use System For loop, or Array.CurValue expression.

    Actually, that's not even "For Each element" loop on your screenshot, it's "For Each instance".

    DOH!

    Thanks. Just used to php and throwing that array in there and expecting a foreach for each of it's elements.

    Knew I was doing something totally stupid.

  • And just as a test I set that EmailTitle to the MailDeleteArray.AsJson and it appears to be properly loading the CSV so... it must be in my concatenation.

  • Ok, I know I'm missing something just blatantly obvious here but for the life of me, it's kicking my ass.

    I have a JS in my HTML that's calling this Get Checked Mail ID function each time a checkbox is clicked. It's passing a csv of numbers to this function with each checkbox ID. Ex - 9,3,4,2,5

    I'm splitting that csv into an array and doing a foreach.

    What I'm trying to build is a URL with an array to post with ajax, similar to this:

    example.com/api The purpose of this function is to build that URL array and save it to a string.

    What I get from this code is the first element in the csv/array (delete_emails[]=9) and none of the others.

    I know the csv looks good passed from the JS. What I can't tell because the JS won't run in debug is whether the array is getting populated correctly or my concatenation is screwed up. Which is why for now I'm just setting that EmailTitle to the string it creates.

    Thanks.

  • If you are loading the js into an html element you can do this:

    parent.c3_callFunction("MyFunction", [MyParam]);

  • I'm a little late to this but, my suggestions are:

    1. Only work with a developer in the same country as you.

    2. Get a legal Non-Disclosure Agreement (NDA) signed.

  • Ok, only thing that comes to mind is that chrome has a habit of caching JS scripts, especially if you're pulling them in from a remote location. One of the old tricks is to add a version number to the JS file name... myjsfile10.js When you change that js, change the file name... myjsfile11.js. Chrome will see the new file name and fetch it instead of using the cached copy.

    Another thing you can do in the preview is to try hitting ctl-f5 or ctl-r. Both of those force the everything to reload including images and js files.

  • Just curious, have you tried sending your query as an ajax request? Don't forget to set your CORS header if you do.

    Which makes me wonder, have you checked the debug console to see if there are any errors. I know a CORS error in the AJAX won't return anything but it will produce a console error.

    I'm not using any mod rewrites but I am using wordpress as a game server. What I do with it is have it look for a specific /foo/bar in any incoming request and if that directory is in the url, I pass the query on to the game server code which returns a JSON. Otherwise, it hands back off to the wordpress code and displays the website.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • someone else answered a similar question in a much easier way.

    construct.net/en/forum/construct-3/how-do-i-8/game-saved-file-183408

  • Well I'm not sure how your game works but local storage is a simple var storage. I use it in my game to store the users login info (remember me). It's not secure so don't store anything important. But you could for example set the level they last completed. Next time the game runs, get the level from local storage and go to the next level layout. Store points, coins, etc.

Fengist's avatar

Fengist

Member since 6 Nov, 2015

Twitter
Fengist has 5 followers

Trophy Case

  • 9-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x3
    Coach One of your tutorials has over 1,000 readers
  • x2
    Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

16/44
How to earn trophies