From ec3b1b1c6f6ed364ece503588c780f3d6e564f10 Mon Sep 17 00:00:00 2001 From: rebecca Date: Tue, 14 Jul 2026 20:52:23 +0100 Subject: pos: add index() --- pos.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/pos.lua b/pos.lua index ba1a404..8f4ad94 100644 --- a/pos.lua +++ b/pos.lua @@ -48,6 +48,7 @@ function Pos.floor(self) return Pos:make(math.floor(self.x),math.floor(self.y)) function Pos.ceil(self) return Pos:make(math.ceil(self.x),math.ceil(self.y)) end function Pos.round(self) return Pos:make(rmath.round(self.x),rmath.round(self.y)) end function Pos.divmod(self,size) local div = (self/size):floor() return div, self-div*size end +function Pos.index(self,size) return 1+self.x*size+self.y end function Pos.__tostring(self) return string.format("(%.2f,%.2f)",self.x,self.y) end -- cgit v1.2.3