SOLVED Dynamically access object properties

BillFrams

Member
I am trying to do the following as I am coming from a js/node.js background and GML is quite similar to it, though I cannot access an object key with a dynamic string. The error it gives is "unable to convert string "jump" to int64" as it expects an integer index, though I want a string object property. I am new to Game Maker Studio 2, so I would appreciate some assistance; looking online didn't seem to provide relevant info.

GML:
var directions = {
    jump: "w",
    crouch: "s",
    left: "a",
    right: "d"
}

var action = "jump";

show_debug_message(directions[action]);
 
Top