1.14 controller droid WML/lua

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

Moderator: Forum Moderators

Post Reply
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

1.14 controller droid WML/lua

Post by enclave »

Ok.. I have a complicated question... I might need some undocumented features or even magic to help me here..

In 1.12 droided side has "AI" controller or similar...
In 1.14 droided side has "human" controller or similar.. nothing indicates that the side is controlled by ai at all... I couldn't find any array of side that would link me to understanding if the side is currently droid or human controlled... but it cant be true, there must be something.. PC knows that it has to play side instead of human.. so there must be some lua feature that would indicate that?

What change has happened ? Is droided side now controlled by human player behind it and not host?
My code relying on checking if side is ai or human doesn't work anymore.. therefore my ai events become useless for droided sides.. How could I discern whether the side is currently droid or human?

Thanks..
User avatar
Ravana
Forum Moderator
Posts: 2933
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: 1.14 controller droid WML/lua

Post by Ravana »

It has been decided that whether someone controls side directly or through ai is their private business and is not shared.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: 1.14 controller droid WML/lua

Post by enclave »

how is ai supposed to play on non-standard wesnoth content with custom menus and things? Answer: no way...

I will work around that problem, but the decision itself is politely saying "unwise" if it is not based on any CPU/core/ram/technical difficulties.

I think this decision has to be polled for public vote.

Wait.. maybe I'm stupid somehow.. which is often the case.. Is there a command to give control to ai as a person? Or I misunderstand how droid works?
I mean 9 people started a game, 7 people left.. the host will have to watch all 7 players turns? What if he doesn't want to? What if he wants to give control to Computer Player???
User avatar
Ravana
Forum Moderator
Posts: 2933
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: 1.14 controller droid WML/lua

Post by Ravana »

For local AI, which you have during its turn, you should still be able to see if it is ai. You can use modify_side to change side to local ai.

Related code

Code: Select all

                [option]
                    message=_"change controller"
                    [command]
						[lua]
							code=<<
-- human, network, ai, network_ai, null, idle.
local count = 0
wesnoth.set_variable("Rav_DBG_control["..tostring(count).."].message", "Return")
for i, side in ipairs(wesnoth.sides) do
	if i == wesnoth.current.side then
		goto continue
	end
	
	count = count + 1
	if side.controller == "human" then
		wesnoth.set_variable("Rav_DBG_control["..tostring(count).."].message", "Change side "..tostring(i).." to ai")
		wesnoth.set_variable("Rav_DBG_control[" .. tostring(count) .. "].command.modify_side[0].side", i)
		wesnoth.set_variable("Rav_DBG_control[" .. tostring(count) .. "].command.modify_side[0].controller", "ai")
	else
		wesnoth.set_variable("Rav_DBG_control["..tostring(count).."].message", "Change side "..tostring(i).." to human")
		wesnoth.set_variable("Rav_DBG_control[" .. tostring(count) .. "].command.modify_side[0].side", i)
		wesnoth.set_variable("Rav_DBG_control[" .. tostring(count) .. "].command.modify_side[0].controller", "human")
	end
	::continue::
end
>>
						[/lua]
						[message]
							speaker=narrator
							[insert_tag]
								name=option
								variable=Rav_DBG_control
							[/insert_tag]
						[/message]
						{CLEAR_VARIABLE Rav_DBG_control}
                    [/command]
                [/option]
Post Reply