function gui.register(function f) This function will be called just before a graphical update. More complicated, but doesn't suffer any frame delays. Nil will be accepted in place of a function to erase a previously registered function, and the previous function (if any) is returned, or nil if none.
| 4822 | // a previously registered function, and the previous function |
| 4823 | // (if any) is returned, or nil if none. |
| 4824 | static int gui_register(lua_State *L) { |
| 4825 | |
| 4826 | // We'll do this straight up. |
| 4827 | |
| 4828 | |
| 4829 | // First set up the stack. |
| 4830 | lua_settop(L,1); |
| 4831 | |
| 4832 | // Verify the validity of the entry |
| 4833 | if (!lua_isnil(L,1)) |
| 4834 | luaL_checktype(L, 1, LUA_TFUNCTION); |
| 4835 | |
| 4836 | // Get the old value |
| 4837 | lua_getfield(L, LUA_REGISTRYINDEX, guiCallbackTable); |
| 4838 | |
| 4839 | // Save the new value |
| 4840 | lua_pushvalue(L,1); |
| 4841 | lua_setfield(L, LUA_REGISTRYINDEX, guiCallbackTable); |
| 4842 | |
| 4843 | // The old value is on top of the stack. Return it. |
| 4844 | return 1; |
| 4845 | |
| 4846 | } |
| 4847 | |
| 4848 | // table sound.get() |
| 4849 | static int sound_get(lua_State *L) |
nothing calls this directly
no test coverage detected