Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

gml_string

GML syntax highlighting for games, websites, and more · By YellowAfterlife

Instance Variables Highlight

A topic by indieklem created Mar 10, 2024 Views: 91 Replies: 4
Viewing posts 1 to 2

Hi,

I've setup the .js lib on my website (running on wordpress - https://indieklem.com/).

I don't know how to highlight Instance variable (the one in blue in the GMS editor).

On yal.cc website (https://yal.cc/gamemaker-variable-references-2023/) they are highlighted, but I don't find how to do it in the doc.

Thanks.

Developer

Hello, for that you need to run hintLocals, like so

for (let el of document.querySelectorAll("code:not(.gml)")) {
    el.classList.add("gml");
    var tks = [];
    gml_string.parse(el.innerHTML, tks);
    gml_string.hintLocals(tks);
    el.innerHTML = gml_string.renderToHTML(tks, "gml");
}

This is exactly the code I have.

Local var are not highlighted, only the class "gmlIdent" is added.

You can see it live here: https://indieklem.com/randomize-value-in-array-with-game-maker/ 

JS is here: https://indieklem.com/wp-content/themes/indieklem/js/gml_highlight.js

Developer(+1)

Ah sorry, mixed up local and instance variables - it’s a bit of a busy week.

My website uses a slightly different highlighter but basically it’s just gmlIdent being styled to look blue when using the dark theme.

No worry :)
I will style the gmlIdent then, thanks for the advice :)