-- Script from https://teardownmods.com/index.php?/file/793-university-dorm-bergwall-hall/
-- Check it out, awesome map

function init()
	lvlStart = false
	
	if not GetBool("savegame.mod.dkbridgeLaunched") then
		needReload = true
	end
	ClearKey("savegame.mod.dkbridgeLaunched")
end

local settings = {
	"TrafficVehicles1", "TrafficVehicles2", "Ground", "LongBridgeRopes", "ShortBridgeRopes", "Explosives"
}

function checkLevel()
	if not lvlStart then
		lvlStart = true

		local optionsString = "handle"
		for k, v in ipairs(settings) do
			if GetBool("savegame.mod.dkbridge_"..v) then
				optionsString = optionsString.." "..v
			end
		end

		SetBool("savegame.mod.dkbridgeLaunched", true)
		StartLevel("dkbridge_", "MOD/main.xml", optionsString)
	end
end

function update()
	if needReload then
		checkLevel()
	end
end

function draw()
	if needReload then
		UiTranslate(0,0)
		UiColor(0, 0, 0)
		UiRect(UiWidth(), UiHeight())
	end
end