Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

GMLive.gml

Livecoding for GameMaker: Studio / GameMaker Studio 2 · By YellowAfterlife

[Fixed in 1.0.26+] Is there a way to setup a macro for the 2-line live call you need to put into the step event?

A topic by @ColtonPhillips created Apr 18, 2020 Views: 358 Replies: 7
Viewing posts 1 to 3
(1 edit)

Hi,
Downloaded this today. Sorry, but I don't yet know all the details of the tool but I've figured out if include 

if (live_call()) { return live_result; }

in the top of a step function it turns my event into a live event. 

I am a software engineer so I like to simply things: I wanted to turn the above into a gml macro, since I hear that they are simple find and replace tools, but it's not working. I create this macro in the gml_object _create_ event:

#macro live_freely if (live_call()) { return live_result; }
^^^


But when I change my step to look like this:

/// @description Insert description here
// You can write your code in this editor
live_freely
 image_speed = 1;

image_alpha = 0.5;


The macro doesn't appear to work. The updates don't work, even though it "should" be the same thing.
Is your extension literally scanning the files for some regex of " if (live_call()) { return live_result; }"

or something? 

Does someone well versed in gml / gms2 macros know what I'm doing wrong here? 
I even tried forcing it so that my macro ended with a semicolon... /shrug


Developer
Is your extension literally scanning the files for some regex of " if (live_call()) { return live_result; }"

Close enough - it looks for the pattern outside of comments/strings but it is not aware of macros.

Supporting macro expansion for live detection means that:

  1. The server needs to actually parse tokens in every single code snippet in the project, which can add up on large projects.
  2. The server needs to store code snippets in memory so that it can parse them again after entirety of codebase had been scanned and macros have been established (as you can put macros absolutely anywhere).

I intend to support this later (alongside with rewriting macro support in runtime to be more GML-like instead of "pure" macros - I write a lot of strange GML parsers these days), but for workaround I could probably add a CLI option for the server to add extra regular expression(s) for live code detection?

Thank you for your thoughtful response.  What I'm basically looking for is a short keyword to add to the top of a step or draw call just to keep things short. So something like 

"""
live_load // or some other name, just an example.

/// Code proceeds here to be live reloaded
"""

Something like that would reduce the amount of effort to add livey-ness to any particular step, instead of trying to remember the 3 liner, or keeping it in your clipboard or whatever. I don't know if macros are necessary for this -- it sounds like you are onto something, perhaps this would be worthy of an opt-in preparser tag, eh? That would be le epic.  Whatever you think makes most sense. 

(+1)

What I've done is create an AutoHotkey script that types in the phrase for me.

If you want to copy it, the code is:

^d::
Send if (live_call()) return live_result;
return

You can activate the hotkey with Ctrl+D. It may not be the best ahk code but it works well enough for me.

Genius!

Thanks! I'm glad it worked

Developer

If it's purely about fast insertion, GMS1, GMS2, and GMEdit all have snippet support.

GMS1:
Snippet file location: %APPDATA%\GameMaker-Studio\snippets.txt
Keyboard shortcut: F2

GMS2:
Snippet file location: %PROGRAMFILES%\GameMaker Studio 2\TextEditor\snippets.txt
Keyboard shortcut: F4
Note: make a backup since the file can get overwritten on IDE updates

GMEdit:
Snippet file location: Accessed via Preferences - Code Editor - edit snippets (wiki)
Keyboard shortcut: none - shown in auto-completion when you start typing out snippet names

Thank you for the wonderful support. That will do for now. :)