MCPcopy Create free account
hub / github.com/defold/defold / SetGlobal

Function SetGlobal

engine/script/src/script.cpp:662–691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

660 }
661
662 uint32_t SetGlobal(lua_State* L, const char* name)
663 {
664 size_t name_length = strlen(name);
665 uint32_t name_hash = dmHashBuffer32(name, name_length);
666 // [-1] instance
667
668 lua_pushlstring(L, name, name_length);
669 // [-1] name
670 // [-2] instance
671
672 lua_pushvalue(L, -2);
673 // [-1] instance
674 // [-2] name
675 // [-3] instance
676
677 lua_settable(L, LUA_GLOBALSINDEX);
678 // [-1] instance
679
680 lua_pushinteger(L, (lua_Integer)name_hash);
681 // [-1] name_hash
682 // [-2] instance
683
684 lua_insert(L, -2);
685 // [-1] instance
686 // [-2] name_hash
687
688 lua_settable(L, LUA_GLOBALSINDEX);
689
690 return name_hash;
691 }
692
693 void GetGlobal(lua_State*L, uint32_t name_hash)
694 {

Callers 2

InitializeFunction · 0.85
ScriptPhysicsRegisterFunction · 0.85

Calls 6

lua_pushlstringFunction · 0.85
lua_pushvalueFunction · 0.85
lua_settableFunction · 0.85
lua_pushintegerFunction · 0.85
lua_insertFunction · 0.85
dmHashBuffer32Function · 0.50

Tested by

no test coverage detected