MCPcopy Index your code
hub / github.com/Shopify/go-lua / SetGlobal

Method SetGlobal

lua.go:1082–1088  ·  view source on GitHub ↗

SetGlobal pops a value from the stack and sets it as the new value of global name. http://www.lua.org/manual/5.2/manual.html#lua_setglobal

(name string)

Source from the content-addressed store, hash-verified

1080//
1081// http://www.lua.org/manual/5.2/manual.html#lua_setglobal
1082func (l *State) SetGlobal(name string) {
1083 l.checkElementCount(1)
1084 g := l.global.registry.atInt(RegistryIndexGlobals)
1085 l.push(name)
1086 l.setTableAt(g, l.stack[l.top-1], l.stack[l.top-2])
1087 l.top -= 2 // pop value and key
1088}
1089
1090// SetTable does the equivalent of table[key]=v, where table is the value
1091// at index, v is the value at the top of the stack and key is the value

Callers 5

TestLuaFunction · 0.95
TestErrorfFunction · 0.95
RegisterMethod · 0.95
ExampleFunction · 0.95
RequireFunction · 0.80

Calls 4

checkElementCountMethod · 0.95
pushMethod · 0.95
setTableAtMethod · 0.95
atIntMethod · 0.80

Tested by 3

TestLuaFunction · 0.76
TestErrorfFunction · 0.76
ExampleFunction · 0.76