wesnoth/data/campaigns/tutorial/lua/character_selection.lua
Celtic Minstrel 977f05d77f Lua: Replace uses of deprecated (moved) unit functions
Also backtracked the removal of wesnoth.get_recall_units, which is now available as wesnoth.units.find_on_recall - it's just more convenient than passing x=recall to wesnoth.units.find
2019-11-15 22:39:08 -05:00

108 lines
2.2 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- #textdomain wesnoth-tutorial
-- Allows the player to choose whether they want to play Konrad or Lisar
-- for the tutorial
local T = wml.tag
local wml_actions = wesnoth.wml_actions
local _ = wesnoth.textdomain "wesnoth-tutorial"
function wml_actions.select_character()
local character_selection_dialog = {
maximum_height = 250,
maximum_width = 400,
T.helptip { id="tooltip_large" }, -- mandatory field
T.tooltip { id="tooltip_large" }, -- mandatory field
T.grid {
T.row {
T.column {
grow_factor = 1,
border = "all",
border_size = 5,
horizontal_alignment = "left",
T.label {
definition = "title",
label = _"Select Character"
}
}
},
T.row {
T.column {
grow_factor = 1,
border = "all",
border_size = 5,
horizontal_alignment = "left",
T.label {
label = _"Who do you want to play?"
}
}
},
T.row {
T.column {
T.grid {
T.row {
T.column {
grow_factor = 1,
border = "all",
border_size = 5,
T.image {
label = "units/konrad-fighter.png"
}
},
T.column {
grow_factor = 1,
border = "all",
border_size = 5,
T.image {
label = "units/human-princess.png~TC(1,magenta)"
}
}
},
T.row {
T.column {
grow_factor = 1,
border = "all",
border_size = 5,
T.button {
label = _"Konrad",
return_value = 1
}
},
T.column {
grow_factor = 1,
border = "all",
border_size = 5,
T.button {
label = _"Lisar",
return_value = 2
}
}
}
}
}
}
}
}
local character = wesnoth.show_dialog(character_selection_dialog)
local unit = wml.variables.student_store
if character == 2 then
wesnoth.units.to_map({
type = "Fighteress",
id = unit.id,
name = _"Lisar",
unrenamable = true,
profile = "portraits/lisar.png",
canrecruit = true,
facing = unit.facing,
}, unit.x, unit.y )
wesnoth.sides[1].side_name = _"Lisar"
-- enable the help to display this unit's page
wesnoth.add_known_unit("Fighteress")
else
wesnoth.units.to_map(unit)
end
wesnoth.redraw {}
end