本文整理汇总了C++中map_location::set_wml_y方法的典型用法代码示例。如果您正苦于以下问题:C++ map_location::set_wml_y方法的具体用法?C++ map_location::set_wml_y怎么用?C++ map_location::set_wml_y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map_location
的用法示例。
在下文中一共展示了map_location::set_wml_y方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: luaW_tolocation
bool luaW_tolocation(lua_State *L, int index, map_location& loc) {
if (!lua_checkstack(L, LUA_MINSTACK)) {
return false;
}
if (lua_isnoneornil(L, index)) {
// Need this special check because luaW_tovconfig returns true in this case
return false;
}
vconfig dummy_vcfg = vconfig::unconstructed_vconfig();
index = lua_absindex(L, index);
if (lua_istable(L, index) || luaW_tounit(L, index) || luaW_tovconfig(L, index, dummy_vcfg)) {
map_location result;
int x_was_num = 0, y_was_num = 0;
lua_getfield(L, index, "x");
result.set_wml_x(lua_tonumberx(L, -1, &x_was_num));
lua_getfield(L, index, "y");
result.set_wml_y(lua_tonumberx(L, -1, &y_was_num));
lua_pop(L, 2);
if (!x_was_num || !y_was_num) {
// If we get here and it was userdata, checking numeric indices won't help
// (It won't help if it was a config either, but there's no easy way to check that.)
if (lua_isuserdata(L, index)) {
return false;
}
lua_rawgeti(L, index, 1);
result.set_wml_x(lua_tonumberx(L, -1, &x_was_num));
lua_rawgeti(L, index, 2);
result.set_wml_y(lua_tonumberx(L, -1, &y_was_num));
lua_pop(L, 2);
}
if (x_was_num && y_was_num) {
loc = result;
return true;
}
} else if (lua_isnumber(L, index) && lua_isnumber(L, index + 1)) {
// If it's a number, then we consume two elements on the stack
// Since we have no way of notifying the caller that we have
// done this, we remove the first number from the stack.
loc.set_wml_x(lua_tonumber(L, index));
lua_remove(L, index);
loc.set_wml_y(lua_tonumber(L, index));
return true;
}
return false;
}