backport fp.lua from spaghettimod