Fengist's Recent Forum Activity

  • Ok, so I have this function:

    function UUID() {
    	runtime.globalVars.UUID = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
    		const r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
    		return v.toString(16);
    	});
    }
    

    If I click add script to an event (and remove the function UUID() bits) and then assign the global var UUID to say a text object, it works exactly as intended.

    However, I plan on calling this a bunch of times. Seems a tad wasteful to keep copy/pasting this script all over the place. I'd like to put it in a js file in either the files or scripts folder (dunno which) and then call the function with an event. I tried the whole browser.execjs thing and it can't find it.

    So, the question is (after spending several hours digging through the JS tutorial to no avail), how can I call this as a function from an event????

    Oh and I tried this: runtime.callFunction("FunctionName")

    Strangely enough, the code completion for callfunction finds the function name.

    But apparently I'm not holding my mouth right. I put the function in files/stuff.js and I tried putting it in scripts/main.js. Doesn't find it.

    Thanks

  • Ok, after 2 months and no reply on how to get an app working on google play, I'm just going to assume it can't be done.

    Good thing I can work in Unity.

  • About the easiest way to do this is using Ajax and json on the construct side. You'll need some sort of server to send and receive your json data and to communicate with the mysql server.

    What you're asking for is not a simple, here you go, 2 lines of code. I've done this myself in php. There's lots of things to consider when making a user registration system.

  • You'll need to make sure you have a 'tag' in your Ajax Send. Then create a new event Ajax On Completed and use the same 'tag'. Your post reply will be in Ajax Last Data. To detect a failed post you add a new event Ajax On Error and again, use the same 'tag'. You can also use an Ajax Any Error event.

  • 1. Donations? LOL, right. Created mods for KSP. My big mod had over 300,000 downloads and after years of not even caring any more I still get people wanting to download it. Total donations? $50.00.

    2. No, Construct isn't cheap. Of course you could buy other coding languages like Dephi. I think the architect version is $3,700 this year. Or, you could do Unity and C# in Visual Studio for free (until they change the rules again) if you wanna get buried for the next 5 years in their API where the minute you learn how to do something they depreciate it and end up throw your hands up in disgust.

    There are other options.

    My opinion, if you can't somehow manage to find the money for an annual subscription then perhaps you should consider a real job and save money until you can. Bill Gates started out writing code for a power plant.

  • Ok, got a test plugin uploaded to google play. SLOWLY figuring this crap out.

    Here's what I know. I download and run the app from the play store and it shows my google play login name so I know the oauth and such is working. However, I can't get the C3 plugin to work. None of the text fields are changing so it appears the plugin is not signing in. I have the app ID correct and when it didn't run with just that I added the client ID. Still not doing anything. Where am I going wrong?

    + System: On start of layout

    -> Text: Set text to "It Works V2"

    + GooglePlay: On error

    -> Text: Set text to GooglePlay.ErrorMessage

    + GooglePlay: On loaded

    -> GooglePlay: Sign in

    + GooglePlay: On signed in

    -> GooglePlay: Request player details

    -> Text: Set text to "Signed in"

    + GooglePlay: On player details received

    -> Text: Set text to GooglePlay.MyDisplayName

    -> Text2: Set text to GooglePlay.MyFamilyName

    -> Text3: Set text to GooglePlay.MyGivenName

    -> Text4: Set text to GooglePlay.MyID

    + GooglePlay: On auto-sign in failed

    -> Text: Set text to "auto signin failed"

    + GooglePlay: On sign in failed

    -> Text: Set text to "signin failed"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'll give it a try. Thanks!

  • Ok, screw the tokenat. Found a working solution with regex.

    "^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$"

    Here's what I have and it mostly works. The theory, if the text input is a valid IPV4, it sets the opacity of a search sprite to 100%, otherwise it sets the opacity to 50%. The problem is, if a user enters a.a.asd.aawd It's seeing those as integers. I've tried various combinations of !NaN and checking to see if it is an integer and it always evaluates the character as a valid integer.

    What am I forgetting??

    Thanks!

    * On function 'CheckIP'

    ----+ System: tokencount(IPInput.Text, ".") = 4

    --------+ System: Repeat tokencount(IPInput.Text, ".") times

    ------------+ System: tokenat(IPInput.Text,LoopIndex, ".") > ""

    ----------------+ System: int(tokenat(IPInput.Text,LoopIndex, ".")) ≤ 255

    -----------------> IPSearchIcon: Set opacity to 100

    ----------------+ System: Else

    -----------------> IPSearchIcon: Set opacity to 50

    -----------------> System: Stop loop

    ------------+ System: Else

    -------------> IPSearchIcon: Set opacity to 50

    -------------> System: Stop loop

    ----+ System: Else

    -----> IPSearchIcon: Set opacity to 50

  • Found one slight problem with this. It doesn't work when in debug mode.

  • 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

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