Lua [allow_extra_recruit] equivalent?

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

Moderators: Forum Moderators, Developers

Lua [allow_extra_recruit] equivalent?

Postby Smok » November 14th, 2016, 5:27 pm

Looking for this.
Smok
 
Posts: 49
Joined: June 14th, 2016, 11:52 am

Re: Lua [allow_extra_recruit] equivalent?

Postby Ravana » November 14th, 2016, 6:41 pm

You can call any wml tag from Lua should you need to.
User avatar
Ravana
Moderator
 
Posts: 1460
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: Lua [allow_extra_recruit] equivalent?

Postby Smok » November 14th, 2016, 7:00 pm

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.
Smok
 
Posts: 49
Joined: June 14th, 2016, 11:52 am

Re: Lua [allow_extra_recruit] equivalent?

Postby Ravana » November 14th, 2016, 7:10 pm

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: .
User avatar
Ravana
Moderator
 
Posts: 1460
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: Lua [allow_extra_recruit] equivalent?

Postby gfgtdf » November 14th, 2016, 7:26 pm

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.
gfgtdf
Developer
 
Posts: 910
Joined: February 10th, 2013, 2:25 pm

Re: Lua [allow_extra_recruit] equivalent?

Postby Smok » November 14th, 2016, 7:46 pm

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"
}
Smok
 
Posts: 49
Joined: June 14th, 2016, 11:52 am

Re: Lua [allow_extra_recruit] equivalent?

Postby gfgtdf » November 14th, 2016, 8:15 pm

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.
gfgtdf
Developer
 
Posts: 910
Joined: February 10th, 2013, 2:25 pm


Return to Lua Labs

Who is online

Users browsing this forum: No registered users and 1 guest