Mikal's Recent Forum Activity

  • mOOnpunk - it has been discussed many times, no implementation yet.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Press F12 to show dev console and share the error.

  • Might be interesting to create a little class that does this. Keeps track of picked list and filters down with subsequent picking conditions. Also has a reset picking mechanism. Just as a helper for folks coming from events to JS.

  • 1.7.0

    Add very basic steamworks network messaging for testing. Requires correct SteamID to communicated between clients.

    To get the correct SteamID: In the Steam desktop application, select your Steam username in the top right corner of the screen. Select ''Account details''. Your Steam ID can be found below your Steam username.

    Networking must be enabled before communication. In the example project click on 'Enable Networking' this enables polling each tick for incoming messages.

    In the example app, the steamId should be added to the top box and the message to the other box (right now a random number is appended in the example project, easy to change.)

    When communication first happens between two clients, the receiving client must accept the connection before messages can be sent between them. The example project automatically accepts all incoming connections/sessions. Right now the channel number is hardwired to 0, but will change. Please try it out and let me know your experiences!

  • 1.6.0 Add GetFriendPersonaName

  • Ah, could be an issue with what version of JS the C2 export supports or it could be async nit supporyed at top level, not in module. Does it still work without async?

  • Added to C3 addons, so we don't lose access to this awesome tool:

    construct.net/en/make-games/addons/1140/easystar

  • Ah, yes this is a traditional canvas. I assume this function will be used multiple times, so I would also suggest creating a single canvas outside of the function and pass it to the function to be reused (so you are not creating a canvas per function call.)

  • I can give the basics, but I don't use c2 anymore. Here's generally how I would do it (untested):

     async function GetFriendAvatar(e) {
     return new Promise((resolve, reject) => {
     const requestResult = this._greenworks["requestUserInformation"](e["steam-id"], false);
     console.log('*** INFO *** domSide.js _OnGetFriendAvatar requestResult', requestResult);
     console.log('*** INFO *** domSide.js _OnGetFriendAvatar', e);
     var handle = this._greenworks["getSmallFriendAvatar"](e["steam-id"]);
     console.log('*** INFO *** domSide.js _OnGetFriendAvatar handle', handle);
     var data = this._greenworks["getImageRGBA"](handle);
     console.log('*** INFO *** domSide.js _OnGetFriendAvatar data', data);
     var size = this._greenworks["getImageSize"](handle);
     console.log('*** INFO *** domSide.js _OnGetFriendAvatar size', size);
     const result = {size, data};
     resolve(JSON.stringify(result));
     });
    	const e = {"steam-id": "483094812098"}
    	const result = await GetFriendAvatar(e);
    
    function createImageDataUrl(pixelArray, width, height) {
     // Create a canvas element
     const canvas = document.createElement('canvas');
     canvas.width = width;
     canvas.height = height;
    
     // Get the 2D context of the canvas
     const ctx = canvas.getContext('2d');
    
     // Create a new ImageData object
     let imageData = ctx.createImageData(width, height);
    
     // Set the pixel values
     for (let i = 0; i < pixelArray.length; i++) {
     imageData.data[i] = pixelArray[i];
     }
    
     // Put the image data onto the canvas
     ctx.putImageData(imageData, 0, 0);
    
     // Convert the canvas to a data URL and return it
     return canvas.toDataURL();
    }
    
    const imageData = result
    const height = imageData.size.height
    const width = imageData.size.width
    const pixelArray = imageData.data.data
    
    const dataURL = createImageDataUrl(pixelArray, width, height)
    
    console.log('dataURL', dataURL)
    

    replace this._greenworks with your pointer to greenworks

    I can help debug, if you try and it is not working for you. Just post the code.

  • Another interesting note in terms of my implementation, I got the function for creating a data URI from the original array, by describing the data format in my first post and then asked chatgpt4 to create the function for me in JS and the result worked w/o any changes, pretty nice!

  • Ok, got something working. Though, I am doing it for local user who's avatar may already be cached. So it may require another ACE to get the userInfo, wait for that to be available, then getFriendAvatar.

    The test project includes the function to change the data to a dataURL which a sprite can load.

    Let me know if you have any questions - it's a basic test case.

    I find that I need to use the steam ID from looking at my profile on steam website my profile URL.

    (Put the steam ID in the top text box, then press Get Avatar button. Need to export as nw.js 0.82 and add steam_appid.txt to the usual spot.

    construct.net/en/make-games/addons/244/greengrinds

  • It looks like it provides the handle (just an int tag) to be used by another greenworks function greenworks.getImageRGBA(handle); which returns a color 1d array, arranged in byte order of a[idx] = R, a[idx+1] = G, a[idx+2] = B, a[idx+3] = A.

    You can combine these together to make a RGBA color, using c3 expressions and write them into a C3 canvas for example.

    That's the theory at least :) I'm going to try it out, by adding the call to Greengrinds.

Mikal's avatar

Mikal

Early Adopter

Member since 22 Apr, 2016

Twitter
Mikal has 105 followers

Trophy Case

  • 8-Year Club
  • Entrepreneur Sold something in the asset store
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Popular Game One of your games has over 1,000 players
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • RTFM Read the fabulous manual
  • x10
    Great Comment One of your comments gets 3 upvotes
  • Delicious Comment One of your comments gets 10 upvotes
  • Email Verified

Progress

20/44
How to earn trophies