tutorial = tutorial or {}

function tutorial.start()
    --tutorial.state_lamp_show = false
    tutorial.state_inv_lamp = 1 
    tutorial.state_lamp = nil
    tutorial.state_book = nil
    tutorial.inventory_arrow = nil

	--add_score = tutorial.add_score

    tutorial.last_correct_action_time = tutorial.tutorial_timer.Get().GetTime()
	form_event([[
		if not is_object_on_level("lamp") then
			hide("tutorial_bulb")
		end
		if state("table", "table02") then
			hide("tutorial_lamp")
		end
	
		while true do
			if is_object_on_level("lamp") then
				if state("tutorial_bulb", "tutorial_bulb01") then
					if not tutorial.is_pre_arrow_delay() then
					   change_state("tutorial_bulb", "tutorial_bulb02")
					end					
				end
			elseif cursor("lamp") then
				if tutorial.state_lamp == 2 then
					tutorial.state_lamp = 3
					change_state("tutorial_lamp", "tutorial_lamp02")
					
				end

    		    show_ex(nil, false, "tutorial_lamp")
	
    			if not tutorial.state_lamp then
					tutorial.state_lamp = 1
				end
				
                change_invent_state_by_id("lamp", "inv_bulb")
                tutorial.state_inv_lamp = 3
				
			elseif is_object_in_inventory("lamp") then
			    if tutorial.state_inv_lamp == 3 then
			        tutorial.state_inv_lamp = 1
			        if tutorial.inventory_arrow then
			            change_invent_state_by_id("lamp", "inv_arrow")
			        else
			            change_invent_state_by_id("lamp", "__inv")
			        end
			    end
			    
				if tutorial.state_lamp == 1 then
					tutorial.state_lamp = 2
					if not tutorial.inventory_arrow then
                        change_invent_state("lamp")
                        tutorial.inventory_arrow = true
                    end
					
				end
				if not tutorial.inventory_arrow then
					if not tutorial.is_pre_arrow_delay() then
                        change_invent_state("lamp")
                        tutorial.inventory_arrow = true
					end					
				end
				
			    hide_ex(nil, false, "tutorial_lamp")
			
			
			elseif state("table", "table02") and not tutorial.state_book and not is_task_completed(3) then
				if tutorial.state_book == nil then
				    show_ex(nil, false,"tutorial_book")
				    tutorial.state_book = 1
				    tutorial.drop_timer()
				end
				
			elseif state("table", "table02") and tutorial.state_book then

				if state("tutorial_book", "tutorial_book01") then
					if not tutorial.is_pre_arrow_delay() then
						change_state("tutorial_book", "tutorial_book02")
						break
					end
				end
			elseif is_task_completed(3) then
				hide("tutorial_book")
				break
			end
			sleep(50)
		end

	]])
	
end

