View difference between Paste ID: RZv2gptG and VxCzWsEg
SHOW: | | - or go back to the newest paste.
1
--hotloading because yesss
2
local hotloadings={}
3
function AddHotloadingFile(f)
4
	hotloadings[f]=file.Read("/lua/"..f)
5
end
6
function AddHotloadingSelf()
7
	local i=1
8
	local info=debug.getinfo(i)
9
	while info != nil do
10
		i=i+1
11
		info=debug.getinfo(i)
12
	end
13
	info=debug.getinfo(i-1)
14-
	AddHotloadingFiles(info.source:match("/lua/(.-%.lua)"))
14+
	AddHotloadingFile(info.source:match("/lua/(.-%.lua)"))
15
end
16
timer.Create("hotloading_update",1,0,function()
17
	for k,v in pairs(hotloadings) do
18
		local c=file.Read("/lua/"..k)
19
		if(c!=v) then
20
			hotloadings[k]=v
21
			include(k)
22
		end
23
	end
24
end)