-- Create the mission.
function create()
  -- Target destination.
  planet = space.getPlanet(misn.factions())

  -- Missions generic.
  misn_type = "Rush"
  misn.setTitle("Rush Delivery to " .. planet)

  -- More mission specifics.
  carg_mass = rnd.int(10, 30)
  carg_type = "Food"
  misn.setDesc(string.format(
                          "%s needs a rush delivery of %d tons of %s by %s.",
                          planet, carg_mass, carg_type, "SOMEDAY"))
  misn_reward = carg_mass * 1000 + rnd.int(0, 5000)
  misn.setReward(string.format("%d Scred", misn_reward))
end

function accept()
  player.addCargo(carg_type, carg_mass)
  toolkit.msg("Mission Accepted",
        string.format("The workers load the %d tons of %s onto your ship.",
        carg_mass, carg_type))
  hook.land("land")
end

function land()
  if planet.name() == planet then
    player.rmCargo(carg_type, carg_mass)
    player.pay(misn_reward)
    toolkit.msg("Mission Accomplished",
          string.format("The workers unload the %s at the docks.", carg_type))
  
  -- Set the hooks.
  hook.land("land")
  end
end