Skip to content

Commit

Permalink
Properly port [scroll] to Lua
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Apr 5, 2017
1 parent 4c89e93 commit 9b4514d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
11 changes: 10 additions & 1 deletion data/lua/wml-tags.lua
Expand Up @@ -916,7 +916,16 @@ function wml_actions.replace_schedule(cfg)
end

function wml_actions.scroll(cfg)
wesnoth.scroll(cfg)
local sides = utils.get_sides(cfg)
local have_human = false
for i, side in ipairs(sides) do
if side.controller == 'human' and side.local then
have_human = true
end
end
if have_human or #sides == 0 then
wesnoth.scroll(cfg.x, cfg.y)
end
end

function wml_actions.color_adjust(cfg)
Expand Down
16 changes: 3 additions & 13 deletions src/scripting/game_lua_kernel.cpp
Expand Up @@ -3533,21 +3533,11 @@ int game_lua_kernel::intf_set_time_of_day(lua_State * L)

int game_lua_kernel::intf_scroll(lua_State * L)
{
vconfig cfg = luaW_checkvconfig(L, 1);
int x = luaL_checkinteger(L, 1), y = luaL_checkinteger(L, 2);

if (game_display_) {
const std::vector<int> side_list = get_sides_vector(cfg);
bool side_match = false;
for (int side : side_list) {
if(teams()[side-1].is_local_human()) {
side_match = true;
break;
}
}
if ((cfg["side"].empty() && !cfg.has_child("filter_side")) || side_match) {
game_display_->scroll(cfg["x"], cfg["y"], true);
game_display_->draw(true,true);
}
game_display_->scroll(x, y, true);
game_display_->draw(true, true);
}

return 0;
Expand Down
1 change: 1 addition & 0 deletions src/scripting/lua_team.cpp
Expand Up @@ -74,6 +74,7 @@ static int impl_side_get(lua_State *L)
return_tstring_attrib("faction_name", t.faction_name());
return_string_attrib("color", t.color());
return_cstring_attrib("controller", t.controller().to_string().c_str());
return_bool_attrib("local", t.is_local());
return_string_attrib("defeat_condition", t.defeat_condition().to_string());
return_string_attrib("share_vision", t.share_vision().to_string());
return_float_attrib("carryover_bonus", t.carryover_bonus());
Expand Down

0 comments on commit 9b4514d

Please sign in to comment.