Discussion GML to JS(p5)/Max Msp

Discussion in 'GameMaker Studio 2 Community Tech Support' started by Kyon, Feb 7, 2019.

  1. Kyon

    Kyon Member

    Joined:
    Jun 27, 2016
    Posts:
    418
    Hi everyone, so I've been experimenting a lot with Max msp and Javascript (p5) lately, and I really want to combine gamemaker with it.
    But I don't really know where to begin, how capable is gamemaker with external programs, or inputs?
    Can I link gamemaker through max to an arduino or teensy?
    Or can gamemaker recognize other controllers like midi or something else through extensions? Where's the best place to look for them?

    But most important, linking gamemaker to stuff like javascript. Like, can I sort of send inputs in gamemaker to maybe a textfile and that javascript picks up changes? idk how this stuff is done.


    Kyon.
     
  2. Pfap

    Pfap Member

    Joined:
    Apr 30, 2017
    Posts:
    475
    I'm not too familiar with Max or p5.js, but communicating between javascript and gml is easy enough using JSON. It took me a while to become familiar with it and most of it seems to be with how you structure your JSON and how you want to use it on the Gamemaker side. Basically, a javascript array can be thought of as a Gamemaker list and a javascript object can be thought of as a Gamemaker map. Anything you encode in JSON is pretty easy to work with on most platforms and with most languages; although, some databases can be problematic when working with it.

    Actually, I neat little trick if you ever want to visually see what is in a Gamemaker list or map is to JSON encode before calling show_debug_message.

    Code:
    var data_map = ds_map_create();
    
    ds_map_add(data_map,"data",any_data);
    
    show_debug_message(data);//will display the map index
    
    var data = json_encode(data_map);//encode maps and lists before debugging for an easy visual
    
    show_debug_message(data);//will display the contents of the map
    
     
  3. Kyon

    Kyon Member

    Joined:
    Jun 27, 2016
    Posts:
    418
    But how would I access this? Send it to a txtfile?
    How would I for instance trigger changes in that textfile? Or should I just have JS check every frame if a variable has changed?
     
  4. Pfap

    Pfap Member

    Joined:
    Apr 30, 2017
    Posts:
    475
    I was figuring you would use the network and a database or the Arduino or other project computer. I'm not sure about using a shared file as the Gamemaker system is sandboxed. I'm pretty sure you could still use the loopback address for accessing something on the same computer as your Gamemaker application. I did some playing around with the raspberry pi and getting it to work with Gamemaker a while ago. I checked out the js p5 website and the links on the main page don't seem to be working, it seems like some type of visual scripting language though. What are you trying to make? In my head I'm thinking you are trying to build a front end for some project that will be controlled with Gamemaker, but I'm confused why you would need to link to Max before linking to the Arduino. Instead of going directly to the project board. Or are you planning on going from Max to Gamemaker and then Gamemaker talks to the project board?
     
  5. chirpy

    chirpy Member

    Joined:
    Oct 6, 2016
    Posts:
    108
    I'm not familiar with it but you might want to look into async events which many extensions seem to use, so you can also check the marketplace for examples.
     
  6. immortalx

    immortalx Member

    Joined:
    Sep 6, 2018
    Posts:
    269
    Well my answer won't probably be any real help, but regarding the part of your question about Gamemaker being able to interface with other controllers, here's an idea:
    Depending on your Arduino board, it can be set up as a USB-HID device (keyboard/mouse/gamepad/etc.). Which means that GM should be able to read is output. (I've build a home-made steering wheel this way and it works with every game I tested). Maybe that combined with a virtual loopback MIDI software could accomplish what you need.
    Again, I don't have a clue how all that can work with Max msp and Javascript and sorry if this isn't relevant to what you need.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice