function klass() local k={} k.__index=k function k:new(...) local n={} setmetatable(n,k) n:init(...) return n end return k end function assert_range(i,mn,mx,name) assert(i >= mn and i < mx, name.." must be ["..mn..","..mx..")") end