I would like control over client ready state from lua.
I would like this for ingame faction selector.
Lua way to click ready button/hide engine ready button
Moderator: Moderators
Re: Lua way to click ready button/hide engine ready button
Spring.SendCommands("forcestart")
But I suppose you want finer control.
But I suppose you want finer control.
Re: Lua way to click ready button/hide engine ready button
This will set individual player ready?
Re: Lua way to click ready button/hide engine ready button
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.
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
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
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
the return value toggles the ready state
Re: Lua way to click ready button/hide engine ready button
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
Code: Select all
bool CLuaHandle::GameSetup(const string& state, bool& ready,
const map<int, string>& playerStates)
Or can I use it without arguments to just retrieve the playerstates?