--for continue button

-- All the buttons do the same stuff so let's just import that
local buttonstuff = include("start-1")

-- Helper for save stuff
local misc = include("_misc")

function buttonon()
  buttonstuff.buttonon()
end

function buttonoff()
  buttonstuff.buttonoff()
end

function load()
  dink.playsound(18, 22050, 0, 0, false);

  local save_result = misc.show_savegame_menu()

  if save_result == nil then return true end
  if not dink.game_exist(save_result) then return false end

  --part of a fix for a stange bug where screen is draw twice upon load.
  dink.script_attach(1000);

  stopmidi();
  player.active = true
  player.x = 334
  player.y = 161
  player.base_walk = 70
  player.base_attack = 100
  player.dir = direction.WEST
  player.brain = brain.PLAYER
  player.que = 0
  player.noclip = false
  dink.set_mode(2);

  --wait command, second part fix for previously mentioned double draw screen bug
  dink.wait(0);

  dink.load_game(save_result)
  dink.kill_this_task();
end

function click()
  player.brain = brain.NONE
  local result = load()
  player.brain = brain.MOUSE
  if not result then
    dink.say_xy("`%Try loading a saved game that exists, friend.", 0, 390)
  end
end
