1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
initclose = {}
prepareclose = {}
addhook("startround","varinit")
function varinit()
	for i=1,100 do
		initclose[i]=false
		prepareclose[i] = false
	end
end
function doorclose(doornumber,trigname)
	if trigname == "mydoor"..doornumber then
		if not(initclose[doornumber]) then
			initclose[doornumber] = true
			parse("trigger mydoordelay"..doornumber)
		else
			if prepareclose[doornumber] then
				prepareclose[doornumber] = false
				initclose[doornumber] = false
			else
				return 1
			end
		end
	end
	if trigname == "mydoorcheck"..doornumber then
		prepareclose[doornumber] = true
		parse("trigger mydoor"..doornumber)
	end
end
addhook("trigger","doorcloseprepare")
function doorcloseprepare(trigname)
	if string.sub(trigname,1,11)=="mydoorcheck" then
		num = string.sub(trigname, 12, string.len(trigname))
	else
		num = string.sub(trigname, 7, string.len(trigname))
	end
	num = tonumber(num)
	if not(num == nil) then
		return doorclose(num,trigname)
	end
end