MCPcopy Create free account
hub / github.com/TASEmulators/fceux / zapper_set

Function zapper_set

src/lua-engine.cpp:2786–2813  ·  view source on GitHub ↗

zapper.set(table state) Sets the zapper state for the next frame advance.

Source from the content-addressed store, hash-verified

2784//
2785// Sets the zapper state for the next frame advance.
2786static int zapper_set(lua_State* L) {
2787
2788 luaL_checktype(L, 1, LUA_TTABLE);
2789
2790 luazapperx = -1;
2791 luazappery = -1;
2792 luazapperfire = -1;
2793
2794 lua_getfield(L, 1, "x");
2795 if (!lua_isnil(L, -1)) luazapperx = lua_tointeger(L, -1);
2796 lua_pop(L, 1);
2797
2798 lua_getfield(L, 1, "y");
2799 if (!lua_isnil(L, -1)) luazappery = lua_tointeger(L, -1);
2800 lua_pop(L, 1);
2801
2802 lua_getfield(L, 1, "fire");
2803 if (!lua_isnil(L, -1))
2804 {
2805 if (lua_toboolean(L, -1)) // True or string
2806 luazapperfire = 1;
2807 if (lua_toboolean(L, -1) == 0 || lua_isstring(L, -1)) // False or string
2808 luazapperfire = 0;
2809 }
2810 lua_pop(L, 1);
2811
2812 return 0;
2813}
2814
2815// table joypad.read(int which = 1)
2816//

Callers

nothing calls this directly

Calls 5

luaL_checktypeFunction · 0.85
lua_getfieldFunction · 0.85
lua_tointegerFunction · 0.85
lua_tobooleanFunction · 0.85
lua_isstringFunction · 0.85

Tested by

no test coverage detected