Checking spectators doesn't work for specs who have always been specs

Checking spectators doesn't work for specs who have always been specs

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14385
Joined: 17 Nov 2005, 02:43

Checking spectators doesn't work for specs who have always been specs

Post by Forboding Angel » 16 Sep 2018, 07:23

So evo has a lot of audio/visual prompting. This can be annoying for spectators, especially spectators who are catching up to a game that is already in progress.

Code: Select all

	if n%30 == 1 then
		local myteam = Spring.GetMyTeamID()
		local _, _, spectator = Spring.GetPlayerInfo(myteam)
		--Spring.Echo(spectator)
		resourcePrompts = Spring.GetConfigInt("evo_resourceprompts", 1)
		simplifiedResourceBar = Spring.GetConfigInt("evo_simplifiedresourcebar", 1)

		--Assume that if it isn't set, resourcePrompts is true
		if resourcePrompts == nil then
			resourcePrompts = 1
		end
		
		if spectator then
			resourcePrompts = 0
		end
		--Spring.Echo(resourcePrompts)
	end
So, this works perfectly if the person was previously a player and is now a spectator. But if the person was always a spectator, it doesn't take any effect at all. How can I just check if the person is a spec, regardless of whether they were originally a player or not.

So as I was writing this post I had an idea:

Code: Select all

	if n%30 == 1 then
		local myteam = Spring.GetMyTeamID()
		local _, _, spectator = Spring.GetPlayerInfo(myteam)
		--Spring.Echo(spectator)
		resourcePrompts = Spring.GetConfigInt("evo_resourceprompts", 1)
		simplifiedResourceBar = Spring.GetConfigInt("evo_simplifiedresourcebar", 1)

		--Assume that if it isn't set, resourcePrompts is true
		if resourcePrompts == nil then
			resourcePrompts = 1
		end
		
		if not spectator then
			resourcePrompts = 1
		else
			resourcePrompts = 0
		end
		
		Spring.Echo("I herd u liek prompts!")
		Spring.Echo(resourcePrompts)
	end
So I then pushed this, and make a game between 2 null ai and myself as a spec and launched the game. Echo for prompts was 0, SUCCESS! But wait... as soon as I selected a unit on the field it changed to 1, and then when I selected the unit from the OTHER team, it was 0 again... what in the hell???

I fully recognize that this is likely because a widget used for spectating is likely getting cute with getplayerinfo. My question is, is there any way for me to work around it?
0 x

User avatar
Silentwings
Moderator
Posts: 3404
Joined: 25 Oct 2008, 00:23

Re: Checking spectators doesn't work for specs who have always been specs

Post by Silentwings » 16 Sep 2018, 08:58

I fully recognize that this is likely because a widget used for spectating is likely getting cute with getplayerinfo. My question is, is there any way for me to work around it?
If that's actually the problem (which I am skeptical about) and "is getting cute" was intended to mean "is breaking", the only reliable way would be to fix or remove that widget.

I didn't read your code closely but it looks as though you are using 0/1 to mean false/true. In Lua doing this is usually discouraged because e.g. http://www.cesarbs.org/blog/2009/10/23/ ... kes-sense/

Code: Select all

--Assume that if it isn't set, resourcePrompts is true
		if resourcePrompts == nil then
			resourcePrompts = 1
		end
		
		if not spectator then
			resourcePrompts = 1
		else
			resourcePrompts = 0
		end
0 x

sprunk
Posts: 75
Joined: 29 Jun 2015, 07:36

Re: Checking spectators doesn't work for specs who have always been specs

Post by sprunk » 18 Sep 2018, 19:54

Code: Select all

local myteam = Spring.GetMyTeamID()
local _, _, spectator = Spring.GetPlayerInfo(myteam)
Here's your problem. Team ID is not player ID.
0 x

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14385
Joined: 17 Nov 2005, 02:43

Re: Checking spectators doesn't work for specs who have always been specs

Post by Forboding Angel » 19 Sep 2018, 03:39

/slaps forehead
0 x

Post Reply

Return to “Game Development”