--[[

⠀       	 ⢀⣀⣤⣤⣤⣀⣀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⠟⠉⠉⠉⠉⠉⠉⠉⠙⠻⢶⣄⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠙⣷⡀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⡟⠀⣠⣶⠛⠛⠛⠛⠛⠛⠳⣦⡀⠀⠘⣿⡄⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⠁⠀⢹⣿⣦⣀⣀⣀⣀⣀⣠⣼⡇⠀⠀⠸⣷⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠉⠛⠿⠿⠿⠿⠛⠋⠁⠀⠀⠀⠀⣿⡄
⠀⠀    ⠀⠀⢠⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⢻⡇⠀
       ⠀⣸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣧⠀
⠀⠀⠀⠀⠀⠀⠀⢸⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⠀
⠀⠀⠀⠀⠀⠀⠀⣾⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀
⠀⠀⠀⠀⠀⠀⠀⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀
⠀⠀⠀⠀⠀⠀⢰⣿⠀⠀⠀⠀⣠⡶⠶⠿⠿⠿⠿⢷⣦⠀⠀⠀⠀⠀⠀⣿⠀
⠀⠀⣀⣀⣀⠀⣸⡇⠀⠀⠀⠀⣿⡀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀⠀⠀⠀⠀⣿⠀
⣠⡿⠛⠛⠛⠛⠻⠀⠀⠀⠀⠀⢸⣇⠀⠀⠀⠀⠀⠀⣿⠇⠀⠀⠀⠀⠀⠀⣿⠀
⢻⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⡟⠀⠀   ⣴⣿⠀⠀⠀⠀⠀⠀ ⠀⣿⠀
⠈⠙⢷⣶⣦⣤⣤⣤⣴⣶⣾⠿⠛⠁⢀⣶⡟⠉⠀⠀⠀⠀⠀⠀⠀⠀⢀⡟⠀
    ⠉⠉⠉⠉⠉⠄⠀⠀⠀⠀⠈⣿⣆⡀⠀⠀⠀⠀⠀⠀⢀⣠⣴⡾⠃⠀
⠀         ⠀⠀⠀⠀⠀⠀⠈⠛⠻⢿⣿⣾⣿⡿⠿⠟⠋⠁⠀⠀

We do a little trolling

]]



local dev = GetSelf()

local data = get_base_data()

local rate = 0.1
make_default_activity(rate)

function post_initialize()

	print_message_to_user("ThunderBirds Mods By Thomaz#3537 - Public Release V1",8.0)
	
Burner = false
smoke_equip = false
timer2 = 0
state = 0
timer = 0
end


dev:listen_command(7003) -- smoke

function SetCommand(command,value)
	if(command==7003) then
	
		if smoke_equip then
			state = state + 1
				if state > 1 then
					state = 0
					print_message_to_user("SMOKE OFF")
				else
					print_message_to_user("SMOKE ON")
				end
		end
		
		if Burner == false then
			if state == 1 then
				dev:launch_station(11)
			else
				dev:launch_station(11)
				
			end
		end
	end
end


function update()
smokestation = dev:get_station_info(11)

	if smokestation.CLSID == "{INV-SMOKE-WHITE}" then
	--print_message_to_user("YA YEET")
	end
--print_message_to_user("state :"..state)

	if get_aircraft_draw_argument_value(29) >= 0.21 then
	 Burner = true
	 --print_message_to_user("Burn")
	else 
	 Burner = false
	end
	
	if smokestation.count >= 1 then smoke_equip = true else
	smoke_equip = false
	end
	
	if Burner == false then 
		timer2 = timer2 + 0.1 -- Exit Burn
		timer = 0
	else
		timer2 = 0
		timer = timer + 0.1 -- Enter Burn
	end
	
	if state == 1 then
		if Burner then
			
			if timer == 0.1 then
				dev:launch_station(11)
				--print_message_to_user("1")
			end
				
		else
			if timer2 == 0.1 then
				dev:launch_station(11)
				--print_message_to_user("2")
			end
			
		end
	end
	
	--print_message_to_user("TIMER2: "..timer2)
	--print_message_to_user("TIMER: "..timer)
end
	
need_to_be_closed = false