package.path = "./commands/?.lua;"
console.clear()
movement = loadfile('movement.lua')
m = movement()
scriptName = "Script1"

run_daycare = {
    {"runR", 120},
    {"runL", 120},

}
custom1 = {
    {'u', 1},
    {'grass_cycle', 1}
}
custom2 = {
    {'r', 1},
    {'grass_cycle', 1}
}
custom3 = {
    {'d', 1},
    {'grass_cycle', 1}
}
custom4 = {
    {'l', 1},
    {'grass_cycle', 1}
}

custom5 = {
    {'w', 120},
    {'spin', 50},
    {'w', 360}, -- battle started
    {'l', 2},
    {'u', 2},
    {'use_move', 1},
    {'press_b', 10},
    {'d', 1}, -- realign against wall
}
custom6 = {
    {'w', 120},
    {'spin', 50},
    {'w', 360}, -- battle started
    {'l', 2},
    {'u', 2},
    {'press_a', 1},
    {'w', 360},
    {'press_a', 1},
    {'w', 1200},
    {'press_b', 1},
    {'w', 360},
    {'press_b', 1},
    {'w', 360},
    {'d', 1}, -- realign against wall
}
a = {
       -- rom starts
       {'w', 1200},
       {'s', 360},
       {'s', 60},
       {'s', 60},
       {'press_b', 40},
       {'d', 2},
       {'press_a',1},
       {'press_b',8},
       {'w', 360},
       {'press_b',8},
       {'w', 360},
       {'touch_middle', 15},
       {'w', 60},
       {'touch_middle', 15},
       {'w', 60},
       {'press_b', 60},
       {'press_a', 3},
       {'w', 180},
       {'a', 60},
       {'w', 180},
       {'a', 60},
       {'w', 180},
       {'a', 60},
    --    {'a', 60},
       {'r', 8},
       {'d', 1},
       {'a', 15},
       {'l', 4},
       {'a', 15},
       {'l', 4},
       {'d', 1},
       {'a', 15},
       {'r', 5},
       {'u', 1},
       {'a', 15},
       {'s', 15},
       {'press_a', 2},
       {'w', 360},
       {'press_b', 1},
       {'press_a', 1},
       {'w', 180},
       {'press_b', 9},
       {'press_a', 1},
       {'w', 180},
       {'press_a', 1},
       {'d', 1},
       {'r', 2},
       {'a', 15},
       {'u', 1},
       {'l', 2},
       {'a', 15},
       {'r', 9},
       {'d', 1},
       {'a', 15},
       {'l', 2},
       {'u', 1},
       {'a', 15},
       {'s', 15},
       {'press_a', 2},
       {'w', 360},
       {'press_a', 4},
       {'press_b', 40},
       {'w', 600},
       {'press_a', 1},
       {'press_b', 20},
       {'w', 600}, -- standing in room
       {'save', '01-GameBegins'},
    {'r', 2},
    {'press_b', 68},
    {'w', 180},
    {'r', 3},
    {'u', 2},
    {'r', 1},
    {'u', 2},
    {'r', 2},
    {'w', 540},
    {'press_b', 14},
    {'d', 7},
    {'l', 5},
    {'w', 360},
    {'press_b', 18},
    {'d', 1},
    {'w', 180},
    {'d', 1},
    {'w', 720}, -- outside house
    {'l', 8},
    {'u', 10},
    {'l', 5},
    {'u', 2},
    {'press_b', 40},
    {'u', 2},
    {'w', 540},
    {'l', 5},
    {'u', 8},
    {'r', 4},
    {'w', 540},
    {'press_b', 28},
    {'u', 1},
    {'l', 2},
    {'w', 360},
    {'d', 8},
    {'r', 5},
    {'d', 4},
    {'w', 540}, -- outside rival's house
    {'x', 15}, -- change text settings
    {'d', 3},
    {'press_a', 1},
    {'r', 1},
    {'d', 2},
    {'r', 1},
    {'press_b', 2},
    {'press_a', 1},
    {'press_b', 5}, -- text fast and battle anim off
    {'w', 60},
    {'r', 8}, -- walk to rival
    {'u', 24},
    {'w', 180},
    {'press_b', 60}, -- talk to prof
    {'press_a', 25},
    {'press_b', 60},
    {'w', 180},
    {'l', 2}, -- pick a pokemon
    {'press_a', 1},
    {'w', 240},
    {'press_b', 4},
    {'r', 1},
    {'press_a', 4},
    {'w', 180},
    {'press_b', 45},
    {'press_a', 10},
    {'save', '02-RivalBattle'},

    {'w', 1680}, -- battle starts with rival
    {'u', 2},
    {'a', 90},
    {'r', 1},
    {'w', 15},
    {'use_move', 25}, -- lose on purpose
    {'press_b', 40}, -- get running shoes from mom
    {'d', 4}, -- leave mom's place
    {'w', 540},
    {'l', 5},
    {'u', 7},
    {'l', 3},
    {'u', 27},
    {'press_b', 20}, -- talk to math
    {'l', 7},
    {'u', 4},
    {'l', 23},
    {'u', 8},
    {'l', 2},
    {'u', 6},
    {'press_b', 9}, 
    {'w', 540},
    {'press_b', 4},
    {'w', 360},
    {'press_b', 70}, -- talk to genocide man
    {'d', 3},
    {'w', 540},
    {'d', 9},
    {'r', 35}, -- about to walk into grass
    {'u', 2}, -- avoid npc in bottom 2 rows
    {'r', 3},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1}, -- out of grass
    {'r', 20},
    {'u', 2},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'r', 15},
    {'w', 180},
    {'press_b', 30}, -- talk to dawn
    {'w', 720},
    {'press_b', 1},
    {'w', 30},
    {'press_b', 1},
    {'w', 30},
    {'press_b', 1},
    {'w', 30},
    {'press_b', 1},
    {'w', 30},
    {'press_b', 1},
    {'w', 30},
    {'press_b', 1},
    {'w', 30},
    {'press_b', 1},
    {'w', 60},
    {'press_a', 1}, -- name chimchar
    {'w', 300},
    {'press_a', 1},
    {'d', 2},
    {'press_a', 1},
    {'u', 3},
    {'r', 1},
    {'press_a', 1},
    {'d', 2},
    {'r', 1},
    {'press_a', 1},
    {'l', 1},
    {'u', 1},
    {'press_a', 1},
    {'d', 1},
    {'l', 1},
    {'press_a', 1},
    {'r', 3},
    {'u', 1},
    {'press_a', 1},
    {'u', 1},
    {'l', 2},
    {'press_a', 1},
    {'d', 1},
    {'r', 2},
    {'press_a', 1},
    {'u', 1},
    {'press_a', 1},
    {'d', 1},
    {'l', 3},
    {'press_a', 1},
    {'r', 3},
    {'press_a', 1},
    {'w', 30},
    {'s', 15},
    {'press_a', 50}, -- done naming
    {'press_b', 30}, -- listen to prof, receive RETURN
    {'save', '03-AcquiredReturn'},

    {'d', 10},
    {'w', 360},
    {'press_b', 90}, -- listen to dawn
    {'w', 180},
    {'l', 37}, -- done with tutorial, walk back to mom
    {'d', 5},
    {'w', 180},
    {'d', 3},
    {'l', 24},
    {'r', 2},
    {'u', 3},
    {'l', 17},
    {'d', 2},
    {'w', 180},
    {'d', 24},
    {'r', 2},
    {'d', 11},
    {'r', 4},
    {'u', 2},
    {'w', 360}, -- inside mom's house
    {'u', 2},
    {'r', 1},
    {'press_a', 1}, -- talk to mom
    {'press_b', 90}, -- get JOURNAL and PARCEL
    {'d', 3},
    {'w', 360},
    {'l', 4}, -- walk back to poke center
    {'u', 35},
    {'r', 3}, -- before grass
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1}, -- out of grass
    {'r', 20},
    {'u', 2},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'r', 28}, -- walk to pokecenter
    {'u', 4},
    {'w', 360},
    {'u', 2},
    {'l', 7}, -- up escalator 
    {'w', 360},
    {'u', 3},
    {'l', 3},
    {'r', 1},
    {'w', 180}, -- get ready for running
    {'run_daycare', 2730}, -- max out friendship :)
    {'save', '04-AfterFriendshipMax'},
    {'w', 60},
    {'r', 3}, -- leave pokecenter
    {'d', 3},
    {'l', 2},
    {'w', 360},
    {'r', 5},
    {'d', 4},
    {'w', 360}, -- outside again
    {'r', 5}, -- position for reset
    {'u', 3},
    {'l', 2},
    {'d', 1},

    {'reset_start', 1},
    {'w', 180},
    {'r', 2}, -- go to grass
    {'d', 5},
    {'l', 33},
    {'x', 15}, -- learn return
    {'d', 3},
    {'press_a', 1},
    {'w', 180},
    {'l', 1}, -- menuing
    {'w', 30},
    {'l', 1},
    {'w', 30},
    {'l', 1},
    {'w', 30},
    {'l', 1},
    {'w', 30},
    {'l', 1},
    {'w', 30},
    {'press_a', 7}, -- use return TM
    {'press_b', 8}, -- exit start menu
    {'x', 15}, -- reopen menu
    {'w', 180},
    {'u', 1},
    {'press_a', 1}, -- open pokemon menu
    {'w', 180},
    {'press_a', 2},
    {'w', 180},
    {'r', 3}, -- swap return to first position
    {'press_a', 1},
    {'d', 2},
    {'press_a', 1},
    {'u', 2},
    {'press_a', 1},
    {'press_b', 8}, -- close menu

    {'save', '05-BeforeTraining'},

    {'u', 3},
    {'l', 2}, -- enter grass
    {'w', 30},
    -- start training.  Reach lvl 9, fastest in 12 battles
    {'wild_train_cycle', 11},
    {'save', '05b-BeforeLeveling'},
    {'w', 60},
    {'wild_train_cycle_2', 7}, -- all parallel universes not at lvl 9
    -- max discrepancy can be 24xp
    {'u', 2},
    {'press_a', 1},
    {'w', 240},
    {'d', 2},
    {'press_a', 2}, -- replace scratch with taunt
    {'w', 1080},
    {'press_b', 3},
    {'r', 1},
    {'grass_cycle', 1}, -- leave the grass
    {'r', 4}, -- realign against sign post
    {'w', 60},
    {'d', 2},
    {'r', 28},
    {'u', 3}, -- into pokecenter
    {'w', 540},
    {'u', 6},
    {'press_a', 9}, -- heal
    {'press_b', 10},
    {'d', 8},
    {'w', 600}, --outside pokecenter
    {'save', '06-AfterTraining'},

    {'r', 8},
    {'u', 17},
    {'l', 5},
    {'w', 360}, -- listen to dawn tutorial
    {'press_b', 8},
    {'w', 3420},
    {'press_b', 36}, -- get 5 pokeballs
    {'l', 1},
    {'grass_cycle', 1},
    {'l', 1},
    {'grass_cycle', 1},
    {'l', 1},
    {'grass_cycle', 1}, 
    {'l', 1},
    {'grass_cycle', 1},
    {'l', 1}, --out of grass
    {'l', 6},
    {'grass_cycle', 1},
    {'l', 1},
    {'grass_cycle', 1},
    {'l', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1}, -- out of grass
    {'u', 1},
    {'r', 2},
    {'w', 360}, -- fight Tristan
    {'press_b', 4},
    {'w', 900},
    {'use_move', 2}, -- starly down
    {'press_b', 10},
    {'save', '07-AfterTristan'},

    {'r', 5}, -- go back to pokecenter
    {'d', 7},
    {'w', 180},
    {'d', 4},
    {'r', 5},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1},
    {'grass_cycle', 1},
    {'r', 1}, -- out of grass
    {'r', 6},
    {'d', 9},
    {'l', 5},
    {'d', 9},
    {'l', 6},
    {'u', 3},
    {'w', 360},
    {'pokecenter_heal', 1},
    {'d', 8},
    {'w', 540}, -- out of pokecenter
    {'r', 8},
    {'u', 17},
    {'l', 5},
    {'l', 1},
    {'grass_cycle', 1},
    {'l', 1},
    {'grass_cycle', 1},
    {'l', 1},
    {'grass_cycle', 1}, 
    {'l', 1},
    {'grass_cycle', 1},
    {'l', 1},
    {'grass_cycle', 1},
    {'l', 1},
    {'grass_cycle', 1},
    {'l', 1}, --out of grass
    {'l', 6},
    {'grass_cycle', 1},
    {'l', 1},
    {'grass_cycle', 1},
    {'l', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1}, -- out of grass
    {'r', 11}, -- go to lass
    {'d', 2},
    {'r', 7},
    {'w', 540},
    {'press_b', 5},
    {'w', 900},
    {'use_move', 2}, -- defeat lass
    {'press_b', 24},
    {'w', 180},
    {'r', 2},
    {'d', 3},
    {'r', 6},
    {'u', 2}, -- to burmy boy
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1},
    {'grass_cycle', 1},
    {'u', 1}, -- out of grass
    {'u', 5}, -- to jubilife
    {'l', 3},
    {'w', 360},
    {'press_b', 4},
    {'w', 720},
    {'use_move', 2},
    {'press_b', 20},
    {'l', 3},
    {'grass_cycle', 1},
    {'l', 1},
    {'grass_cycle', 1},
    {'l', 1},
    {'grass_cycle', 1},
    {'l', 1},
    {'grass_cycle', 1},
    {'l', 1},
    {'grass_cycle', 1},
    {'l', 1}, -- out of grass
    {'l', 4},
    {'u', 11},
    {'press_b', 135}, -- finish talking to dawn // 25
    {'d', 2},
    {'r', 6},
    {'u', 2},
    {'w', 360},
    {'pokecenter_heal', 1}, -- heal
    {'d', 8},
    {'w', 360},
    {'save', '08-InJubilife'},

    {'l', 13},
    {'u', 2},
    {'w', 360},
    {'u', 8},
    {'l', 1},
    {'w', 30},
    {'press_a', 1},
    {'press_b', 41},
    {'d', 2},
    {'l', 6},
    {'u', 2},
    {'l', 1},
    {'w', 30},
    {'press_a', 1},
    {'press_b', 9},
    {'r', 3},
    {'d', 2},
    {'r', 4},
    {'d', 6},
    {'r', 6},
    {'u', 6},
    {'w', 60},
    {'press_a', 5}, -- fight students
    {'press_b', 6},
    {'w', 720},
    {'use_move', 2},
    {'press_b', 10},
    {'r', 3},
    {'u', 1},
    {'w', 30},
    {'press_a', 4},
    {'press_b', 14},
    {'w', 360},
    {'use_move', 3},
    {'press_b', 25},
    {'l', 3},
    {'u', 1},
    {'w', 30},
    {'press_a', 2},
    {'press_b', 20},
    {'d', 7},
    {'l', 6},
    {'d', 2},
    {'w', 360}, -- outside school
    {'r', 7},
    {'u', 2},
    {'w', 360},
    {'press_b', 18}, -- talk to watch guy
    {'r', 2},
    {'u', 5},
    {'r', 6},
    {'u', 4},
    {'r', 200},
    {'press_a', 10},
    {'press_b', 10}, -- get coupon 1
    {'u', 3},
    {'l', 10},
    {'u', 7},
    {'l', 7},
    {'u', 10},
    {'l', 4},
    {'press_a', 10},
    {'press_b', 10}, -- get coupon 2
    {'r', 4},
    {'d', 6},
    {'l', 22},
    {'u', 4},
    {'l', 200},
    {'w', 180},
    {'press_a', 8},
    {'press_b', 14}, -- get coupon 3
    {'d', 5},
    {'r', 29},
    {'d', 5},
    {'r', 4},
    {'d', 9},
    {'press_a', 2},
    {'press_b', 23}, -- get watch
    {'save', '09-WatchAcquired'},

    {'u', 8}, -- got to route 204
    {'l', 4},
    {'u', 10},
    {'r', 4},
    {'u', 28},
    {'l', 2},
    {'u', 2},
    {'l', 1},
    {'press_a', 5}, -- fight lass
    {'press_b', 17},
    {'w', 360},
    {'use_move', 2},
    {'press_b', 24},
    {'l', 1},
    {'w', 60},
    {'u', 2},
    {'l', 6},
    {'u', 2},
    {'l', 2},
    {'u', 1},
    {'press_a', 4}, -- fight magikarp boy
    {'press_b', 20},
    {'use_move', 2},
    {'press_b', 11},
    {'w', 180},
    
    {'r', 7},
    {'u', 2}, -- 28 save state
    {'custom1', 12},
    {'custom4', 1}, -- traverse grass
    {'l', 1}, 
    {'l', 1},
    {'d', 2},-- behind girl
    {'press_a', 3},
    {'press_b', 4}, -- should be level 12 in most PUs
    {'w', 720},
    {'use_move', 2},
    {'press_b', 18}, -- go through level up prompt
    {'w', 60}, -- 29 ss
    {'r', 1}, 
    {'custom2', 1},
    {'custom3', 12}, -- out of grass
    {'w', 30},
    {'r', 3}, -- to pokecenter
    {'d', 32},
    {'l', 4},
    {'d', 10},
    {'r', 4},
    {'d', 17},
    {'r', 7},
    {'u', 3},
    {'w', 360}, -- into pokecenter
    {'pokecenter_heal', 1}, 
    {'d', 8},
    {'w', 540}, -- back outside ss 30
    {'save', '10-BeforeTrainingAgain'},

    {'d', 2},
    {'l', 7},
    {'d', 29},
    {'l', 3},
    {'d', 4},
    {'w', 180},
    {'d', 9},
    {'r', 13},
    {'d', 5},
    {'w', 180},
    {'d', 21},
    {'l', 37}, -- ready to train
    {'custom5', 18}, -- halfway there kinda
    {'grass_cycle', 1}, -- in case we get supremely unlucky realigning
    {'reset_start', 1},
    {'x', 15}, -- swap ember to pos 1
    {'w', 60},
    {'d', 2},
    {'press_a', 1},
    {'w', 360},
    {'press_a', 2},
    {'w', 360},
    {'l', 2},
    {'w', 180},
    {'press_a', 1},
    {'w', 180},
    {'u', 2},
    {'press_a', 1},
    {'d', 2},
    {'press_a', 1},
    {'press_b', 13}, -- done
    {'custom6', 25}, -- finish our training, hit level 14 (mach punch)
    -- we should be on "wants to learn the move..."
    {'press_a', 1},
    {'w', 240},
    {'press_a', 1},
    {'w', 240},
    {'press_a', 1},
    {'w', 240},
    {'d', 1},
    {'w', 30},
    {'press_a', 1},
    {'w', 180},
    {'press_b', 15}, -- done learning mach punch
    {'save', '11-DoneLearningMachPunch'},

    {'custom2', 1},
    {'r', 1}, -- out of grass
    -- breakpoint // realign 
    {'u', 3},
    {'r', 4},
    {'w', 180},
    {'l', 2},
    {'d', 3},
    {'r', 1},
    {'w', 60},
    -- end breakpoint
    {'r', 35},
    {'u', 20},
    {'l', 5},
    {'custom4', 6},
    {'l', 1}, -- out of grass
    {'l', 5},
    {'custom4', 3},
    {'custom1', 8},
    {'u', 1},
    {'r', 12},
    {'d', 4},
    {'r', 12},
    {'u', 1},
    {'custom1', 10},
    {'u', 1}, -- out of grass

    {'u', 5},
    {'l', 4},
    {'custom4', 5},
    {'l', 1},
    {'l', 4},
    {'u', 29}, -- into jubilife
    {'r', 7},
    {'u', 2},
    {'w', 360},
    {'u', 6}, -- heal
    {'w', 180},
    {'press_a', 9},
    {'press_b', 10},
    {'d', 8},
    {'w', 360},
    {'l', 7},
    {'u', 19},
    {'r', 23},
    {'w', 360},
    {'press_b', 8},
    {'w', 800},
    {'press_a', 1},
    {'w', 180},
    {'d', 1},
    {'r', 1},
    {'w', 180},
    {'use_move', 5},
    {'press_b', 14}, -- after rival battle
    {'save', '12-AfterRival'},

    {'r', 4},
    {'u', 6},
    {'r', 3},
    {'u', 5},
    {'w', 360},
    {'press_b', 6},
    {'w', 800},
    {'use_move', 1},
    {'press_a', 1},
    {'w', 180},
    {'r', 2},
    {'d', 1},
    {'w', 180},
    {'press_a', 1},
    {'w', 1200}, -- beat zubat boy
    {'u', 5},
    {'r', 10},
    {'d', 4},
    {'w', 180},
    {'press_a', 1},
    {'press_b', 7},
    {'d', 4},
    {'w', 180},
    {'d', 4},
    {'r', 7},
    {'custom2', 2},
    {'r', 3},
    {'w', 360},
    {'press_b', 3},
    {'w', 900}, -- defeat lad
    {'press_a', 1},
    {'r', 1},
    {'d', 1},
    {'w', 180},
    {'press_a', 1},
    {'w', 900},
    {'press_b', 20}, -- lvl 15
    {'r', 3},
    {'custom2', 2},
    {'r', 7},
    {'u', 2},
    {'w', 360},
    {'press_b', 4},
    {'w', 1080},
    {'press_a', 1},
    {'w', 180},
    {'r', 1},
    {'d', 1},
    {'use_move', 2}, -- machop may survive first return
    {'press_b', 4},
    {'d', 3},
    {'r', 7},
    {'custom2', 3}, -- into sight line of wanderer
    {'save', '13-BeforeWanderer'},

    {'w', 26524}, -- guarentee her seeing us
    {'press_b', 5},
    {'w', 800},
    {'press_b', 1},
    {'w', 1080},
    {'press_a', 1},
    {'d', 1},
    {'r', 1},
    {'w', 30},
    {'use_move', 4},
    {'press_b', 3},
    {'w', 120}, -- defeated her
    {'save', '14-AfterWanderer'},

    {'custom2', 3},
    {'r', 1},
    {'u', 11},
    {'l', 6},
    {'l', 1},
    {'w', 360},
    {'press_b', 1},
    {'w', 1200},
    {'press_a', 1},
    {'r', 1},
    {'d', 1},
    {'use_move', 1},
    {'press_b', 1}, -- avoid learning fury swipes
    {'w', 180},
    {'press_b', 1},
    {'w', 900},
    {'press_b', 1},
    {'w', 300},
    {'press_a', 1},
    {'w', 300},
    {'press_b', 10},
    {'w', 180}, 
    {'r', 3}, -- go get repel
    {'u', 4},
    {'l', 1},
    {'custom4', 13},
    
    {'l', 7},
    {'u', 1},
    {'press_a', 1},
    {'press_b', 8},
    {'r', 7},
    {'custom2', 13},
    {'r', 1},

    {'r', 4}, -- to oreburgh gate
    {'d', 4},
    {'r', 2},
    {'w', 720}, -- wait to get inside
    {'custom2', 3},
    {'press_b', 20}, -- let hiker man talk to us
    {'custom2', 10}, -- go to first trainer
    {'r', 1},
    {'press_b', 12},
    {'w', 900},
    {'use_move', 2},
    {'w', 400},
    {'custom2', 7}, -- go to second trainer
    {'r', 1},
    {'w', 180},
    {'press_b', 5},
    {'w', 900},
    {'press_a', 1},
    {'r', 1},
    {'use_move', 1},
    {'w', 400},
    {'custom2', 4},
    {'r', 1},
    {'w', 720}, -- out of oreburgh gate
    {'r', 8},
    {'w', 180},
    {'press_b', 10},
    {'w', 720},
    {'press_b', 3},
    {'w', 180},
    {'d', 3},
    {'r', 7},
    {'d', 2},
    {'r', 14},
    {'u', 6},
    {'r', 6},
    {'u', 2},
    {'w', 360},
    {'pokecenter_heal', 1},
    {'d', 8},
    {'w', 540}, -- out of pokecenter
    {'save', '15-InOreburgh'},


    {'l', 4},
    {'d', 21},
    {'reset_start', 1},
    {'w', 180},
    {'r', 3},
    {'d', 20},
    {'w', 540},
    {'x', 15}, -- use repel
    {'u', 4},
    {'press_a', 1},
    {'w', 180},
    {'l', 1},
    {'w', 30},
    {'l', 1},
    {'w', 30},
    {'l', 1},
    {'w', 30},
    {'press_a', 2},
    {'press_b', 5}, -- done using repel // insidethemine
    {'save', '16-InsideTheMine'},

    -- BREAKPOINT
    {'d', 20},
{'w', 540},
{'d', 7},
{'r', 2},
{'d', 3},
{'l', 2},
{'d', 6},
{'r', 12},
{'d', 4},
{'w', 60},
{'press_a', 1},
{'w', 180},
{'press_b', 4},
{'w', 1800},
{'press_a', 1},
{'r', 1},
{'use_move', 2},
{'press_b', 4},
{'r', 3},
{'d', 8},
{'l', 2},
{'d', 3},
{'l', 7},
{'d', 2},
{'l', 4},
{'u', 1},
{'w', 60},
{'press_a', 1},
{'w', 180},
{'press_b', 26},
{'l', 11},
{'u', 1},
{'w', 60},
{'press_a', 1},
{'w', 180},
{'press_b', 3},
{'w', 1800},
{'press_a', 1},
{'r', 1},
{'use_move', 1},
{'press_b', 4},
{'press_a', 1},
{'d', 1},
{'use_move', 1},
{'press_b', 20},
{'l', 2},
{'u', 2},
{'l', 3},
{'w', 60},
{'press_a', 1},
{'w', 180},
{'press_b', 7},
{'r', 2},
{'d', 2},
{'r', 15},
{'w', 60},
{'press_b', 1},
{'x', 15},
{'w', 60},
{'press_a', 1},
{'w', 240},
{'press_a', 2},
{'w', 900},
{'save', '17-AfterTheMine'},

    -- END BREAKPOINT
    -- fight gym trainers to gain XP
    {'u', 31},
    {'l', 3},
    {'u', 9},
    {'r', 4},
    {'u', 2},
    {'w', 540},
    {'pokecenter_heal', 1},
    {'d', 8},
    {'w', 360},
    {'l', 5},
    {'d', 6},
    {'l', 18},
    {'u', 7},
    {'w', 360},
    
    {'u', 6},
    {'w', 180},
    {'press_b', 5},
    {'w', 900},
    {'press_a', 1},
    {'r', 1},
    {'use_move', 2},
    {'press_b', 2},
{'w', 180},
{'u', 8},
{'w', 360},
{'press_b', 5},
{'w', 900},
{'press_a', 1},
{'r', 1},
{'use_move', 4},
{'press_b', 3},
{'w', 240},
{'press_b', 2},
{'d', 15}, -- leave to go heal
{'w', 360},
{'d', 5},
{'r', 18},
{'u', 6},
{'r', 5},
{'u', 2},
{'w', 360},
{'pokecenter_heal', 1},
{'d', 8},
{'w', 360},
{'l', 5},
{'d', 6},
{'l', 20},
{'u', 2},
{'l', 11},
{'u', 13},
{'l', 14},
{'w', 540}, -- in cave for last bit of training to hit lvl 18
{'save', '18-BeforeTraining'},
{'u', 1},
{'custom1', 1},
{'u', 1},
{'w', 30},
{'spin_fast', 112}, -- enter fight 1
{'l', 2},
{'u', 2},
{'press_a', 1},
{'w', 60},
{'r', 1},
{'d', 1},
{'w', 60},
{'use_move', 1}, -- use return to KO zubats and psyducks
{'w', 60},
{'press_b', 5}, -- in case of level up now
{'press_a', 1},
{'w', 60},
{'x', 15}, -- menu prevents motion
{'w', 30},
{'u', 1},
{'w', 30},
{'x', 15},
{'w', 30},
{'use_move', 2}, -- two mach punches take out defense curling geodudes
{'press_b', 15},
{'l', 1}, 
{'w', 30},
{'spin_fast', 112}, -- enter fight 2
{'l', 2},
{'u', 2},
{'press_a', 1},
{'w', 60},
{'r', 1},
{'d', 1},
{'w', 60},
{'use_move', 1}, -- use return to KO zubats and psyducks
{'w', 60},
{'press_b', 15}, -- in case of level up now
{'press_a', 1},
{'w', 60},
{'x', 15}, -- menu prevents motion
{'w', 30},
{'u', 1},
{'w', 30},
{'x', 15},
{'w', 30},
{'use_move', 2}, -- two mach punches take out defense curling geodudes
{'press_b', 15},
{'l', 1}, 
{'w', 30},
{'spin_fast', 112}, -- enter fight 1
{'l', 2},
{'u', 2},
{'press_a', 1},
{'w', 60},
{'r', 1},
{'d', 1},
{'w', 60},
{'use_move', 1}, -- use return to KO zubats and psyducks
{'w', 60},
{'press_b', 5}, -- in case of level up now
{'press_a', 1},
{'w', 60},
{'x', 15}, -- menu prevents motion
{'w', 30},
{'u', 1},
{'w', 30},
{'x', 15},
{'w', 30},
{'use_move', 2}, -- two mach punches take out defense curling geodudes
{'press_b', 12},
{'custom1', 1},
{'custom3', 3},
{'custom2', 1},
{'r', 1}, -- out of the gate
{'w', 540},
{'save', '19-AfterTraining'},

{'r', 9},
{'d', 12},
{'r', 14},
{'d', 3},
{'r', 20},
{'u', 6},
{'r', 5},
{'u', 2},
{'w', 360},
{'pokecenter_heal', 1},
{'d', 8},
{'w', 360},
{'l', 5},
{'d', 6},
{'l', 18},
{'u', 7},
{'w', 360},
{'u', 20},
{'w', 60}, -- in front of roark
{'save', '20-BeforeRoark'},

{'press_a', 1},
{'w', 60},
{'press_b', 12},
{'w', 1260}, -- in battle
-- x attack lets us K0 cranidos in one hit
-- and 2HKO geodude and onix.  We know that after the first mach punch 
-- on geodude, roark will use a potion, so we use a potion as well to heal
-- this gives us enough health to survive an onix rock thow crit 
-- while we use mach punch twice on it
-- then cranidos goes down in one mach punch
-- ggs
{'w', 60},
{'u', 1},
{'d', 1},
{'press_a', 1},
{'w', 120},
{'r', 1},
{'d', 1},
{'w', 60},
{'press_a', 1},
{'w', 60},
{'press_a', 1},
{'w', 60},
{'press_a', 1},
{'w', 900},
{'u', 1},
{'press_a', 1},
{'w', 60},
{'r', 1},
{'use_move', 1},
{'w', 120}, -- use potion
{'d', 1},
{'press_a', 1},
{'w', 60},
{'u', 1},
{'l', 1},
{'w', 60},
{'press_a', 1},
{'w', 60},
{'press_a', 2},
{'w', 120},
{'press_a', 1},
{'w', 1200},
{'press_b', 10},
{'u', 3},
{'press_a', 1},
{'w', 60},
{'use_move', 1},
{'w', 300},
{'use_move', 3}, -- finish off onix and cranidos
{'w', 300},
{'use_move', 1},
{'press_a', 60},
{'press_b', 4},
{'w', 90},
{'d', 22},
{'w', 540},
{'r', 4},
{'d', 6},
{'r', 15},
{'u', 6},
{'r', 5},
{'u', 2},
{'w', 360},
{'pokecenter_heal', 1},
{'d', 8},
{'w', 720},
{'save', '21-AfterRoark'},
{'w', 30},
}



client.unpause()
client.unpause_av()

m.executeOrders(a)

client.pause_av()
client.pause()
