Lua [allow_extra_recruit] equivalent?

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

Moderator: Forum Moderators

Post Reply
Smok
Posts: 53
Joined: June 14th, 2016, 11:52 am

Lua [allow_extra_recruit] equivalent?

Post by Smok »

Looking for this.
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Lua [allow_extra_recruit] equivalent?

Post by Ravana »

You can call any wml tag from Lua should you need to.
Smok
Posts: 53
Joined: June 14th, 2016, 11:52 am

Re: Lua [allow_extra_recruit] equivalent?

Post by Smok »

You mean using wesnoth.wml_actions.allow_extra_recruit(cfg)? But I don't know how to make cfg object correctly.

Code: Select all

loacl cfg.extra_recruit = "Elvish Fighter"
Don't work.
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Lua [allow_extra_recruit] equivalent?

Post by Ravana »

Code: Select all

wesnoth.fire("modify_side", { side=i, flag="flags/flag-[1~4].png:250~RC(magenta>Rav_yellow)"})
(Used under for i,v in ipairs(wesnoth.sides) do)
Last edited by Ravana on November 14th, 2016, 8:14 pm, edited 1 time in total.
Reason: .
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Lua [allow_extra_recruit] equivalent?

Post by gfgtdf »

i dont see how your code is related to his problem but you don't need wesnoth.fire here, you can call modify_side directly:

Code: Select all

wesnoth.wml_actions.modify_side {
    side=i,
    flag="flags/flag-[1~4].png:250~RC(magenta>Rav_yellow)",
}
generally you only need wesnoth.fire if the wml content might need variable substitution.

NOTE: im assuming here that i is an integer calculated by lua, if i is a taken from a wml variable/container its uit possible that it doe need variable substitution.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Smok
Posts: 53
Joined: June 14th, 2016, 11:52 am

Re: Lua [allow_extra_recruit] equivalent?

Post by Smok »

Thanks gfgtdf. Now I know how to use it correctly. Problem fixed.

Code: Select all

local side = wesnoth.get_variable("side_number")

wesnoth.wml_actions.allow_extra_recruit {
	side = side,
	extra_recruit = "Elvish Fighter"
}
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Lua [allow_extra_recruit] equivalent?

Post by gfgtdf »

i'd replace wesnoth.get_variable("side_number") with wesnoth.current.side. I doubt that there is wml code that actually overwrites the side_number variable but it's possible.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Post Reply