From c205e30fc12921565d53499567b8d9c7af1b19c6 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 9 Nov 2020 09:37:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=8C=E6=99=AF=E6=A8=A1=E5=9D=97=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=96=B9=E6=B3=95=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/bg.lua | 11 ++--------- main.lua | 12 +++++++++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Zframework/bg.lua b/Zframework/bg.lua index c8d60c27..908c98b2 100644 --- a/Zframework/bg.lua +++ b/Zframework/bg.lua @@ -9,16 +9,9 @@ local BG={ discard=NULL, } ---Load Background files from SOURCE ONLY -for _,v in next,love.filesystem.getDirectoryItems("parts/backgrounds")do - if love.filesystem.getRealDirectory("parts/backgrounds/"..v)~=SAVEDIR then - local name=v:sub(1,-5) - BGlist[name]=require("parts/backgrounds/"..name) - else - LOG.print("Dangerous file : %SAVE%/parts/backgrounds/"..v) - end +function BG.add(name,bg) + BGlist[name]=bg end - function BG.send(...) if BG.event then BG.event(...) diff --git a/main.lua b/main.lua index f22f03f2..9f2717e8 100644 --- a/main.lua +++ b/main.lua @@ -130,7 +130,17 @@ AIFUNC= require("parts/ai") MODES= require("parts/modes") TICK= require("parts/tick") ---Load Scene files from SOURCE ONLY +--Load background files from SOURCE ONLY +for _,v in next,love.filesystem.getDirectoryItems("parts/backgrounds")do + if love.filesystem.getRealDirectory("parts/backgrounds/"..v)~=SAVEDIR then + local name=v:sub(1,-5) + BG.add(name,require("parts/backgrounds/"..name)) + else + LOG.print("Dangerous file : %SAVE%/parts/backgrounds/"..v) + end +end + +--Load scene files from SOURCE ONLY for _,v in next,fs.getDirectoryItems("parts/scenes")do if fs.getRealDirectory("parts/scenes/"..v)~=SAVEDIR then require("parts/scenes/"..v:sub(1,-5))