wi.lua: Fix a bug in the getnextlim function.