From 1d2c1888659cd987b2e25c5220faf314bde37e2f Mon Sep 17 00:00:00 2001 From: CadenCoaster <114967401+cadenthecreator@users.noreply.github.com> Date: Sat, 18 Oct 2025 10:47:19 -0700 Subject: [PATCH] Add default positioning for window creation Set default values for x and y if not provided. --- libs/window.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/window.lua b/libs/window.lua index f627550..7d0cd28 100644 --- a/libs/window.lua +++ b/libs/window.lua @@ -53,8 +53,9 @@ end local function clamp(v, lo, hi) return (v < lo) and lo or ((v > hi) and hi or v) end function lib.create(name, w, h, x, y) - if not x then error("no x",2) end - if not y then error("no x",2) end + local sx,sy = term.getSize() + if not x then x = sx/2-w/2 end + if not y then y = sy/2-h/2 end w = math.floor(w + 0.5) h = math.floor(h + 0.5) x = math.floor(x + 0.5)