diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index f736d188db..76a7e3494d 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -1386,23 +1386,23 @@ public: static int geteffectmagnitude( T* p, lua_State *L ) { RageVector3 v = p->GetEffectMagnitude(); lua_pushnumber(L, v[0]); lua_pushnumber(L, v[1]); lua_pushnumber(L, v[2]); return 3; } static int scaletocover( T* p, lua_State *L ) { p->ScaleToCover( RectF(FArg(1), FArg(2), FArg(3), FArg(4)) ); return 0; } static int scaletofit( T* p, lua_State *L ) { p->ScaleToFitInside( RectF(FArg(1), FArg(2), FArg(3), FArg(4)) ); return 0; } - static int animate( T* p, lua_State *L ) { p->EnableAnimation(!!IArg(1)); return 0; } + static int animate( T* p, lua_State *L ) { p->EnableAnimation(BIArg(1)); return 0; } static int play( T* p, lua_State *L ) { p->EnableAnimation(true); return 0; } static int pause( T* p, lua_State *L ) { p->EnableAnimation(false); return 0; } static int setstate( T* p, lua_State *L ) { p->SetState(IArg(1)); return 0; } - static int texturewrapping( T* p, lua_State *L ) { p->SetTextureWrapping(!!IArg(1)); return 0; } - static int additiveblend( T* p, lua_State *L ) { p->SetBlendMode(!!IArg(1) ? BLEND_ADD : BLEND_NORMAL); return 0; } + static int texturewrapping( T* p, lua_State *L ) { p->SetTextureWrapping(BIArg(1)); return 0; } + static int additiveblend( T* p, lua_State *L ) { p->SetBlendMode(BIArg(1) ? BLEND_ADD : BLEND_NORMAL); return 0; } static int blend( T* p, lua_State *L ) { p->SetBlendMode( Enum::Check(L, 1) ); return 0; } - static int zbuffer( T* p, lua_State *L ) { p->SetUseZBuffer(!!IArg(1)); return 0; } - static int ztest( T* p, lua_State *L ) { p->SetZTestMode((!!IArg(1))?ZTEST_WRITE_ON_PASS:ZTEST_OFF); return 0; } + static int zbuffer( T* p, lua_State *L ) { p->SetUseZBuffer(BIArg(1)); return 0; } + static int ztest( T* p, lua_State *L ) { p->SetZTestMode((BIArg(1))?ZTEST_WRITE_ON_PASS:ZTEST_OFF); return 0; } static int ztestmode( T* p, lua_State *L ) { p->SetZTestMode( Enum::Check(L, 1) ); return 0; } - static int zwrite( T* p, lua_State *L ) { p->SetZWrite(!!IArg(1)); return 0; } + static int zwrite( T* p, lua_State *L ) { p->SetZWrite(BIArg(1)); return 0; } static int zbias( T* p, lua_State *L ) { p->SetZBias(FArg(1)); return 0; } - static int clearzbuffer( T* p, lua_State *L ) { p->SetClearZBuffer(!!IArg(1)); return 0; } - static int backfacecull( T* p, lua_State *L ) { p->SetCullMode((!!IArg(1)) ? CULL_BACK : CULL_NONE); return 0; } + static int clearzbuffer( T* p, lua_State *L ) { p->SetClearZBuffer(BIArg(1)); return 0; } + static int backfacecull( T* p, lua_State *L ) { p->SetCullMode((BIArg(1)) ? CULL_BACK : CULL_NONE); return 0; } static int cullmode( T* p, lua_State *L ) { p->SetCullMode( Enum::Check(L, 1)); return 0; } - static int visible( T* p, lua_State *L ) { p->SetVisible(!!IArg(1)); return 0; } - static int hidden( T* p, lua_State *L ) { p->SetHidden(!!IArg(1)); return 0; } + static int visible( T* p, lua_State *L ) { p->SetVisible(BIArg(1)); return 0; } + static int hidden( T* p, lua_State *L ) { p->SetHidden(BIArg(1)); return 0; } static int hibernate( T* p, lua_State *L ) { p->SetHibernate(FArg(1)); return 0; } static int draworder( T* p, lua_State *L ) { p->SetDrawOrder(IArg(1)); return 0; } static int playcommand( T* p, lua_State *L ) { p->PlayCommand(SArg(1)); return 0; } diff --git a/stepmania/src/ActorFrame.cpp b/stepmania/src/ActorFrame.cpp index ab9122c722..a0a25dfdec 100644 --- a/stepmania/src/ActorFrame.cpp +++ b/stepmania/src/ActorFrame.cpp @@ -389,7 +389,7 @@ class LunaActorFrame : public Luna public: static int playcommandonchildren( T* p, lua_State *L ) { p->PlayCommandOnChildren(SArg(1)); return 0; } static int playcommandonleaves( T* p, lua_State *L ) { p->PlayCommandOnLeaves(SArg(1)); return 0; } - static int propagate( T* p, lua_State *L ) { p->SetPropagateCommands( !!IArg(1) ); return 0; } + static int propagate( T* p, lua_State *L ) { p->SetPropagateCommands( BIArg(1) ); return 0; } static int fov( T* p, lua_State *L ) { p->SetFOV( FArg(1) ); return 0; } static int SetUpdateRate( T* p, lua_State *L ) { p->SetUpdateRate( FArg(1) ); return 0; } static int SetFOV( T* p, lua_State *L ) { p->SetFOV( FArg(1) ); return 0; } diff --git a/stepmania/src/LuaManager.h b/stepmania/src/LuaManager.h index 5a7397598e..ddefdc3e40 100644 --- a/stepmania/src/LuaManager.h +++ b/stepmania/src/LuaManager.h @@ -159,7 +159,23 @@ inline bool MyLua_checkboolean (lua_State *L, int numArg) return !!lua_toboolean( L, numArg ); } +/* BIArg is like BArg, except 1 is accepted as a true value and (as a special case) + * 0 is accepted as a false value. This is to help transitions where "cmd,0" is + * used to mean "cmd,false". */ +inline bool MyLua_checkintboolean( lua_State *L, int iArg ) +{ + int iType = lua_type( L, iArg ); + if( iType == LUA_TNUMBER ) + { + int iValue = lua_tointeger( L, iArg ); + return iValue != 0; + } + + return MyLua_checkboolean( L, iArg ); +} + #define SArg(n) (luaL_checkstring(L,(n))) +#define BIArg(n) (MyLua_checkintboolean(L,(n))) #define IArg(n) (luaL_checkint(L,(n))) #define BArg(n) (MyLua_checkboolean(L,(n))) #define FArg(n) ((float) luaL_checknumber(L,(n))) diff --git a/stepmania/src/RageTexture.cpp b/stepmania/src/RageTexture.cpp index c4185fab9a..aa63cf0446 100644 --- a/stepmania/src/RageTexture.cpp +++ b/stepmania/src/RageTexture.cpp @@ -74,7 +74,7 @@ class LunaRageTexture: public Luna { public: static int position( T* p, lua_State *L ) { p->SetPosition( FArg(1) ); return 0; } - static int loop( T* p, lua_State *L ) { p->SetLooping( !!IArg(1) ); return 0; } + static int loop( T* p, lua_State *L ) { p->SetLooping( BIArg(1) ); return 0; } static int rate( T* p, lua_State *L ) { p->SetPlaybackRate( FArg(1) ); return 0; } LunaRageTexture()