Skip to content

Instantly share code, notes, and snippets.

View DatZach's full-sized avatar

Zach Reedy DatZach

View GitHub Profile
function texturegroup_get_names() {
var _result = global.__texturegroup_names;
if (array_length(_result) > 0)
return _result;
var _dataPath = undefined;
for(var i = 1; i < parameter_count(); i++) {
var _paramString = parameter_string(i);
if (filename_ext(_paramString) == ".win") {
_dataPath = _paramString;
/// @function launch_instance()
/// @description Launches another instance of the game, detatching the debugging from the second if needed
/// @author DatZach, Nommiin
// NOTE Requires this extension:
// https://marketplace.yoyogames.com/assets/575/execute-shell
var _dataPath = "";
for(var i = 1; i < parameter_count(); i++) {
var _paramString = parameter_string(i);

Methods

So far we have explored the usage of functions in GML 2.3; however, this is not the full picture. In the examples we've looked at so far, there is actually a decent amount of work that the compiler is hiding from us. In order to fully understand the intricacies of functions and how they deal with scoping we must intimately understand what methods are and how they work under the hood.

Let's first revisit the definition of a function in GML: code to be executed. Recall that functions are actually resources, with a resource index stored in a real.

A method is a function bound to a struct (or instance) via the variable self.

So what does this mean exactly? On the surface this may seem like an insignificant distinction. This distinction is critically important when we start considering the context in which functions are called and execute from.

Let's begin by exploring how the compiler hides methods from us when dealing with global functions:

/// @desc script_execute_va(scriptIndex, arguments)
/// Executes the specified `scriptIndex` spreading the provided `arguments`
/// @param scriptIndex script Script Resource Index
/// @param arguments array Argument array to spread
/// @returns var Script's return value
var scriptIndex = argument0;
var a = argument1;
var argumentCount = array_length_1d(a);
@DatZach
DatZach / IgorInterceptor.cs
Created January 22, 2018 02:16
Igor Interception
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
// References = System, System.Runtime.Serialization, System.XML