diff options
| author | Eltrac <hi@guhub.cn> | 2025-02-23 10:25:54 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-02-23 10:25:54 +0800 |
| commit | d7156f8787caf167fd4ac5ea11be5cc5c71e5108 (patch) | |
| tree | bcb95d5a9283285f70e87846683f7248b50e0b69 /utils/utils.lua | |
| parent | a3a4040662f6a562d59e2b25462c63aeab99b87f (diff) | |
fix: some rooms spawns with no enemies
Due to incorrect reference to room date directly, killing enemies in one room means killing enemies in other rooms of the same kind.
The problem is now fixed by copying room data instead of referencing it.
Diffstat (limited to 'utils/utils.lua')
| -rw-r--r-- | utils/utils.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/utils/utils.lua b/utils/utils.lua index 3a2dd05..4913385 100644 --- a/utils/utils.lua +++ b/utils/utils.lua @@ -60,3 +60,17 @@ end function utils.resetGraphics() love.graphics.setColor(1,1,1) end + +function utils.copy(t, deep) + local copy = {} + + for k, v in pairs(t) do + if deep and type(v) == "table" then + copy[k] = utils.copy(v, true) + else + copy[k] = v + end + end + + return copy +end |
