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: 14673
Joined: 17 Nov 2005, 02:43

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

Post by Forboding Angel »

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?
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

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

Post by Silentwings »

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
sprunk
Posts: 100
Joined: 29 Jun 2015, 07:36

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

Post by sprunk »

Code: Select all

local myteam = Spring.GetMyTeamID()
local _, _, spectator = Spring.GetPlayerInfo(myteam)
Here's your problem. Team ID is not player ID.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

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

Post by Forboding Angel »

/slaps forehead
Post Reply

Return to “Game Development”