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

if flags.firein then
  if flags.otkrylBust then
    speciale_action(2,601)
    speciale_action(2,obj.card_16_11.id)
    for i=1,8 do
      set_visible_object(i,false)
    end
  else
    miniCreate()
  end
end

local n = {0,0,0,0}
local N = {8,4,2,9}
local pressed = nil

function gameinput (sender,obj_id,attachedID)
  MiniInterfaceHandler(sender, obj_id,attachedID);
  sendersProcessing(sender,obj_id,attachedID)
  if wrongItemWarning(sender, obj_id, attachedID) then
    return
  end
  if sender==1 then
    if flags.firein then
      if obj_id >= 1 and obj_id <= 8 then
        local i = math.ceil(obj_id/2)      -- вычисляем позицию цифры
        local up = (math.mod(obj_id,2) == 0)  -- если айдишник чётный, значит нажали "вверх"
        pressed = obj_id
        set_visible_object(obj_id,false)
        set_visible_object(10*i+n[i],false)
        playeffect("switch")
        if up then
          if n[i] == 9 then
            n[i] = 0
          else
            n[i] = n[i] + 1
          end  
        else
          if n[i] == 0 then
            n[i] = 9
          else
            n[i] = n[i] - 1
          end
        end
        set_visible_object(10*i+n[i],true)
        checkMini()
      end
    else
      CreatePlashechka("592","he")
    end
    if obj_id == obj.card_16_11.id then
      neighbors.YoungerBust.lock = true
      neighbors.YoungerHidden.lock = false
      neighbors.ZalBratyevHidden.lock = false
      flags.YoungerHidden2=true
      flags.ZalBratyevHidden2=true
      StoreObj(obj.card_16_11.id)
    end
  end
  if sender == 8129 then
    if pressed then
      set_visible_object(pressed,true)
      pressed = nil
    end
  end
  if sender == 10 then
    Journal:addText(14,"9026",148,112,330)
    Journal:addText(14,"9027",550,88,330)
    Journal:addPicture(14,"page14",137,183,0,0,807,400);
    playeffect("tain_bes")
    flags.otkrylBust = true
    -- for i=1,8 do
      -- speciale_action(4,i)
      -- speciale_action(2,i,true,1)
    -- end
    -- speciale_action(2,51)
    -- speciale_action(2,52)
    -- speciale_action(2,53)
    -- speciale_action(2,54)
    speciale_action(2,601,true,1)
    speciale_action(2,obj.card_16_11.id,true,1)
  end
  if sender == 26 then
    --CloseSatelite()
  end
  if sender == 30 then
    if obj.card_16_11 and obj.card_16_11.is_collapsed then
      dofile("./data/16/0/comics.lua")
    end
  end
end

function checkMini()
  for i=1,4 do
    if n[i] ~= N[i] then
      return
    end
  end
  -- speciale_action(4,51)
  -- speciale_action(4,52)
  -- speciale_action(4,53)
  -- speciale_action(4,54)

  -- speciale_action(2,51,true,0.5)
  -- speciale_action(2,52,true,0.5)
  -- speciale_action(2,53,true,0.5)
  -- speciale_action(2,54,true,0.5)
  
  Block_Show_Cur(true)
  
  StartTimer(9546,0.5,"close")
end

function frame1()
  -- speciale_action(4,601)
  -- speciale_action(2,51)
  -- speciale_action(2,52)
  -- speciale_action(2,53)
  -- speciale_action(2,54)
  speciale_action(2,601,true,1)
  speciale_action(2,obj.card_16_11.id,true,1)
  for i=1,8,1 do
    set_visible_object(i,false)
  end;  
  for i=51,54,1 do
    set_visible_object(i,false)
  end;
  set_visible_object(10,false)
  set_visible_object(20,false)
  set_visible_object(30,false)
  set_visible_object(40,false)
  -- StartTimer(9546,3,"CloseSatelite")
end

function close()
  Block_Show_Cur(false)
  finish_mini_game(true)
end


