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

local m = false

if flags.videlLyvov then
  miniCreate()
  m = true
end

function rasstavit()
SetObjectPosition(1,270,67)
SetObjectPosition(2,602,66)
SetObjectPosition(3,437,233)
SetObjectPosition(4,271,398)
SetObjectPosition(5,603,399)
end;

local state = {1,2,3,4,5}
local STATE = {3,5,1,4,2}

local lastID = nil

local fufufu = false

function gameinput (sender,obj_id,attachedID)
  MiniInterfaceHandler(sender, obj_id);
  sendersProcessing(sender,obj_id,attachedID)
  if wrongItemWarning(sender, obj_id, attachedID) then
    return
  end
  if sender==1 then
    if obj_id >= 1 and obj_id <= 5 then
      if not m then
        CreatePlashechka("601")
      else
        if not lastID then
          lastID = obj_id
          setcolor(obj_id,0.8,0.8,0.8,1)
        else
          if obj_id == lastID then
            setcolor(lastID,1,1,1,1)
            lastID = nil
          else
            if state[obj_id] == 1 or state[lastID] == 1 then
              swap(obj_id,lastID)
              setcolor(lastID,1,1,1,1)
              lastID = nil
              playeffect("block")
              checkMini()
            else
              setcolor(lastID,1,1,1,1)
              lastID = obj_id
              setcolor(lastID,0.8,0.8,0.8,1)
  end  end  end  end  end  end  
  if sender == 10 then
    neighbors.Lions.lock = true
    neighbors.Muzey.lock = false
    playeffect("gate")
    fufufu = true
    rasstavit()
    Block_Show_Cur(true)
    CreatePlashechka("608")
    playeffect("mini_complete")
    StartTimer(timerID,1.5,"unBlock_Show_Cur")
  end
  if sender == 121 then
    if fufufu then
      CloseSatelite()
    end
  end
end


function swap(a,b)
  local x1,y1 = GetObjectPosition(a)
  local x2,y2 = GetObjectPosition(b)
  SetObjectPosition(a,x2,y2)
  SetObjectPosition(b,x1,y1)
  state[a],state[b] = state[b],state[a]
end

function checkMini()
  for i=1,5 do
    if state[i] ~= STATE[i] then
      return
    end
  end
  finish_mini_game(true)
end