Lua way to click ready button/hide engine ready button

Lua way to click ready button/hide engine ready button

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Lua way to click ready button/hide engine ready button

Post by Licho »

I would like control over client ready state from lua.

I would like this for ingame faction selector.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Lua way to click ready button/hide engine ready button

Post by zwzsg »

Spring.SendCommands("forcestart")

But I suppose you want finer control.
User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Re: Lua way to click ready button/hide engine ready button

Post by Licho »

This will set individual player ready?
SeanHeron
Engines Of War Developer
Posts: 614
Joined: 09 Jun 2005, 23:39

Re: Lua way to click ready button/hide engine ready button

Post 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.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Lua way to click ready button/hide engine ready button

Post 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;
}
User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Re: Lua way to click ready button/hide engine ready button

Post 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.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Lua way to click ready button/hide engine ready button

Post by jK »

the return value toggles the ready state
User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Re: Lua way to click ready button/hide engine ready button

Post by Licho »

I will check engine how often its called - if its possible to make button and then pass the click through gamesetup callin.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Lua way to click ready button/hide engine ready button

Post 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?
Post Reply

Return to “Feature Requests”