mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-04 20:11:31 +00:00
wesnoth.terrain_types: add mvt_alias and def_alias
these expose `terrain_type::mvt_type()` and ``terrain_type::def_type()` respectively. (#9969)
This commit is contained in:
parent
cf0eb00518
commit
c3ef8084d5
|
@ -6,6 +6,7 @@
|
|||
* `Convert To Scenario` menu item added to `File` menu that allows converting an already opened map to a scenario.
|
||||
### Multiplayer
|
||||
### Lua API
|
||||
* Add `mvt_alias` and `def_alias` to `wesnoth.terrain_types`.
|
||||
### Packaging
|
||||
* Boost 1.70 or later is now required
|
||||
### Terrain
|
||||
|
|
|
@ -1126,6 +1126,30 @@ int game_lua_kernel::impl_get_terrain_info(lua_State *L)
|
|||
lua_pushinteger(L, info.gives_healing());
|
||||
lua_setfield(L, -2, "healing");
|
||||
|
||||
// movement alias
|
||||
lua_newtable(L);
|
||||
int idx = 1;
|
||||
for (const auto& terrain : info.mvt_type()) {
|
||||
const terrain_type& base = board().map().tdata()->get_terrain_info(terrain);
|
||||
if (!base.id().empty()) {
|
||||
lua_pushstring(L, t_translation::write_terrain_code(base.number()).c_str());
|
||||
lua_rawseti(L, -2, idx++);
|
||||
}
|
||||
}
|
||||
lua_setfield(L, -2, "mvt_alias");
|
||||
|
||||
// defense alias
|
||||
lua_newtable(L);
|
||||
idx = 1;
|
||||
for (const auto& terrain : info.def_type()) {
|
||||
const terrain_type& base = board().map().tdata()->get_terrain_info(terrain);
|
||||
if (!base.id().empty()) {
|
||||
lua_pushstring(L, t_translation::write_terrain_code(base.number()).c_str());
|
||||
lua_rawseti(L, -2, idx++);
|
||||
}
|
||||
}
|
||||
lua_setfield(L, -2, "def_alias");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -5292,10 +5316,10 @@ game_lua_kernel::game_lua_kernel(game_state & gs, play_controller & pc, reports
|
|||
// Create the unit_types table
|
||||
cmd_log_ << lua_unit_type::register_table(L);
|
||||
|
||||
// Create the unit_types table
|
||||
// Create the terrainmap metatables
|
||||
cmd_log_ << lua_terrainmap::register_metatables(L);
|
||||
|
||||
// Create the unit_types table
|
||||
// Create the terrain_types table
|
||||
cmd_log_ << "Adding terrain_types table...\n";
|
||||
lua_getglobal(L, "wesnoth");
|
||||
lua_newuserdatauv(L, 0, 0);
|
||||
|
|
|
@ -291,6 +291,8 @@ wesnoth.scenario = {}
|
|||
---@field castle boolean
|
||||
---@field keep boolean
|
||||
---@field healing boolean
|
||||
---@field mvt_alias string[]
|
||||
---@field def_alias string[]
|
||||
|
||||
---@type table<string, terrain_info>
|
||||
wesnoth.terrain_types = {}
|
||||
|
|
Loading…
Reference in New Issue
Block a user