function mini_create()
  init_mini(true)
  create_mini(8128);
end

local mouseDown = false
local state = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}

if not flags.tryapkaMokraya then
  SetObjectPosition(99,2200,200)
else
  set_visible_object(96,false)
end

if flags.zerkaloChisto then
  for i=1,19 do
    set_visible_object(i,false)
  end
  SetObjectPosition(99,2200,200)
  set_visible_object(97,true)
else
  if neighbors.Kranik.lock then
    miniCreate()
  end
end

function Stiraem()
   for i=1,19,1 do
   SetAlfaValue(i, 0)
   end;
return;end;

function gameinput (sender,obj_id,attachedID)
  -- Write("sender="..sender.." ; obj_id="..obj_id.."\n");
  if sender == 14 then
    if obj.tryapkaMokraya_5_14 and obj_id == obj.tryapkaMokraya_5_14.id then
      removeFromMouse()
    --  UnStoreObj(obj.tryapkaMokraya_5_14.id)
      SetCustomCursor(99)
      tryapka = true
      set_visible_object(96,false)
      flags.tryapkaMokraya = true
      return
    elseif flags.tryapkaMokraya then
      return 
    end
  end
  sendersProcessing(sender,obj_id,attachedID)
  MiniInterfaceHandler(sender, obj_id,attachedID);
  if wrongItemWarning(sender, obj_id, attachedID, "tryapkaMokraya_5_14",99) then
    return
  end
  if sender == 1 then
    if obj_id == 97 then
      CreatePlashechka("622")
    end
    if obj_id == 99 and not flags.zerkaloChisto then
      SetCustomCursor(99)
      tryapka = true
      -- for i=1,19 do
        -- setCursor(i,3)
      -- end
    end
    -- if not flags.tryapkaMokraya and obj_id >= 1 and obj_id <= 19 then
    if obj_id == 96 and (not tryapka) then
      CreatePlashechka("621")
    end
  end
  -- if sender == 8 and ((obj.tryapkaMokraya_5_14 and attachedID==obj.tryapkaMokraya_5_14.id) or attachedID==99)then
    -- freeCustomCursor()
    -- SetObjectPosition(99,200,200)
    -- tryapka = false
  -- end
  if sender == 8128 and tryapka  then
    mouseDown = true
  end
  if sender == 8129 then
    mouseDown = false
  end
  if sender == 10 then
  mouseDown=false
  removeFromMouse()
  UnStoreObj(obj.tryapkaMokraya_5_14.id)
    Journal:addText(6,"9011",563,126,330)
    Journal:addPicture(6,"page6",531,231,428,0,379,301);
    freeCustomCursor()
    playeffect("mini_complete")
    SetAlfa(99,1,0,2)
    tryapka = false
    flags.zerkaloChisto = true
    setCursor(96,3)
    Stiraem()
    set_visible_object(96,false)
    set_visible_object(97,true)
    neighbors.Zerkalo.lock = true
  end
  if sender == 35 then
    if obj_id >= 1 and obj_id <= 19 and mouseDown and not flags.zerkaloChisto and state[obj_id]>0 then
      state[obj_id] = state[obj_id] - 0.5
      SetAlfaValue(obj_id, state[obj_id])
  --    SetAlfa()
      checkClean()
    end
  end
end

function checkClean()
playeffect("mirror")
  for i=1,19 do
    if state[i] > 0 then
      return
    end
  end
  finish_mini_game(true)
end

-- function frame1()
  -- FreeCustomCursor()
  -- SetObjectPosition(99,200,200)
-- end