Skip to content

Conversation

@samisalreadytaken
Copy link

This maintains parity with Valve's implementation.

When a variable is not found in a class, its get/set metamethods are called instead of falling back to the root environment. Since mapbase adds both to all classes regardless of whether they are implemented or not, expected fallbacks would fail.

An additional work to do would be adding a flag on ScriptClassDesc_t to indicate that a class has IScriptInstanceHelper::Get/Set implemented so that only those will have the metamethods created, saving about 10KB of memory (in 32 bit) as well.

::_func3 <- function()
{
	return entindex();
}

// Use CTFPlayer for TF2
CHL2_Player._func2 <- function() { return 1337 }
CHL2_Player._func1 <- function()
{
	printl( _func3() );
	printl( _func2() );
	local fn = function(){}
	// assignment fails but set returns the value
	printl( fn == ( entindex = fn ) );
}

EntIndexToHScript(1)._func1();

PR Checklist

  • My PR follows all guidelines in the CONTRIBUTING.md file
  • My PR targets a develop branch OR targets another branch with a specific goal in mind

@Blixibon Blixibon merged commit 793d8df into mapbase-source:develop Jul 24, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants