Allow lua integer writes to accept anything that can be converted to an integer

May address #1044
develop
lethosor 2017-03-18 17:55:39 -04:00
parent a35d5493a4
commit fa1adbbac4
1 changed files with 4 additions and 3 deletions

@ -122,10 +122,11 @@ void df::integer_identity_base::lua_read(lua_State *state, int fname_idx, void *
void df::integer_identity_base::lua_write(lua_State *state, int fname_idx, void *ptr, int val_index) void df::integer_identity_base::lua_write(lua_State *state, int fname_idx, void *ptr, int val_index)
{ {
if (!lua_isinteger(state, val_index)) int is_num = 0;
auto value = lua_tointegerx(state, val_index, &is_num);
if (!is_num)
field_error(state, fname_idx, "integer expected", "write"); field_error(state, fname_idx, "integer expected", "write");
write(ptr, value);
write(ptr, lua_tointeger(state, val_index));
} }
void df::float_identity_base::lua_read(lua_State *state, int fname_idx, void *ptr) void df::float_identity_base::lua_read(lua_State *state, int fname_idx, void *ptr)