Skip to content

Commit fe42e74

Browse files
committed
use luaL_optnumber() instead of explicit argument number checking. Thanks to cskyzi for the suggestion.
1 parent 7b6ce68 commit fe42e74

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

load81.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,13 @@ int getpixelBinding(lua_State *L) {
254254

255255
int spriteBinding(lua_State *L) {
256256
const char *filename;
257-
int x, y, angle, argc = lua_gettop(L);
257+
int x, y, angle;
258258
void *sprite;
259259

260260
filename = lua_tostring(L, 1);
261261
x = lua_tonumber(L, 2);
262262
y = lua_tonumber(L, 3);
263-
angle = (argc == 4) ? lua_tonumber(L,4) : 0;
263+
angle = luaL_optnumber(L,4,0);
264264
sprite = spriteLoad(L,filename);
265265
spriteBlit(l81.fb, sprite, x, y, angle);
266266
return 1;

0 commit comments

Comments
 (0)