Page 1 of 1
Lua way to click ready button/hide engine ready button
Posted: 28 Jul 2010, 23:41
by Licho
I would like control over client ready state from lua.
I would like this for ingame faction selector.
Re: Lua way to click ready button/hide engine ready button
Posted: 28 Jul 2010, 23:46
by zwzsg
Spring.SendCommands("forcestart")
But I suppose you want finer control.
Re: Lua way to click ready button/hide engine ready button
Posted: 28 Jul 2010, 23:48
by Licho
This will set individual player ready?
Re: Lua way to click ready button/hide engine ready button
Posted: 30 Jul 2010, 14:42
by SeanHeron
Obviously not. But I guess you could add your own level/variable of "ready"ness, and then "forcestart" the game when that variable is "true" for all players... (and handle that variable through your own GUI, etc.)
But I reckon that sort of hacking is not what you're looking for either. You say you want to use for ingame faction selection - so basiclly if a players done selecting a faction, he should auto-ready, is that the thought?
In general I think this would be a good feature to have.
Re: Lua way to click ready button/hide engine ready button
Posted: 21 Jul 2011, 19:29
by jK
Already told him in chat but there is a way to do so via the GameSetup callin:
Code: Select all
bool CLuaHandle::GameSetup(const string& state, bool& ready,
const map<int, string>& playerStates)
{
if (!CheckModUICtrl()) {
return false;
}
LUA_CALL_IN_CHECK(L);
lua_checkstack(L, 5);
static const LuaHashString cmdStr("GameSetup");
if (!PushUnsyncedCallIn(L, cmdStr)) {
return false;
}
lua_pushsstring(L, state);
lua_pushboolean(L, ready);
lua_newtable(L);
map<int, string>::const_iterator it;
for (it = playerStates.begin(); it != playerStates.end(); ++it) {
lua_pushnumber(L, it->first);
lua_pushsstring(L, it->second);
lua_rawset(L, -3);
}
// call the routine
if (!RunCallInUnsynced(cmdStr, 3, 2)) {
return false;
}
if (lua_isboolean(L, -2)) {
if (lua_toboolean(L, -2)) {
if (lua_isboolean(L, -1)) {
ready = lua_toboolean(L, -1);
}
lua_pop(L, 2);
return true;
}
}
lua_pop(L, 2);
return false;
}
Re: Lua way to click ready button/hide engine ready button
Posted: 21 Jul 2011, 19:52
by Licho
But this does not seem to allow you to change ready state, or does it? Game setup appears to only get playuer list and their ready states.
Re: Lua way to click ready button/hide engine ready button
Posted: 21 Jul 2011, 19:56
by jK
the return value toggles the ready state
Re: Lua way to click ready button/hide engine ready button
Posted: 21 Jul 2011, 20:12
by Licho
I will check engine how often its called - if its possible to make button and then pass the click through gamesetup callin.
Re: Lua way to click ready button/hide engine ready button
Posted: 22 Jul 2011, 20:29
by Jools
Code: Select all
bool CLuaHandle::GameSetup(const string& state, bool& ready,
const map<int, string>& playerStates)
Maybe I mix the callin with a callout, but how do I use that function? Do I need to know all those 4 params, string ready, bool ready, map, string playerstates?
Or can I use it without arguments to just retrieve the playerstates?