-- ~2.5 Hours@60fps
package.path = "./main/?.lua;"
movement = loadfile('movement.lua')
m = movement()
local num = 3

use_move = {
    {'a', 15},
    {'a', 15},
    {'w', 480},
    {'b', 100},
    {'b', 100},
    {'b', 100},
    {'b', 100},
    {'b', 100},
    {'b', 100},
    {'b', 100},
    {'b', 100},
    {'b', 100},
    {'b', 100},
    {'b', 100},
}
gym_loop = {
    {'u', 2},
    {'w', 160},
    {'u', 4},
    {'l', 6},
    {'u', 2},
    {'r', 1}, -- in position for verm loop
    {'a', 15}, -- check can 1
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'u', 3},
    {'r', 1},
    {'a', 15}, -- check can 6
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'u', 3},
    {'r', 1},
    {'a', 15}, -- check can 11
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'u', 2},
    {'r', 5},
    {'d', 2},
    {'l', 1},
    {'a', 15}, -- check can 12
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'d', 3},
    {'l', 1},
    {'a', 15}, -- check can 7
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'d', 3},
    {'l', 1},
    {'a', 15}, -- check can 2
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'d', 2}, 
    {'r', 3},
    {'u', 2},
    {'l', 1},
    {'a', 15}, -- check can 3
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'r', 1},
    {'a', 15}, -- check can 4
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'u', 3},
    {'r', 1},
    {'a', 15}, -- check can 9
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'l', 1},
    {'a', 15}, -- check can 8
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'u', 3},
    {'l', 1},
    {'a', 15}, -- check can 13
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'r', 1},
    {'a', 15}, -- check can 14
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'u', 2},
    {'r', 5},
    {'d', 2},
    {'l', 1},
    {'a', 15}, -- check can 15
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'d', 3},
    {'l', 1},
    {'a', 15}, -- check can 10
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'d', 3},
    {'l', 1},
    {'a', 15}, -- check can 5
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'d', 2},
    {'l', 4},
    {'u', 1},
    {'a', 15}, -- check last can
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'b', 30},
    {'l', 3},
    {'d', 6},
    {'w', 120},
}
press_b = {
    {'b', 60}
}


start3 = {
{'w', 200},
{'l', 14},
{'d', 10},
{'l', 12},
{'u', 12},
{'r', 2},
{'u', 9},
{'r', 23},
{'u', 1},
--mapChange
{'w', 213},
{'u', 1},
{'l', 2},
{'u', 5},
{'r', 3},
{'u', 2},
--mapChange
{'w', 240},
{'u', 2},
{'r', 7},
{'d', 14},
{'r', 3},
{'d', 16},
{'l', 8},
--mapChange
{'d', 35},
{'w', 147},
{'l', 4},
{'d', 6},
{'r', 3},
{'u', 3},
--mapChange
{'w', 237},
{'u', 2},
{'r', 2},
{'u', 3},
{'l', 1},
--mapChange
{'w', 92},
{'d', 58},
--mapChange
{'l', 3},
{'w', 145},
{'d', 4},
{'l', 2},
{'d', 3},
--mapChange
{'w', 274},
{'l', 13},
{'w', 283},
{'w', 374},
{'d', 3},
{'w', 261},
{'a', 21},
{'w', 493},
{'a', 19},
{'w', 416},
{'a', 23},
{'w', 194},
{'a', 23},
{'w', 399},
{'a', 39},
{'w', 140},
{'a', 35},
{'w', 286},
{'a', 31},
{'w', 28},
{'a', 30},
{'w', 363},
{'a', 29},
{'w', 71},
{'a', 18},
{'w', 146},
{'a', 34},
{'w', 31},
{'a', 30},
{'w', 33},
{'a', 30},
{'w', 27},
{'a', 24},
{'w', 29},
{'a', 29},
{'w', 37},
{'a', 23},
{'w', 181},
{'a', 31},
{'w', 66},
{'a', 23},
{'w', 39},
{'a', 26},
{'w', 39},
{'a', 1},
{'w', 198},
{'a', 24},
{'w', 110},
{'a', 19},
{'w', 58},
{'a', 25},
{'w', 176},
{'a', 19},
{'w', 33},
{'a', 30},
{'w', 99},
{'a', 25},
{'w', 46},
{'a', 23},
{'w', 60},
{'d', 4},
{'w', 45},
{'r', 11},
{'w', 85},
{'d', 6},
{'w', 265},
{'a', 25},
{'w', 547},
{'a', 27},
{'w', 345},
{'a', 20},
{'w', 82},
{'a', 25},
{'w', 403},
{'a', 29},
{'w', 58},
{'a', 24},
{'w', 159},
{'a', 24},
{'w', 115},
{'a', 31},
{'w', 83},
{'a', 30},
{'w', 164},
{'a', 31},
{'w', 38},
{'a', 29},
{'w', 38},
{'a', 27},
{'w', 61},
{'a', 23},
{'w', 24},
{'a', 22},
{'w', 54},
{'d', 3},
{'w', 68},
{'l', 6},
{'w', 80},
{'l', 1},
{'w', 46},
{'d', 5},
{'w', 123},
{'a', 29},
{'w', 376},
{'a', 31},
{'w', 30},
{'a', 26},
{'w', 50},
{'a', 24},
{'w', 161},
{'a', 20},
{'w', 25},
{'a', 24},
{'w', 22},
{'a', 22},
{'w', 24},
{'a', 26},
{'w', 403},
{'a', 21},
{'a', 26},
{'w', 23},
{'a', 25},
{'w', 29},
{'a', 25},
{'w', 23},
{'a', 23},
{'w', 28},
{'a', 21},
{'w', 26},
{'a', 15},
{'w', 25},
{'a', 24},
{'w', 30},
{'a', 18},
{'w', 28},
{'a', 19},
{'w', 23},
{'a', 23},
{'w', 23},
{'a', 27},
{'w', 27},
{'a', 22},
{'w', 36},
{'a', 21},
{'w', 26},
{'a', 26},
{'w', 24},
{'a', 17},
{'w', 26},
{'a', 24},
{'w', 27},
{'a', 21},
{'w', 28},
{'a', 24},
{'w', 24},
{'a', 22},
{'w', 31},
{'a', 22},
{'w', 26},
{'a', 22},
{'w', 25},
{'a', 23},
{'w', 31},
{'a', 21},
{'w', 28},
{'a', 18},
{'w', 28},
{'a', 22},
{'w', 23},
{'a', 20},
{'w', 32},
{'a', 17},
{'w', 30},
{'a', 19},
{'w', 29},
{'a', 20},
{'w', 29},
{'a', 22},
{'w', 30},
{'a', 15},
{'w', 23},
{'a', 24},
{'w', 28},
{'a', 23},
{'w', 28},
{'a', 19},
{'w', 28},
{'a', 19},
{'a', 21},
{'w', 22},
{'a', 16},
{'w', 24},
{'a', 17},
{'w', 25},
{'a', 18},
{'w', 22},
{'a', 20},
{'a', 13},
{'a', 15},
{'w', 190},
{'a', 23},
{'a', 26},
{'w', 22},
{'a', 21},
{'w', 22},
{'a', 25},
{'a', 29},
{'a', 25},
{'a', 29},
{'w', 21},
{'a', 27},
{'w', 24},
{'a', 14},
{'w', 28},
{'a', 15},
{'w', 24},
{'a', 17},
{'w', 26},
{'a', 15},
{'w', 23},
{'a', 19},
{'w', 26},
{'a', 17},
{'w', 23},
{'a', 17},
{'w', 25},
{'a', 17},
{'w', 24},
{'a', 17},
{'w', 26},
{'a', 11},
{'w', 184},
{'d', 1},
{'w', 153},
{'a', 28},
{'w', 360},
{'a', 27},
{'w', 21},
{'a', 27},
{'w', 25},
{'a', 21},
{'a', 20},
{'w', 29},
{'a', 19},
{'w', 24},
{'a', 22},
{'a', 18},
{'w', 24},
{'a', 20},
{'w', 25},
{'a', 18},
{'w', 24},
{'a', 24},
{'a', 26},
{'a', 22},
{'w', 22},
{'a', 22},
{'w', 21},
{'a', 23},
{'a', 23},
{'w', 21},
{'a', 20},
{'w', 24},
{'a', 20},
{'w', 24},
{'a', 23},
{'w', 23},
{'a', 10},
{'a', 23},
{'w', 21},
{'a', 22},
{'w', 23},
{'a', 23},
{'w', 27},
{'a', 19},
{'w', 22},
{'a', 19},
{'w', 27},
{'a', 15},
{'w', 25},
{'a', 22},
{'w', 23},
{'a', 21},
{'w', 25},
{'a', 22},
{'a', 23},
{'w', 22},
{'a', 17},
{'w', 24},
{'a', 20},
{'w', 26},
{'a', 18},
{'w', 25},
{'a', 20},
{'w', 23},
{'a', 21},
{'w', 22},
{'a', 21},
{'w', 25},
{'a', 15},
{'w', 23},
{'a', 26},
{'a', 22},
{'w', 22},
{'a', 13},
{'a', 17},
{'w', 24},
{'a', 20},
{'w', 25},
{'a', 19},
{'w', 22},
{'a', 18},
{'w', 21},
{'a', 20},
{'w', 23},
{'a', 21},
{'w', 21},
{'a', 17},
{'w', 22},
{'a', 16},
{'a', 22},
{'w', 24},
{'a', 22},
{'a', 17},
{'w', 26},
{'a', 9},
{'w', 34},
{'a', 13},
{'a', 20},
{'a', 23},
{'w', 25},
{'a', 25},
{'w', 25},
{'a', 19},
{'w', 22},
{'a', 22},
{'w', 23},
{'a', 22},
{'w', 24},
{'a', 28},
{'w', 24},
{'a', 21},
{'a', 20},
{'a', 18},
{'w', 21},
{'a', 23},
{'w', 24},
{'a', 18},
{'w', 119},
{'a', 16},
{'w', 41},
{'a', 9},
{'w', 26},
{'a', 11},
{'w', 21},
{'a', 9},
{'w', 22},
{'a', 9},
{'a', 16},
{'w', 271},
{'a', 11},
{'w', 24},
{'a', 11},
{'a', 14},
{'w', 24},
{'a', 9},
{'a', 14},
{'w', 273},
--mapChange
{'d', 16}, -- enter verm
{'w', 236},
{'r', 8},
{'w', 27},
{'u', 3},
{'w', 41},
{'r', 10},
{'w', 24},
{'d', 9},
{'w', 23},
{'l', 8},
{'w', 59},
{'l', 1},
{'w', 26},
{'u', 2},
{'w', 54},
{'u', 1},
{'w', 25},
{'l', 6},
{'w', 36},
{'d', 7},
{'w', 61},
{'r', 11},
{'w', 25},
{'d', 11},
{'l', 14},
{'w', 44},
{'d', 5},  -- talk to the ship guy
{'w', 189},
{'b', 10},
{'w', 90},
{'b', 16},
{'w', 79},
{'b', 22},
{'w', 76},
{'b', 21},
{'w', 119},
{'b', 20},
{'w', 251},
--mapChange
{'d', 4},
{'w', 123},
--mapChange
{'d', 10}, -- walkway
{'w', 335},
{'d', 7}, -- into boat
{'w', 80},
{'l', 7},
{'w', 89},
{'u', 2},
{'w', 42},
{'l', 12},
--mapChange
{'w', 435},
{'d', 3},
{'w', 23},
{'r', 3},
{'w', 37},
{'d', 8},
{'w', 308},
{'d', 3},
{'w', 34},
{'r', 27},
{'w', 49},
{'u', 9},
{'w', 153},
{'w', 448},
{'a', 1},
{'w', 367},
{'a', 15},
{'w', 122},
{'a', 16},
{'w', 213},
{'a', 14},
{'w', 150},
{'a', 15},
{'w', 405},
{'a', 19},
{'w', 446},
{'a', 24},
{'w', 32},
{'a', 18},
{'w', 1003},
{'a', 18},
{'w', 100},
{'a', 22},
{'w', 335},
{'a', 25},
{'w', 28},
{'a', 20},
{'w', 768},
{'a', 22},
{'w', 129},
{'a', 24},
{'w', 503},
{'a', 24},
{'w', 115},
{'a', 23},
{'w', 1223},
{'a', 24},
{'w', 124},
{'a', 27},
{'w', 572},
{'a', 16},
{'w', 32},
{'a', 21},
{'w', 918},
{'a', 27},
{'w', 109},
{'a', 21},
{'w', 644},
{'a', 27},
{'w', 119},
{'a', 24},
{'w', 222},
{'a', 23},
{'w', 161},
{'a', 18},
{'w', 249},
{'a', 19},
{'w', 159},
{'a', 27},
{'w', 129},
{'a', 21},
{'w', 131},
{'a', 15},
{'w', 125},
{'a', 14},
{'w', 294},
{'a', 22},
{'w', 136},
{'a', 20},
{'w', 256},
{'a', 17},
{'w', 34},
{'a', 19},
{'w', 251},
{'u', 5},
{'w', 123},
--mapChange
{'r', 2},
{'w', 231},
{'r', 3},
{'u', 4},
{'w', 70},
{'l', 1},
{'w', 160},
{'a', 24}, -- get cut
{'w', 72},
{'a', 29},
{'w', 42},
{'a', 38},
{'w', 39},
{'a', 41},
{'w', 29},
{'a', 41},
{'w', 45},
{'a', 40},
{'w', 44},
{'a', 37},
{'w', 47},
{'a', 38},
{'w', 37},
{'a', 39},
{'w', 42},
{'a', 38},
{'w', 37},
{'a', 37},
{'w', 37},
{'a', 32},
{'w', 43},
{'a', 36},
{'w', 45},
{'a', 41},
{'w', 38},
{'a', 28},
{'w', 41},
{'a', 30},
{'w', 38},
{'a', 34},
{'w', 97},
{'d', 4},
{'w', 43},
{'l', 5},
--mapChange
{'w', 200}, -- leave boat
{'w', 247},
{'d', 10},
{'w', 40},
{'l', 28},
{'w', 113},
{'u', 3},
{'w', 31},
{'r', 2},
{'w', 40},
{'u', 6},
{'w', 34},
{'l', 4},
{'w', 33},
{'u', 3},
{'w', 41},
--mapChange
{'r', 4},
{'w', 676},
{'r', 13},
{'w', 42},
{'d', 2},
{'w', 30},
{'r', 4},
{'w', 31},
{'u', 9},
--mapChange
--mapChange
{'w', 2240},
{'u', 1}, -- outside port
{'w', 275},
{'u', 4},
{'w', 21},
{'r', 13},
{'w', 23},
{'u', 10},
{'w', 41},
{'l', 7},
{'w', 28},
{'u', 3},
--mapChange
{'w', 161}, -- enter mart
{'u', 4},
{'w', 51},
{'l', 1},
{'w', 57},
{'a', 11},
{'w', 147},
{'a', 19},
{'w', 586},
{'d', 1},
{'w', 66},
{'l', 1},
{'w', 49},
{'d', 1},
{'w', 42},
{'l', 1},
{'w', 31},
{'d', 1},
{'w', 30},
{'l', 1},
{'w', 28},
{'d', 1},
{'w', 27},
{'l', 1},
{'w', 31},
{'d', 1},
{'w', 25},
{'l', 1},
{'w', 26},
{'d', 1},
{'w', 29},
{'l', 1},
{'w', 309},
{'a', 16},
{'w', 594},
{'d', 1},
{'w', 275},
{'a', 19},
{'w', 150},
{'a', 17},
{'w', 117},
{'a', 18},
{'w', 152},
{'b', 21},
{'w', 91},
{'b', 41},
{'w', 49},
{'b', 29}, -- finish buying repels
{'r', 2},
{'d', 7},
{'reset_start', 1},
{'w', 174}, --  learn cut
{'s', 7},
{'w', 30},
{'u', 1},
{'w', 39},
{'l', 1},
{'w', 38},
{'u', 1},
{'w', 37},
{'l', 1},
{'w', 30},
{'u', 1},
{'w', 39},
{'l', 1},
{'w', 32},
{'u', 1},
{'w', 37},
{'l', 1},
{'w', 41},
{'u', 1},
{'w', 90},
{'d', 1},
{'w', 90},
{'a', 12},
{'w', 90},
{'l', 1},
{'w', 90},
{'w', 90},
{'d', 1},
{'w', 25},
{'l', 1},
{'w', 21},
{'d', 1},
{'l', 1},
{'w', 21},
{'d', 1},
{'l', 1},
{'w', 22},
{'d', 1},
{'l', 1},
{'w', 90},
{'r', 1},
{'w', 100},
{'d', 1},
{'w', 90},
{'a', 17},
{'w', 90},
{'a', 12},
{'w', 100},
{'r', 1},
{'w', 90},
{'a', 20},
{'w', 73},
{'a', 17},
{'w', 90},
{'a', 12},
{'w', 80},
{'a', 20},
{'w', 67},
{'a', 17},
{'w', 81},
{'a', 23},
{'w', 62},
{'a', 22},
{'w', 100},
{'d', 1},
{'w', 51},
{'r', 1},
{'w', 34},
{'d', 1},
{'w', 50},
{'r', 1},
{'w', 39},
{'d', 1},
{'w', 92},
{'a', 10},
{'w', 276},
{'a', 17},
{'w', 65},
{'a', 15},
{'w', 62},
{'a', 15},
{'w', 59},
{'a', 17},
{'w', 100},
{'a', 23},
{'w', 100},
{'b', 36},
{'w', 39},
{'b', 34},
{'w', 42},
{'b', 42},
{'w', 42},
{'b', 42},
{'w', 42},
{'b', 42},
{'w', 42},
{'b', 42},
{'w', 42},
{'b', 42},
{'w', 42},
{'b', 42},
{'w', 151}, -- leave mart
{'l', 2},
{'w', 31},
{'d', 1},
--mapChange
{'w', 221},
{'l', 6},
{'w', 72},
{'d', 6},
{'w', 60},
{'u', 2},
{'w', 23},
{'l', 5},
{'w', 38},
{'l', 1},
{'w', 27},
{'d', 2},
{'w', 233},
{'a', 7},
{'w', 54},
{'a', 10},
{'w', 42},
{'a', 9},
{'w', 40},
{'a', 14},
{'w', 199},
{'d', 3},
{'w', 28},
{'l', 6},
{'u', 1},
--mapChange
{'w', 336}, -- into gym
{'u', 1},
{'w', 208}, -- end here
{'w', 238},
{'r', 6},
{'w', 257},
{'u', 6},
{'w', 82},
{'l', 2},
{'w', 309},
{'a', 16},
{'w', 54},
{'b', 27},
{'b', 20},
{'b', 11},
{'w', 21},
{'b', 19},
{'w', 22},
{'b', 16},
{'w', 23},
{'b', 19},
{'w', 23},
{'b', 19},
{'w', 23},
{'b', 20},
{'w', 21},
{'b', 13},
{'w', 22},
{'b', 19},
{'w', 98},
{'b', 15},
{'w', 22},
{'b', 14},
{'b', 22},
{'b', 20},
{'b', 18},
{'w', 25},
{'b', 15},
{'w', 23},
{'b', 22},
{'w', 22},
{'b', 26},
{'b', 19},
{'w', 21},
{'b', 18},
{'b', 24},
{'b', 15},
{'b', 18},
{'b', 24},
{'b', 15},
{'b', 16},
{'a', 15},
{'r', 1},
{'use_move', 2},
{'b', 60},
{'b', 60},
{'b', 60},
{'b', 60},
{'b', 60},
{'b', 60},
{'b', 60},
{'b', 60},
{'r', 5},
{'w', 30},
{'u', 3},
{'l', 10},
{'a', 60},
{'press_b', 15},
{'a', 60},
{'r', 1},
{'use_move', 3},
{'press_b', 12},
{'r', 15},
{'w', 60},
{'d', 9},
{'l', 6},
{'d', 2},
{'w', 220}, -- breakpoint
{'gym_loop', 80}, -- finish verm puzzle
{'u', 2},
{'w', 130},
{'u', 8},
{'l', 2},
{'u', 10},
{'w', 200},
{'a', 60},
{'a', 60},
{'w', 480},
{'a', 60},
{'w', 360},
{'a', 60},
{'r', 1},
{'use_move', 1},
{'press_b', 5},
{'u', 4},
{'r', 2},
{'u', 2},
{'w', 30},
{'a', 60},
{'press_b', 6},
{'w', 360},
{'b', 60},
{'w', 360},
{'a', 60},
{'r', 1},
{'use_move', 4},
{'press_b', 6},
{'d', 4},
{'r', 2},
{'d', 13},
{'l', 2},
{'d', 3},
--mapChange
{'w', 141},
{'r', 6},
{'w', 32},
{'u', 2},
{'w', 35},
{'a', 24},
{'w', 47},
{'a', 27},
{'w', 30},
{'a', 34},
{'w', 36},
{'a', 30},
{'w', 239}, -- tree cut
{'u', 6},
{'r', 7},
{'u', 7},
{'r', 7},
{'d', 3},
{'r', 10},
{'u', 9},
{'l', 14},
{'l', 1},
{'d', 2},
{'l', 11},
{'l', 1},
{'u', 3},
--mapChange
{'w', 307},
{'u', 4},
{'w', 34},
{'a', 24},
{'w', 34},
{'a', 27},
{'w', 28},
{'a', 29},
{'w', 31},
{'a', 29},
{'w', 33},
{'a', 30},
{'w', 189},
{'a', 31},
{'a', 29},
{'w', 24},
{'a', 26},
{'w', 23},
{'a', 25},
{'w', 24},
{'a', 25},
{'w', 22},
{'a', 24},
{'w', 89},
{'b', 31},
{'b', 22},
{'b', 22},
{'b', 21},
{'b', 16},
{'w', 22},
{'b', 21},
{'b', 23},
{'b', 18},
{'w', 24},
{'d', 6},
--mapChange
{'w', 200},
}


m.executeOrders(start3)
local info = debug.getinfo(1, "S")
local folderName = info.what
local nextScript = num + 1 
savestate.save(string.format("./States/Gym%dFinished.State", num))
print(string.format("You beat Lt. Surge! Making savestate: '%s/States/Gym%dFinished.State'. To continue from here load the state and run %d.lua.", folderName, num, nextScript))