--
-- Check out "Getting started" on the Wiki!
--     http://freeschi.com/w/index.php/Main_Page
--     http://freeschi.com/w/index.php/Getting_Started
--     http://freeschi.com/w/index.php/API
--

-- Please rename empty_addon!
lockStars = ScriptThread("lockStars")

-- Run
function lockStars:Run()
	starLock = 5
	
	function star1() starLock = 1 end
	function star2() starLock = 2 end
	function star3() starLock = 3 end
	function star4() starLock = 4 end
	function star5() starLock = 5 end
	
	starMenu = gui.SimpleMenu(self, {
		Title = "Lock stars menu",
		x = 0.03,
		y = 0.02,
		Width = 0.23,
		TitleHeight = 0.05,
		OptionHeight = 0.03,
		CanBeClosed = true
	})
	
	starMenu:AddOption("Lock 1 star", star1)
	starMenu:AddOption("Lock 2 star", star2)
	starMenu:AddOption("Lock 3 star", star3)
	starMenu:AddOption("Lock 4 star", star4)
	starMenu:AddOption("Unlock", star5)
	starMenu:Close()
	
	while self:IsRunning() do
		starMenu:Update()
		
		if LocalPlayer():GetWantedLevel() > starLock then
			LocalPlayer():SetWantedLevel(starLock)
		end
		
		if IsKeyDown(KEY_U) then
			starMenu:Open()
		end
		self:Wait(0)
	end
end

-- OnError
function lockStars:OnError()
	print("lockStars Thread caused an error!")
	self:Reset()
end

-- Register
lockStars:Register()