is_observer LUA or WML equivalent?

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

Moderators: Forum Moderators, Developers

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

is_observer LUA or WML equivalent?

Post by Choicerer » May 3rd, 2018, 3:41 pm

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.
Creator of Choicerer's Map Randomizer - http://bit.ly/2GNcnuv Better Odds - http://bit.ly/2HP41ln
The Better Names Mod - http://bit.ly/2ICIGwz Architecture Mod - http://bit.ly/2JjbNsN
Curse of Satan Claus - http://bit.ly/2pq6MSg The Trolling Mod - http://bit.ly/2GbpAiO
and the Mushroom Isar.

User avatar
Ravana
Moderator
Posts: 1745
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: is_observer LUA or WML equivalent?

Post by Ravana » May 3rd, 2018, 4:23 pm

See [chat] implementation, I added such check there.

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

Re: is_observer LUA or WML equivalent?

Post by Choicerer » May 3rd, 2018, 6:38 pm

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.
Creator of Choicerer's Map Randomizer - http://bit.ly/2GNcnuv Better Odds - http://bit.ly/2HP41ln
The Better Names Mod - http://bit.ly/2ICIGwz Architecture Mod - http://bit.ly/2JjbNsN
Curse of Satan Claus - http://bit.ly/2pq6MSg The Trolling Mod - http://bit.ly/2GbpAiO
and the Mushroom Isar.


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

Re: is_observer LUA or WML equivalent?

Post by Choicerer » May 3rd, 2018, 7:04 pm

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.
Creator of Choicerer's Map Randomizer - http://bit.ly/2GNcnuv Better Odds - http://bit.ly/2HP41ln
The Better Names Mod - http://bit.ly/2ICIGwz Architecture Mod - http://bit.ly/2JjbNsN
Curse of Satan Claus - http://bit.ly/2pq6MSg The Trolling Mod - http://bit.ly/2GbpAiO
and the Mushroom Isar.

User avatar
Ravana
Moderator
Posts: 1745
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: is_observer LUA or WML equivalent?

Post by Ravana » May 3rd, 2018, 7:11 pm

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: 214
Joined: April 29th, 2017, 11:37 pm

Re: is_observer LUA or WML equivalent?

Post by Choicerer » May 3rd, 2018, 7:38 pm

You mean [set_menu_item][filter_location]lua_function?
Creator of Choicerer's Map Randomizer - http://bit.ly/2GNcnuv Better Odds - http://bit.ly/2HP41ln
The Better Names Mod - http://bit.ly/2ICIGwz Architecture Mod - http://bit.ly/2JjbNsN
Curse of Satan Claus - http://bit.ly/2pq6MSg The Trolling Mod - http://bit.ly/2GbpAiO
and the Mushroom Isar.

User avatar
Ravana
Moderator
Posts: 1745
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: is_observer LUA or WML equivalent?

Post by Ravana » May 3rd, 2018, 7:43 pm

That should work too.

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

Re: is_observer LUA or WML equivalent?

Post by Choicerer » May 3rd, 2018, 8:27 pm

That in addition to what?
Creator of Choicerer's Map Randomizer - http://bit.ly/2GNcnuv Better Odds - http://bit.ly/2HP41ln
The Better Names Mod - http://bit.ly/2ICIGwz Architecture Mod - http://bit.ly/2JjbNsN
Curse of Satan Claus - http://bit.ly/2pq6MSg The Trolling Mod - http://bit.ly/2GbpAiO
and the Mushroom Isar.

User avatar
Ravana
Moderator
Posts: 1745
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: is_observer LUA or WML equivalent?

Post by Ravana » May 3rd, 2018, 8:31 pm

SUF also has lua_function, which is there in 1.12 too.

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

Re: is_observer LUA or WML equivalent?

Post by Choicerer » May 3rd, 2018, 8:42 pm

Thanks, I'll try that.
Creator of Choicerer's Map Randomizer - http://bit.ly/2GNcnuv Better Odds - http://bit.ly/2HP41ln
The Better Names Mod - http://bit.ly/2ICIGwz Architecture Mod - http://bit.ly/2JjbNsN
Curse of Satan Claus - http://bit.ly/2pq6MSg The Trolling Mod - http://bit.ly/2GbpAiO
and the Mushroom Isar.

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

Re: is_observer LUA or WML equivalent?

Post by Choicerer » May 5th, 2018, 11:37 am

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.
Creator of Choicerer's Map Randomizer - http://bit.ly/2GNcnuv Better Odds - http://bit.ly/2HP41ln
The Better Names Mod - http://bit.ly/2ICIGwz Architecture Mod - http://bit.ly/2JjbNsN
Curse of Satan Claus - http://bit.ly/2pq6MSg The Trolling Mod - http://bit.ly/2GbpAiO
and the Mushroom Isar.

User avatar
Ravana
Moderator
Posts: 1745
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: is_observer LUA or WML equivalent?

Post by Ravana » May 5th, 2018, 11:41 am

Yes, I said to look [chat] implementation, that makes use of is_local.

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

Re: is_observer LUA or WML equivalent?

Post by Choicerer » May 5th, 2018, 12:58 pm

[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?
Creator of Choicerer's Map Randomizer - http://bit.ly/2GNcnuv Better Odds - http://bit.ly/2HP41ln
The Better Names Mod - http://bit.ly/2ICIGwz Architecture Mod - http://bit.ly/2JjbNsN
Curse of Satan Claus - http://bit.ly/2pq6MSg The Trolling Mod - http://bit.ly/2GbpAiO
and the Mushroom Isar.

User avatar
Ravana
Moderator
Posts: 1745
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: is_observer LUA or WML equivalent?

Post by Ravana » May 5th, 2018, 1:01 pm

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

Post Reply