Minion 74 Posted September 18, 2014 Share Posted September 18, 2014 LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); lua_pushboolean(L, ch->GetExchange()); return 1; no work. Help me Link to comment Share on other sites More sharing options...
Premium Zonni 230 Posted September 18, 2014 Premium Share Posted September 18, 2014 int pc_do_something(lua_State* L) { LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); if (ch->GetExchange() || ch->GetMyShop() || ch->GetShopOwner() || ch->IsOpenSafebox() || ch->IsCubeOpen()) { lua_pushboolean(L, 1); } else { lua_pushboolean(L, 0); } return 1; } Untested but should work. When character do something function returns true, if not return false. Simple & clean & usefull. Link to comment Share on other sites More sharing options...
Honorable Member martysama0134 7178 Posted September 19, 2014 Honorable Member Share Posted September 19, 2014 LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); lua_pushboolean(L, ch->GetExchange()); return 1; no work. Help me CExchange returns a "CExchange *", so you can't directly use it as an argument for boolean: int pc_is_trade0(lua_State* L) { LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); lua_pushboolean(L, ch->GetExchange() != NULL); return 1; } There are few other ways such as "(ch->GetExchange())" or "!!ch->GetExchange()". int pc_do_something(lua_State* L) { LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); if (ch->GetExchange() || ch->GetMyShop() || ch->GetShopOwner() || ch->IsOpenSafebox() || ch->IsCubeOpen()) { lua_pushboolean(L, 1); } else { lua_pushboolean(L, 0); } return 1; }Untested but should work. When character do something function returns true, if not return false. Simple & clean & usefull. Simplified: int pc_is_busy0(lua_State* L) { LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); lua_pushboolean(L, (ch->GetExchange() || ch->GetMyShop() || ch->GetShopOwner() || ch->IsOpenSafebox() || ch->IsCubeOpen())); return 1; } Check out my GitHub Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now