From 8d49bc70e5a96c5e54f728a4af9ae53596cbd986 Mon Sep 17 00:00:00 2001 From: yuki Date: Tue, 11 Nov 2025 05:11:10 -0300 Subject: [PATCH] add room destroy function --- main.lua | 1 + obj/Room.lua | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/main.lua b/main.lua index 5f9f778..43215d5 100644 --- a/main.lua +++ b/main.lua @@ -121,6 +121,7 @@ function gotoRoom(room_type, ...) if type(Class) ~= "table" and type(Class) ~= "function" then error("room '"..room_type.."' is not callable (got "..type(Class)..", does room return itself?)") end + if current_room and current_room.destroy then current_room:destroy() end current_room = _G[room_type](...) end diff --git a/obj/Room.lua b/obj/Room.lua index f945190..056c0c1 100644 --- a/obj/Room.lua +++ b/obj/Room.lua @@ -46,4 +46,10 @@ function Room:canvasDraw() self.area:draw() end +---Destroys room +function Room:destroy() + self.area:destroy() + self.area = nil +end + return Room