--*********************************************************************************************************************
function public.Init()

  --------------------------------------------------------------------------------------------
  -- function get_bowstring1 () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "get_bowstring1" ] = {

      type = "get",
      get_obj = "spr_complex_bow_bowstring1",
      room = "int_complex_inv",
      zz = "inv_complex_bow",
      zz_gate = "inv_bow"
  };
  --------------------------------------------------------------------------------------------
  local get_bowstring1_inv = function ()

    interface.InventoryItemRemove( "inv_bow" );
    interface.InventoryItemAdd( "inv_bowstring1", "obj_complex_bow_bowstring1" );

    ObjDelete("gfx_complex_bow_bowstring1");

  end;
  cmn.AddSubscriber( "get_bowstring1", get_bowstring1_inv );
  --------------------------------------------------------------------------------------------
  -- function get_bowwitharrow2 () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "get_bowwitharrow2" ] = {

      type = "get",
      get_obj = "spr_complex_bow_bowstring2",
      room = "int_complex_inv",
      zz = "inv_complex_bow2",
      zz_gate = "inv_bow2"
  };
  --------------------------------------------------------------------------------------------
  local get_bowwitharrow2_inv = function ()

    interface.InventoryItemRemove( "inv_bow2" );
    interface.InventoryItemAdd( "inv_bowstring2", "spr_complex_bow_bowstring2_fly" );

    ObjDelete("gfx_complex_bow_bowstring2");
    ObjDelete("spr_complex_bow_bowstring2");
    ObjDelete("obj_complex_bow_bowstring2");

  end;
  cmn.AddSubscriber( "get_bowwitharrow2", get_bowwitharrow2_inv );
  --------------------------------------------------------------------------------------------
  -- function get_staple () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "get_staple" ] = {

      type = "get",
      get_obj = "spr_complex_boxstaple_staple",
      room = "int_complex_inv",
      zz = "inv_complex_boxstaple",
      zz_gate = "inv_boxstaple"
  };
  --------------------------------------------------------------------------------------------
  local get_staple_inv = function ()

    --interface.InventoryItemRemove( "inv_boxstaple" );
    interface.InventoryItemAdd( "inv_staple", "spr_complex_boxstaple_staple" );

    ObjDelete("gfx_complex_boxstaple_staple");

    ObjSet("inv_boxstaple_star_light",  { alp = 0 });

  end;
  cmn.AddSubscriber( "get_staple", get_staple_inv );
  --------------------------------------------------------------------------------------------
  -- function get_camera () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "get_camera" ] = {

      type = "get",
      get_obj = "spr_complex_boxstaple_camera",
      room = "int_complex_inv",
      zz = "inv_complex_boxstaple",
      zz_gate = "inv_boxstaple"
  };
  --------------------------------------------------------------------------------------------
  local get_camera_inv = function ()

    interface.InventoryItemRemove( "inv_boxstaple" );
    interface.InventoryItemAdd( "inv_camera", "spr_complex_boxstaple_camera" );

    ObjDelete("gfx_complex_boxstaple_camera");
    ObjDelete("spr_complex_boxstaple_camera_sh");

  end;
  cmn.AddSubscriber( "get_camera", get_camera_inv );
  --------------------------------------------------------------------------------------------
  -- function get_wallpicture () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "get_wallpicture" ] = {

      type = "get",
      get_obj = "spr_complex_parcel_wallpicture",
      room = "int_complex_inv",
      zz = "inv_complex_parcel",
      zz_gate = "inv_parcel"
  };
  --------------------------------------------------------------------------------------------
  local get_wallpicture_inv = function ()

    interface.InventoryItemRemove( "inv_parcel" );
    interface.InventoryItemAdd( "inv_wallpicture", "spr_complex_parcel_wallpicture" );

  end;
  cmn.AddSubscriber( "get_wallpicture", get_wallpicture_inv );
  --------------------------------------------------------------------------------------------
  -- function get_arrowwithvelcro () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "get_arrowwithvelcro" ] = {

      type = "get",
      get_obj = "spr_complex_arrow2_arrowwithvelcro",
      room = "int_complex_inv",
      zz = "inv_complex_arrow2",
      zz_gate = "inv_arrow2"
  };
  --------------------------------------------------------------------------------------------
  local get_arrowwithvelcro_inv = function ()

    interface.InventoryItemRemove( "inv_arrow2" );
    interface.InventoryItemAdd( "inv_arrowwithvelcro", "spr_complex_arrow2_arrowwithvelcro" );

    ObjSet("inv_bow2_star_light",  { alp = 1 });

    ObjDelete("gfx_complex_arrow2_arrowwithvelcro");

  end;
  cmn.AddSubscriber( "get_arrowwithvelcro", get_arrowwithvelcro_inv );
  --------------------------------------------------------------------------------------------
  -- function get_console () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "get_console" ] = {

      type = "get",
      get_obj = "obj_complex_remotewithoutbatteries_get_console",
      room = "int_complex_inv",
      zz = "inv_complex_remotewithoutbatteries",
      zz_gate = "inv_remotewithoutbatteries"
  };
  --------------------------------------------------------------------------------------------
  local get_console_inv = function ()

    interface.InventoryItemRemove( "inv_remotewithoutbatteries" );
    interface.InventoryItemAdd( "inv_console", "spr_complex_remotewithoutbatteries_console" );

    ObjDelete("gfx_complex_remotewithoutbatteries_console");
    ObjDelete("spr_complex_remotewithoutbatteries_remote");
    ObjDelete("obj_complex_remotewithoutbatteries_get_console");

  end;
  cmn.AddSubscriber( "get_console", get_console_inv );
  --------------------------------------------------------------------------------------------
  -- function get_coin () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "get_coin" ] = {

      type = "get",
      get_obj = "spr_complex_tangle_coin",
      room = "int_complex_inv",
      zz = "inv_complex_tangle",
      zz_gate = "inv_tangle"
  };
  --------------------------------------------------------------------------------------------
  local get_coin_inv = function ()
  
    interface.InventoryItemAdd( "inv_coin", "spr_complex_tangle_coin" );

    if cmn.IsEventDone("get_greenbutton") and cmn.IsEventDone("get_insulatingtape") then
      interface.InventoryItemRemove( "inv_tangle" );
    end;
  
  end;
  
  local get_coin_closezz = function ()
  
    ObjDelete( "gfx_complex_tangle_coin" );
  
  end;
  
  cmn.AddSubscriber( "get_coin", get_coin_inv );
  cmn.AddSubscriber( "get_coin", get_coin_closezz, "inv_complex_tangle" );
  --------------------------------------------------------------------------------------------
  -- function get_greenbutton () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "get_greenbutton" ] = {

      type = "get",
      get_obj = "spr_complex_tangle_greenbutton",
      room = "int_complex_inv",
      zz = "inv_complex_tangle",
      zz_gate = "inv_tangle"
  };
  --------------------------------------------------------------------------------------------
  local get_greenbutton_inv = function ()
  
    interface.InventoryItemAdd( "inv_greenbutton", "spr_complex_tangle_greenbutton" );

    if cmn.IsEventDone("get_coin") and cmn.IsEventDone("get_insulatingtape") then
      interface.InventoryItemRemove( "inv_tangle" );
    end;
  
  end;
  
  local get_greenbutton_closezz = function ()
  
    ObjDelete( "gfx_complex_tangle_greenbutton" );
  
  end;
  
  cmn.AddSubscriber( "get_greenbutton", get_greenbutton_inv );
  cmn.AddSubscriber( "get_greenbutton", get_greenbutton_closezz, "inv_complex_tangle" );
  --------------------------------------------------------------------------------------------
  -- function get_insulatingtape () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "get_insulatingtape" ] = {

      type = "get",
      get_obj = "spr_complex_tangle_insulatingtape",
      room = "int_complex_inv",
      zz = "inv_complex_tangle",
      zz_gate = "inv_tangle"
  };
  --------------------------------------------------------------------------------------------
  local get_insulatingtape_inv = function ()
  
    interface.InventoryItemAdd( "inv_insulatingtape", "spr_complex_tangle_insulatingtape" );

    if cmn.IsEventDone("get_coin") and cmn.IsEventDone("get_greenbutton") then
      interface.InventoryItemRemove( "inv_tangle" );
    end;
  
  end;
  
  local get_insulatingtape_closezz = function ()
  
    ObjDelete( "gfx_complex_tangle_insulatingtape" );
  
  end;
  
  cmn.AddSubscriber( "get_insulatingtape", get_insulatingtape_inv );
  cmn.AddSubscriber( "get_insulatingtape", get_insulatingtape_closezz, "inv_complex_tangle" );

  --------------------------------------------------------------------------------------------
  -- function use_arrow () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "use_arrow" ] = {

      type = "use",
      inv_obj = "inv_arrow",
      use_place = "obj_complex_bow_use_arrow",
      room = "int_complex_inv",
      zz = "inv_complex_bow",
      zz_gate = "inv_bow"
  };
  --------------------------------------------------------------------------------------------
  local use_arrow_inv = function ()

    interface.InventoryItemRemove( "inv_arrow" );

    --ObjSet("inv_bow_star_light",  { alp = 0 });

  end;
  local use_arrow_beg = function ()

    ObjDelete( "obj_complex_bow_use_arrow" );

  end;
  local use_arrow_end = function ()

    ObjSet( "obj_complex_bow_bowstring1", { input = true, alp = 1 } );

    ObjDelete("spr_complex_bow_empty");

  end;
  cmn.AddSubscriber( "use_arrow", use_arrow_inv );
  cmn.AddSubscriber( "use_arrow", use_arrow_beg, "inv_complex_bow" );
  cmn.AddSubscriber( "use_arrow", use_arrow_end, "inv_complex_bow" );
  cmn.AddSubscriber( "use_arrow_inv", use_arrow_inv );
  cmn.AddSubscriber( "use_arrow_beg", use_arrow_beg, "inv_complex_bow" );
  cmn.AddSubscriber( "use_arrow_end", use_arrow_end, "inv_complex_bow" );
  --------------------------------------------------------------------------------------------
  -- function use_arrowwithvelcro () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "use_arrowwithvelcro" ] = {

      type = "use",
      inv_obj = "inv_arrowwithvelcro",
      use_place = "obj_complex_bow2_use_arrow",
      room = "int_complex_inv",
      zz = "inv_complex_bow2",
      zz_gate = "inv_bow2"
  };
  --------------------------------------------------------------------------------------------
  local use_arrowwithvelcro_inv = function ()

    interface.InventoryItemRemove( "inv_arrowwithvelcro" );

    --ObjSet("inv_bow2_star_light",  { alp = 0 });

  end;
  local use_arrowwithvelcro_beg = function ()

    ObjDelete( "obj_complex_bow2_use_arrow" );

  end;
  local use_arrowwithvelcro_end = function ()

    ObjMultiSet( { {"spr_complex_bow_bowstring2", { alp = 1 }},
                   {"obj_complex_bow_bowstring2", { input = 1 }} } );

    ObjDelete("spr_complex_bow2_empty");

  end;
  cmn.AddSubscriber( "use_arrowwithvelcro", use_arrowwithvelcro_inv );
  cmn.AddSubscriber( "use_arrowwithvelcro", use_arrowwithvelcro_beg, "inv_complex_bow2" );
  cmn.AddSubscriber( "use_arrowwithvelcro", use_arrowwithvelcro_end, "inv_complex_bow2" );
  cmn.AddSubscriber( "use_arrowwithvelcro_inv", use_arrowwithvelcro_inv );
  cmn.AddSubscriber( "use_arrowwithvelcro_beg", use_arrowwithvelcro_beg, "inv_complex_bow2" );
  cmn.AddSubscriber( "use_arrowwithvelcro_end", use_arrowwithvelcro_end, "inv_complex_bow2" );
  --------------------------------------------------------------------------------------------
  -- function use_number18 () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "use_number18" ] = {

      type = "use",
      inv_obj = "inv_number18",
      use_place = "obj_complex_boxstaple_use_number18",
      room = "int_complex_inv",
      zz = "inv_complex_boxstaple",
      zz_gate = "inv_boxstaple"
  };
  --------------------------------------------------------------------------------------------
  local use_number18_inv = function ()
    
    interface.InventoryItemRemove( "inv_number18" );

    --ObjSet("inv_boxstaple_star_light",  { alp = 0 });

  end;
  local use_number18_beg = function ()
    
    ObjDelete( "obj_complex_boxstaple_use_number18" );

  end;
  local use_number18_end = function ()

    ObjMultiSet( { {"spr_complex_boxstaple_camera", { input = true, alp = 1 }},
                   {"spr_complex_boxstaple_box_open", { alp = 1 }},
                   {"spr_complex_boxstaple_lockers_open", { alp = 1 }} } );

    ObjDelete("spr_complex_boxstaple_box_cover");
    ObjDelete("spr_complex_boxstaple_box_cover_sh");

  end;
  cmn.AddSubscriber( "use_number18", use_number18_inv );
  cmn.AddSubscriber( "use_number18", use_number18_beg, "inv_complex_boxstaple" );
  cmn.AddSubscriber( "use_number18", use_number18_end, "inv_complex_boxstaple" );
  cmn.AddSubscriber( "use_number18_inv", use_number18_inv );
  cmn.AddSubscriber( "use_number18_beg", use_number18_beg, "inv_complex_boxstaple" );
  cmn.AddSubscriber( "use_number18_end", use_number18_end, "inv_complex_boxstaple" );
  --------------------------------------------------------------------------------------------
  -- function use_battery () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "use_battery" ] = {

      type = "use",
      inv_obj = "inv_battery",
      use_place = "obj_complex_remotewithoutbatteries_use_battery",
      room = "int_complex_inv",
      zz = "inv_complex_remotewithoutbatteries",
      zz_gate = "inv_remotewithoutbatteries"
  };
  --------------------------------------------------------------------------------------------
  local use_battery_inv = function ()

    interface.InventoryItemRemove( "inv_battery" );

  end;
  local use_battery_beg = function ()

    ObjDelete( "obj_complex_remotewithoutbatteries_use_battery" );

  end;
  local use_battery_end = function ()

    ObjMultiSet( { {"spr_complex_remotewithoutbatteries_battery1", { alp = 1 }},
                   {"spr_complex_remotewithoutbatteries_battery2", { alp = 1 }},
                   {"spr_complex_remotewithoutbatteries_cover", { input = 1 }} } );

  end;
  cmn.AddSubscriber( "use_battery", use_battery_inv );
  cmn.AddSubscriber( "use_battery", use_battery_beg, "inv_complex_remotewithoutbatteries" );
  cmn.AddSubscriber( "use_battery", use_battery_end, "inv_complex_remotewithoutbatteries" );
  cmn.AddSubscriber( "use_battery_inv", use_battery_inv );
  cmn.AddSubscriber( "use_battery_beg", use_battery_beg, "inv_complex_remotewithoutbatteries" );
  cmn.AddSubscriber( "use_battery_end", use_battery_end, "inv_complex_remotewithoutbatteries" );
  --------------------------------------------------------------------------------------------
  -- function use_bubblegum () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "use_bubblegum" ] = {

      type = "use",
      inv_obj = "inv_bubblegum",
      use_place = "obj_complex_arrow2_use_bubblegum",
      room = "int_complex_inv",
      zz = "inv_complex_arrow2",
      zz_gate = "inv_arrow2"
  };
  --------------------------------------------------------------------------------------------
  local use_bubblegum_inv = function ()

    interface.InventoryItemRemove( "inv_bubblegum" );

  end;
  local use_bubblegum_beg = function ()

    ObjDelete( "obj_complex_arrow2_use_bubblegum" );

  end;
  local use_bubblegum_end = function ()

    ObjMultiSet( { {"obj_complex_arrow2_use_hankline", { input = 1, active = 1, visible = 1 }},
                   {"spr_complex_arrow2_gum", { alp = 1 }} } );

  end;
  cmn.AddSubscriber( "use_bubblegum", use_bubblegum_inv );
  cmn.AddSubscriber( "use_bubblegum", use_bubblegum_beg, "inv_complex_arrow2" );
  cmn.AddSubscriber( "use_bubblegum", use_bubblegum_end, "inv_complex_arrow2" );
  cmn.AddSubscriber( "use_bubblegum_inv", use_bubblegum_inv );
  cmn.AddSubscriber( "use_bubblegum_beg", use_bubblegum_beg, "inv_complex_arrow2" );
  cmn.AddSubscriber( "use_bubblegum_end", use_bubblegum_end, "inv_complex_arrow2" );
  --------------------------------------------------------------------------------------------
  -- function use_hankline () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "use_hankline" ] = {

      type = "use",
      inv_obj = "inv_hankline",
      use_place = "obj_complex_arrow2_use_hankline",
      room = "int_complex_inv",
      zz = "inv_complex_arrow2",
      zz_gate = "inv_arrow2"
  };
  --------------------------------------------------------------------------------------------
  local use_hankline_inv = function ()

    interface.InventoryItemRemove( "inv_hankline" );

    --ObjSet("inv_arrow2_star_light",  { alp = 0 });

  end;
  local use_hankline_beg = function ()

    ObjDelete( "obj_complex_arrow2_use_hankline" );

  end;
  local use_hankline_end = function ()

    ObjMultiSet( { {"spr_complex_arrow2_arrowwithvelcro", { input = 1 }},
                   {"spr_complex_arrow2_hankline", { alp = 1 }} } );

  end;
  cmn.AddSubscriber( "use_hankline", use_hankline_inv );
  cmn.AddSubscriber( "use_hankline", use_hankline_beg, "inv_complex_arrow2" );
  cmn.AddSubscriber( "use_hankline", use_hankline_end, "inv_complex_arrow2" );
  cmn.AddSubscriber( "use_hankline_inv", use_hankline_inv );
  cmn.AddSubscriber( "use_hankline_beg", use_hankline_beg, "inv_complex_arrow2" );
  cmn.AddSubscriber( "use_hankline_end", use_hankline_end, "inv_complex_arrow2" );

  --------------------------------------------------------------------------------------------
  -- function clk_clickstaple () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "clk_clickstaple" ] = {

      type = "click",
      use_place = "obj_complex_boxstaple_clk_clickstaple",
      room = "int_complex_inv",
      zz = "inv_complex_boxstaple",
      zz_gate = "inv_boxstaple"
  };
  --------------------------------------------------------------------------------------------
  local clk_clickstaple = function ()

    ObjSet("spr_complex_boxstaple_staple",  { alp = 1, input = 1 });

    ObjDelete("obj_complex_boxstaple_clk_clickstaple");
    ObjDelete("spr_complex_boxstaple_staple_2");
    ObjDelete("spr_complex_boxstaple_staple_1");
    ObjDelete("spr_complex_boxstaple_staple_1_sh");

  end;
  cmn.AddSubscriber( "clk_clickstaple", clk_clickstaple, "inv_complex_boxstaple" );

  --------------------------------------------------------------------------------------------
  -- function clk_unraveltangle () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "clk_unraveltangle" ] = {

      type = "click",
      use_place = "obj_complex_tangle_clk_unraveltangle",
      room = "int_complex_inv",
      zz = "inv_complex_tangle",
      zz_gate = "inv_tangle"
  };
  --------------------------------------------------------------------------------------------
  local clk_unraveltangle = function ()

    --ObjMultiSet( { {"spr_complex_tangle_coin", { alp = 1, input = 1 }},
    --               {"spr_complex_tangle_greenbutton", { alp = 1, input = 1 }},
    --               {"spr_complex_tangle_insulatingtape", { alp = 1, input = 1 }} } );

    ObjSet("obj_complex_tangle_uravel",  { alp = 1, input = 1 });

    ObjDelete("obj_complex_tangle_clk_unraveltangle");
    ObjDelete("spr_complex_tangle_state1");
    ObjDelete("spr_complex_tangle_state2");
    ObjDelete("spr_complex_tangle_state3");

  end;
  cmn.AddSubscriber( "clk_unraveltangle", clk_unraveltangle, "inv_complex_tangle" );
  --------------------------------------------------------------------------------------------
  -- function clk_remotecover1 () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "clk_remotecover1" ] = {

      type = "click",
      use_place = "obj_complex_remotewithoutbatteries_clk_open",
      room = "int_complex_inv",
      zz = "inv_complex_remotewithoutbatteries",
      zz_gate = "inv_remotewithoutbatteries"
  };
  --------------------------------------------------------------------------------------------
  local clk_remotecover1 = function ()

    ObjMultiSet( { {"spr_complex_remotewithoutbatteries_cover", { pos_x = 248, pos_y = 8 }},
                   {"obj_complex_remotewithoutbatteries_use_battery", { input = 1 }} } );

    ObjDelete("obj_complex_remotewithoutbatteries_clk_open");

  end;
  cmn.AddSubscriber( "clk_remotecover1", clk_remotecover1, "inv_complex_remotewithoutbatteries" );
  --------------------------------------------------------------------------------------------
  -- function clk_remotecover2 () end;
  --------------------------------------------------------------------------------------------
  game.hint[ "clk_remotecover2" ] = {

      type = "click",
      use_place = "spr_complex_remotewithoutbatteries_cover",
      room = "int_complex_inv",
      zz = "inv_complex_remotewithoutbatteries",
      zz_gate = "inv_remotewithoutbatteries"
  };
  --------------------------------------------------------------------------------------------
  local clk_remotecover2 = function ()

    ObjMultiSet( { {"spr_complex_remotewithoutbatteries_cover", { pos_x = 66, pos_y = 102 }},
                   {"spr_complex_remotewithoutbatteries_remote", { input = 0 }},
                   {"obj_complex_remotewithoutbatteries_get_console", { input = 1 }} } );


  end;
  cmn.AddSubscriber( "clk_remotecover2", clk_remotecover2, "inv_complex_remotewithoutbatteries" );

end;
--*********************************************************************************************************************
-- function *** CLOSE FUNC *** () end;
--*********************************************************************************************************************
function public.inv_complex_bow_close()

  if cmn.IsEventDone( "use_arrow" ) and not cmn.IsEventDone( "get_bowstring1" ) then

    cmn.SetEventDone( "get_bowstring1" );
    cmn.CallEventHandler( "get_bowstring1", "inv_complex_bow" );

    cmn.PlayAudio( "snd", "assets/levels/common/audio/aud_takeobject" );

  end;

end;
--------------------------------------------------------------------------------------------
function public.inv_complex_boxstaple_close()

  if cmn.IsEventDone( "use_number18" ) and not cmn.IsEventDone( "get_camera" ) then

    cmn.SetEventDone( "get_camera" );
    cmn.CallEventHandler( "get_camera", "inv_complex_boxstaple" );

    cmn.PlayAudio( "snd", "assets/levels/common/audio/aud_takeobject" );

  end;

  if cmn.IsEventDone( "clk_clickstaple" ) and not cmn.IsEventDone( "get_staple" ) then

    cmn.SetEventDone( "get_staple" );
    cmn.CallEventHandler( "get_staple", "inv_complex_boxstaple" );

    cmn.PlayAudio( "snd", "assets/levels/common/audio/aud_takeobject" );

  end;

end;
--------------------------------------------------------------------------------------------
function public.inv_complex_parcel_close()

  if cmn.IsEventDone( "use_scissorsparcel" ) and not cmn.IsEventDone( "get_wallpicture" ) then

    cmn.SetEventDone( "get_wallpicture" );
    cmn.CallEventHandler( "get_wallpicture", "inv_complex_parcel" );

    cmn.PlayAudio( "snd", "assets/levels/common/audio/aud_takeobject" );

  end;

end;
--------------------------------------------------------------------------------------------
function public.inv_complex_bow2_close()

  if cmn.IsEventDone( "use_arrowwithvelcro" ) and not cmn.IsEventDone( "get_bowwitharrow2" ) then

    ObjSet("spr_complex_bow_bowstring2_fly",  { alp = 1 });

    cmn.SetEventDone( "get_bowwitharrow2" );
    cmn.CallEventHandler( "get_bowwitharrow2", "inv_complex_bow2" );

    cmn.PlayAudio( "snd", "assets/levels/common/audio/aud_takeobject" );

  end;

end;
--------------------------------------------------------------------------------------------
function public.inv_complex_arrow2_close()

  if cmn.IsEventDone( "use_hankline" ) and not cmn.IsEventDone( "get_arrowwithvelcro" ) then

    cmn.SetEventDone( "get_arrowwithvelcro" );
    cmn.CallEventHandler( "get_arrowwithvelcro", "inv_complex_arrow2" );

    cmn.PlayAudio( "snd", "assets/levels/common/audio/aud_takeobject" );

  end;

end;
--------------------------------------------------------------------------------------------
function public.inv_complex_remotewithoutbatteries_close()

  if cmn.IsEventDone( "clk_remotecover2" ) and not cmn.IsEventDone( "get_console" ) then

    ObjSet("spr_complex_remotewithoutbatteries_console",  { alp = 1 });

    cmn.SetEventDone( "get_console" );
    cmn.CallEventHandler( "get_console", "inv_complex_remotewithoutbatteries" );

    cmn.PlayAudio( "snd", "assets/levels/common/audio/aud_takeobject" );

  end;

end;
--------------------------------------------------------------------------------------------
function public.inv_complex_tangle_close()

  if cmn.IsEventDone( "clk_unraveltangle" ) then

    cmn.PlayAudio( "snd", "assets/levels/common/audio/aud_takeobject" );

    if not cmn.IsEventDone( "get_coin" ) then

      cmn.SetEventDone( "get_coin" );
      cmn.CallEventHandler( "get_coin", "inv_complex_tangle" );

    end;

    if not cmn.IsEventDone( "get_greenbutton" ) then

      cmn.SetEventDone( "get_greenbutton" );
      cmn.CallEventHandler( "get_greenbutton", "inv_complex_tangle" );

    end;

    if not cmn.IsEventDone( "get_insulatingtape" ) then

      cmn.SetEventDone( "get_insulatingtape" );
      cmn.CallEventHandler( "get_insulatingtape", "inv_complex_tangle" );

    end;

  end;

end;
--*********************************************************************************************************************
-- function *** PROGRESS USE *** () end;
--*********************************************************************************************************************
function public.use_arrow()

  local item = "inv_arrow";

  if cmn.ObjIntersectCheck( item, "obj_complex_bow_use_arrow" )  then

    cmn.CallEventHandler( "use_arrow_inv", "inv_complex_bow" );
    cmn.CallEventHandler( "use_arrow_beg", "inv_complex_bow" );

    local func_after = function ()

      cmn.Lock( 0 );

      cmn.SetEventDone( "use_arrow" );
      cmn.CallEventHandler( "use_arrow_end", "inv_complex_bow" );
      
    end;

    cmn.Lock( 1 );

    cmn.PlayAudio("snd", "assets/levels/level1/inv_complex/inv_bow/audio/aud_usearrow");

    ObjAnimate( "obj_complex_bow_bowstring1", "alp", 0, 0, func_after,
    { 
      0.0, 0, 0, 
      0.5, 0, 1
    } );

    ObjAnimate( "spr_complex_bow_empty", "alp", 0, 0, "",
    { 
      0.0, 0, 1, 
      0.5, 0, 0
    } );

  else
    
    cmn.WrongApply();  

  end;

end;
--------------------------------------------------------------------------------------------
function public.use_number18()

  local item = "inv_number18";

  if cmn.ObjIntersectCheck( item, "obj_complex_boxstaple_use_number18" )  then

    cmn.CallEventHandler( "use_number18_inv", "inv_complex_boxstaple" );
    cmn.CallEventHandler( "use_number18_beg", "inv_complex_boxstaple" );

    local func_after = private.use_number18_end;

    cmn.Lock( 1 );

    cmn.PlayAudio("snd", "assets/levels/level1/inv_complex/inv_boxstaple/audio/aud_use18");

    ObjAnimate( "spr_complex_boxstaple_number18", "alp", 0, 0, "",
    { 
      0.0, 0, 0, 
      0.3, 0, 1
    } );

    ObjAnimate( "spr_complex_boxstaple_lockers_open2", "alp", 0, 0, func_after,
    { 
      0.0, 0, 0, 
      0.6, 0, 0,
      1.1, 0, 1
    } );

    ObjAnimate( "spr_complex_boxstaple_lockers_open", "alp", 0, 0, "",
    { 
      0.0, 0, 0, 
      0.6, 0, 0,
      1.1, 0, 1
    } );

  else
    
    cmn.WrongApply();  

  end;

end;
--------------------------------------------------------------------------------------------
function private.use_number18_end()

    local func_after = function ()

      cmn.Lock( 0 );

      cmn.SetEventDone( "use_number18" );
      cmn.CallEventHandler( "use_number18_end", "inv_complex_boxstaple" );
      
    end;

    ObjAnimate( "spr_complex_boxstaple_box_cover", "alp", 0, 0, func_after,
    { 
      0.0, 0, 1, 
      0.3, 0, 1,
      1, 0, 0
    } );

    ObjAnimate( "spr_complex_boxstaple_box_open", "alp", 0, 0, "",
    { 
      0.0, 0, 0, 
      0.3, 0, 0,
      1, 0, 1
    } );

end;
--------------------------------------------------------------------------------------------
function public.use_arrowwithvelcro()

  local item = "inv_arrowwithvelcro";

  if cmn.ObjIntersectCheck( item, "obj_complex_bow2_use_arrow" )  then

    cmn.CallEventHandler( "use_arrowwithvelcro_inv", "inv_complex_bow2" );
    cmn.CallEventHandler( "use_arrowwithvelcro_beg", "inv_complex_bow2" );

    local func_after = function ()

      cmn.Lock( 0 );

      cmn.SetEventDone( "use_arrowwithvelcro" );
      cmn.CallEventHandler( "use_arrowwithvelcro_end", "inv_complex_bow2" );
      
    end;

    cmn.Lock( 1 );

    cmn.PlayAudio("snd", "assets/levels/level1/inv_complex/inv_bow/audio/aud_usearrow");

    ObjAnimate( "spr_complex_bow_bowstring2", "alp", 0, 0, func_after,
    { 
      0.0, 0, 0, 
      0.5, 0, 1
    } );

    ObjAnimate( "spr_complex_bow2_empty", "alp", 0, 0, "",
    { 
      0.0, 0, 1, 
      0.5, 0, 0
    } );

  else
    
    cmn.WrongApply();  

  end;

end;
--------------------------------------------------------------------------------------------
function public.use_battery()

  local item = "inv_battery";

  if cmn.ObjIntersectCheck( item, "obj_complex_remotewithoutbatteries_use_battery" )  and ( cmn.CheckMultiObject( "battery", 2 ) ) then

    cmn.CallEventHandler( "use_battery_inv", "inv_complex_remotewithoutbatteries" );
    cmn.CallEventHandler( "use_battery_beg", "inv_complex_remotewithoutbatteries" );

    if cmn.IsEventDone("clk_remotecover1") then
    
      cmn.Lock( 1 );    
      private.use_battery_end();

    else 

      public.clk_remotecover1( true );

    end;

  else
    
    cmn.WrongApply();  

  end;

end;
--------------------------------------------------------------------------------------------
function private.use_battery_end()

  local func_after = function ()

    cmn.Lock( 0 );

    cmn.SetEventDone( "use_battery" );
    cmn.CallEventHandler( "use_battery_end", "inv_complex_remotewithoutbatteries" );
    
  end;

  cmn.Lock( 1 );

  cmn.PlayAudio("snd", "assets/levels/level1/inv_complex/inv_remotewithoutbatteries/audio/aud_battery");

  ObjAnimate( "spr_complex_remotewithoutbatteries_battery1", "alp", 0, 0, "",
  { 
    0.0, 0, 0, 
    0.5, 0, 1
  } );

  ObjAnimate( "spr_complex_remotewithoutbatteries_battery2", "alp", 0, 0, func_after,
  { 
    0.0, 0, 0, 
    0.5, 0, 0,
      1, 0, 1
  } );

end;
--------------------------------------------------------------------------------------------
function public.use_hankline()

  local item = "inv_hankline";

  if cmn.ObjIntersectCheck( item, "obj_complex_arrow2_use_hankline" ) and cmn.IsEventDone("use_bubblegum")  then

    cmn.CallEventHandler( "use_hankline_inv", "inv_complex_arrow2" );
    cmn.CallEventHandler( "use_hankline_beg", "inv_complex_arrow2" );

    local func_after = function ()

      cmn.Lock( 0 );

      cmn.SetEventDone( "use_hankline" );
      cmn.CallEventHandler( "use_hankline_end", "inv_complex_arrow2" );
      
    end;

    cmn.Lock( 1 );

    cmn.PlayAudio("snd", "assets/levels/level1/inv_complex/inv_arrow2/audio/aud_hankline");

    ObjAnimate( "spr_complex_arrow2_hankline", "alp", 0, 0, func_after,
    { 
      0.0, 0, 0, 
      0.5, 0, 1
    } );

  else
    
    cmn.WrongApply();  

  end;

end;
--------------------------------------------------------------------------------------------
function public.use_bubblegum()

  local item = "inv_bubblegum";

  if cmn.ObjIntersectCheck( item, "obj_complex_arrow2_use_bubblegum" )  then

    cmn.CallEventHandler( "use_bubblegum_inv", "inv_complex_arrow2" );
    cmn.CallEventHandler( "use_bubblegum_beg", "inv_complex_arrow2" );

    local func_after = function ()

      cmn.Lock( 0 );

      cmn.SetEventDone( "use_bubblegum" );
      cmn.CallEventHandler( "use_bubblegum_end", "inv_complex_arrow2" );
      
    end;

    cmn.Lock( 1 );

    cmn.PlayAudio("snd", "assets/levels/level1/inv_complex/inv_arrow2/audio/aud_bublegum");

    ObjAnimate( "spr_complex_arrow2_gum", "alp", 0, 0, func_after,
    { 
      0.0, 0, 0, 
      0.5, 0, 1
    } );

  else
    
    cmn.WrongApply();  

  end;

end;
--------------------------------------------------------------------------------------------
function public.use_goldenpendant()

    cmn.WrongApply();  

end;
--*********************************************************************************************************************
-- function *** PROGRESS GET *** () end;
--*********************************************************************************************************************
--------------------------------------------------------------------------------------------
function public.get_coin()

  cmn.SetEventDone( "get_coin" );
  cmn.CallEventHandler( "get_coin" );

  cmn.PlayAudio("snd", "assets/levels/common/audio/aud_takeobject");

  if cmn.IsEventDone("get_greenbutton") and cmn.IsEventDone("get_insulatingtape") then
    common_impl.HideComplexItem();
  end;

end;
--------------------------------------------------------------------------------------------
function public.get_greenbutton()

  cmn.SetEventDone( "get_greenbutton" );
  cmn.CallEventHandler( "get_greenbutton" );

  cmn.PlayAudio("snd", "assets/levels/common/audio/aud_takeobject");

  if cmn.IsEventDone("get_coin") and cmn.IsEventDone("get_insulatingtape") then
    common_impl.HideComplexItem();
  end;

end;
--------------------------------------------------------------------------------------------
function public.get_insulatingtape()

  cmn.SetEventDone( "get_insulatingtape" );
  cmn.CallEventHandler( "get_insulatingtape" );

  cmn.PlayAudio("snd", "assets/levels/common/audio/aud_takeobject");

  if cmn.IsEventDone("get_coin") and cmn.IsEventDone("get_greenbutton") then
    common_impl.HideComplexItem();
  end;

end;
--------------------------------------------------------------------------------------------
function public.get_bowstring1()

  cmn.SetEventDone( "get_bowstring1" );
  cmn.CallEventHandler( "get_bowstring1", "inv_complex_bow" );

  cmn.PlayAudio("snd", "assets/levels/common/audio/aud_takeobject");

  common_impl.HideComplexItem();

end;
--------------------------------------------------------------------------------------------
function public.get_bowwitharrow2()

  ObjSet("spr_complex_bow_bowstring2_fly",  { alp = 1 });

  cmn.SetEventDone( "get_bowwitharrow2" );
  cmn.CallEventHandler( "get_bowwitharrow2", "inv_complex_bow2" );

  cmn.PlayAudio( "snd", "assets/levels/common/audio/aud_takeobject" );

  common_impl.HideComplexItem();

end;
--------------------------------------------------------------------------------------------
function public.get_staple()

  cmn.SetEventDone( "get_staple" );
  cmn.CallEventHandler( "get_staple", "inv_complex_boxstaple" );

  cmn.PlayAudio("snd", "assets/levels/common/audio/aud_takeobject");

end;
--------------------------------------------------------------------------------------------
function public.get_camera()

  cmn.SetEventDone( "get_camera" );
  cmn.CallEventHandler( "get_camera", "inv_complex_boxstaple" );

  cmn.PlayAudio("snd", "assets/levels/common/audio/aud_takeobject");

  common_impl.HideComplexItem();

end;
--------------------------------------------------------------------------------------------
function public.get_wallpicture()

  cmn.SetEventDone( "get_wallpicture" );
  cmn.CallEventHandler( "get_wallpicture", "inv_complex_parcel" );

  cmn.PlayAudio("snd", "assets/levels/common/audio/aud_takeobject");

  common_impl.HideComplexItem();

end;
--------------------------------------------------------------------------------------------
function public.get_console()

  ObjSet("spr_complex_remotewithoutbatteries_console",  { alp = 1 });

  cmn.SetEventDone( "get_console" );
  cmn.CallEventHandler( "get_console", "inv_complex_remotewithoutbatteries" );

  cmn.PlayAudio("snd", "assets/levels/common/audio/aud_takeobject");

  common_impl.HideComplexItem();

end;
--------------------------------------------------------------------------------------------
function public.get_arrowwithvelcro()

  cmn.SetEventDone( "get_arrowwithvelcro" );
  cmn.CallEventHandler( "get_arrowwithvelcro", "inv_complex_arrow2" );

  cmn.PlayAudio("snd", "assets/levels/common/audio/aud_takeobject");

  common_impl.HideComplexItem();

end;
--*********************************************************************************************************************
-- function *** PROGRESS CLICK *** () end;
--*********************************************************************************************************************
function public.clk_clickstaple()

  cmn.Lock( 1 );

  cmn.PlayAudio("snd", "assets/levels/level1/inv_complex/inv_boxstaple/audio/aud_clk_staple");

  ObjSet("obj_complex_boxstaple_clk_clickstaple",  { input = 0 });

  ObjAnimate( "spr_complex_boxstaple_staple_1", "alp", 0, 0, private.clk_clickstaple_end,
  { 
    0.0, 0, 1, 
    0.5, 0, 0
  } );

  ObjAnimate( "spr_complex_boxstaple_staple_1_sh", "alp", 0, 0, "",
  { 
    0.0, 0, 1, 
    0.5, 0, 0
  } );

  ObjAnimate( "spr_complex_boxstaple_staple_2", "alp", 0, 0, "",
  { 
    0.0, 0, 0, 
    0.5, 0, 1
  } );

end;
--------------------------------------------------------------------------------------------
function private.clk_clickstaple_end()

  local func_after = function ()

    cmn.Lock( 0 );

    cmn.SetEventDone( "clk_clickstaple" );
    cmn.CallEventHandler( "clk_clickstaple", "inv_complex_boxstaple" );

  end;

  ObjAnimate( "spr_complex_boxstaple_staple_2", "alp", 0, 0, func_after,
  { 
    0.0, 0, 1, 
    0.5, 0, 0
  } );

  ObjAnimate( "spr_complex_boxstaple_staple", "alp", 0, 0, "",
  { 
    0.0, 0, 0, 
    0.5, 0, 1
  } );

end;
--------------------------------------------------------------------------------------------
function public.clk_unraveltangle()

  local func_after = function ()

    cmn.Lock( 0 );

    cmn.SetEventDone( "clk_unraveltangle" );
    cmn.CallEventHandler( "clk_unraveltangle", "inv_complex_tangle" );

  end;

  cmn.Lock( 1 );

  cmn.PlayAudio("snd", "assets/levels/level1/inv_complex/inv_tangle/audio/aud_tangle");

  ObjSet("obj_complex_tangle_clk_unraveltangle",  { input = 0 });

  ObjAnimate( "spr_complex_tangle_state1", "alp", 0, 0, "",
  { 
    0.0, 0, 1, 
    0.5, 0, 1,
      1, 0, 0
  } );

  ObjAnimate( "spr_complex_tangle_state2", "alp", 0, 0, "",
  { 
    0.0, 0, 0, 
    0.5, 0, 0,
      1, 0, 1,
    1.5, 0, 0
  } );

  ObjAnimate( "spr_complex_tangle_state3", "alp", 0, 0, "",
  { 
    0.0, 0, 0, 
      1, 0, 0,
    1.5, 0, 1,
      2, 0, 0
  } );

  ObjAnimate( "obj_complex_tangle_uravel", "alp", 0, 0, func_after,
  { 
    0.0, 0, 0, 
    1.5, 0, 0,
      2, 0, 1
  } );

end;
--------------------------------------------------------------------------------------------
function public.clk_remotecover1( click )

  local func_after = function ()

    cmn.SetEventDone( "clk_remotecover1" );
    cmn.CallEventHandler( "clk_remotecover1" );

    if click then

      private.use_battery_end();

    else

      cmn.Lock( 0 );

    end;

  end;

  ObjMultiSet( { {"obj_complex_remotewithoutbatteries_clk_open", { input = 0 }},
                 {"obj_complex_remotewithoutbatteries_use_battery", { input = 1 }} } );

  local func_mid = function ()

    ObjSet("spr_complex_remotewithoutbatteries_cover",  { pos_x = 248, pos_y = 8 });

  end;

  cmn.PlayAudio("snd", "assets/levels/level1/inv_complex/inv_remotewithoutbatteries/audio/aud_open_consolelid");

  ObjAnimate("spr_complex_remotewithoutbatteries_cover", "alp", 0, 0, func_after, { 0, 0, 1,   0.3, 0, 0,   0.6, 0, 1 });
  ObjSet("tmr_complex_remotewithoutbatteries_timer",  { time = 0.3, playing = 1, endtrig = func_mid });
  
  cmn.Lock( 1 );

end;
--------------------------------------------------------------------------------------------
function public.clk_remotecover2()

  local func_after = function ()

    cmn.SetEventDone( "clk_remotecover2" );
    cmn.CallEventHandler( "clk_remotecover2" );

    cmn.Lock( 0 );

  end;

  local func_mid = function ()

    ObjMultiSet( { {"spr_complex_remotewithoutbatteries_cover", { pos_x = 66, pos_y = 102 }},
                   {"spr_complex_remotewithoutbatteries_remote", { input = 0 }},
                   {"obj_complex_remotewithoutbatteries_get_console", { input = 1 }} } );

  end;

  cmn.PlayAudio("snd", "assets/levels/level1/inv_complex/inv_remotewithoutbatteries/audio/aud_close_consolelid");

  ObjAnimate("spr_complex_remotewithoutbatteries_cover", "alp", 0, 0, func_after, { 0, 0, 1,   0.3, 0, 0,   0.6, 0, 1 });
  ObjSet("tmr_complex_remotewithoutbatteries_timer",  { time = 0.3, playing = 1, endtrig = func_mid });
  
  cmn.Lock( 1 );

end;
--------------------------------------------------------------------------------------------
--*********************************************************************************************************************
-- function *** OTHER *** () end;
--*********************************************************************************************************************
function public.open_boxstaple()

  common_impl.ShowComplexItem('boxstaple');

  if not(cmn.IsEventDone("opn_boxstaple")) then

    cmn.SetEventDone("opn_boxstaple");

    cmn.TutorialShow( "tutor_9", 0, 512, 384 );

  end;

end;
-------------------------------------------------------------------------------------------