is_observer LUA or WML equivalent?

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

is_observer LUA or WML equivalent?

Post by Choicerer »

1.14 has removed the differentiation between sides a client controls and networked human sides. That used to be a nice way to determine which sides a client controlled. We now have wesnoth.get_viewing_side(), which works nicely to determine if the currently playing side belongs to any client. However, this fails with observers, since they share the vision of the currently playing side, yet don't control it. Is there any equivalent in WML or Lua to the c++ bool is_observer that I can use to allow observers to access a certain feature while still preventing the currently playing side from doing so?
Thanks.
User avatar
Ravana
Forum Moderator
Posts: 2953
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: is_observer LUA or WML equivalent?

Post by Ravana »

See [chat] implementation, I added such check there.
Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: is_observer LUA or WML equivalent?

Post by Choicerer »

Thanks, sadly I need this to be able to display my unsynced menu to observers as well when they click on one of the currently playing player's units.
Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: is_observer LUA or WML equivalent?

Post by Choicerer »

Wait, but does this show for the sides that aren't currently playing, too?
My problem is that I want to prevent the currently playing guy from accesing the menu, but still allow this for observers.
In 1.12 for the observer all sides were controller=networked, here sadly it's human for everyone.
User avatar
Ravana
Forum Moderator
Posts: 2953
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: is_observer LUA or WML equivalent?

Post by Ravana »

You can find if current client is observer. You can use that in menu filter lua_function.

1.14 lobby is not responding, so I wont try to implement it myself yet.
Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: is_observer LUA or WML equivalent?

Post by Choicerer »

You mean [set_menu_item][filter_location]lua_function?
User avatar
Ravana
Forum Moderator
Posts: 2953
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: is_observer LUA or WML equivalent?

Post by Ravana »

That should work too.
Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: is_observer LUA or WML equivalent?

Post by Choicerer »

That in addition to what?
User avatar
Ravana
Forum Moderator
Posts: 2953
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: is_observer LUA or WML equivalent?

Post by Ravana »

SUF also has lua_function, which is there in 1.12 too.
Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: is_observer LUA or WML equivalent?

Post by Choicerer »

Thanks, I'll try that.
Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: is_observer LUA or WML equivalent?

Post by Choicerer »

Well, I've found the thread describing the compatibility changes between 1.12 and 1.13/14 so for anyone who might be wondering about this - there is now an attribute called is_local that replaces the functionality of network/human.
User avatar
Ravana
Forum Moderator
Posts: 2953
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: is_observer LUA or WML equivalent?

Post by Ravana »

Yes, I said to look [chat] implementation, that makes use of is_local.
Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: is_observer LUA or WML equivalent?

Post by Choicerer »

[chat], the WML tag? How can it be making use of a lua proxy table attribute? Oh by the way, where are the WML tags defined in the source code, do you know?
User avatar
Ravana
Forum Moderator
Posts: 2953
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: is_observer LUA or WML equivalent?

Post by Ravana »

data/lua. Many wml tags are just lua functions.
Post Reply