106 HW 08 Solution's Code

Created by: Lisa Michaud

world

Events

When the world starts
Do:
world.my first method


Let move OliveWaterblossom


When G is typed
Do:
OliveWaterblossom.attempt to get


When D is typed
Do:
OliveWaterblossom.attempt to drop


When is clicked on rock
Do:
world.celebrate


OliveWaterblossom

Methods

  OliveWaterblossom.get ( [Obj] what)
    No variables
       // A method to pick up an object
  // "what" is the object to be grabbed
  Do together
       // Fly down and reach for object
  OliveWaterblossom turn to face what
  OliveWaterblossom move down 1 meter
  OliveWaterblossom.Abs.Chest.SleeveR.UpperarmR.ForearmR turn backward 0.12 revolutions
  // Pick up object and fly back up
  what set vehicle to OliveWaterblossom
  OliveWaterblossom move up 1 meter


  OliveWaterblossom.attempt to get ( )
    No variables
       // A method to attempt to pick up one of the three flowers, if one is nearby
  If ( OliveWaterblossom is within 5 meters of Dancing Lilly )
       OliveWaterblossom.get what = Dancing Lilly
  Else
    If ( OliveWaterblossom is within 5 meters of Dancing Lilly2 )
       OliveWaterblossom.get what = Dancing Lilly2
  Else
    If ( OliveWaterblossom is within 5 meters of Dancing Lilly3 )
       OliveWaterblossom.get what = Dancing Lilly3
  Else
    // None of the flowers is nearby; can't get one
  OliveWaterblossom.shrug


  OliveWaterblossom.attempt to drop ( )
    No variables
       // A method to attempt to drop one of the flowers, if one is in her hands
  If ( ( Dancing Lilly . vehicle ) == OliveWaterblossom )
       OliveWaterblossom.drop what = Dancing Lilly
  Else
    If ( ( Dancing Lilly2 . vehicle ) == OliveWaterblossom )
       OliveWaterblossom.drop what = Dancing Lilly2
  Else
    If ( ( Dancing Lilly3 . vehicle ) == OliveWaterblossom )
       OliveWaterblossom.drop what = Dancing Lilly3
  Else
    // No flower is in her hands
  OliveWaterblossom.shrug


  OliveWaterblossom.drop ( [Obj] what)
    No variables
       // A method to drop an object in her hands; "what" is the object to be dropped
  // First, fly down and drop the item
  OliveWaterblossom move down 1 meter
  what set vehicle to world
  // Fly back up and return arm to side
  Do together
       OliveWaterblossom move up 1 meter
  OliveWaterblossom.Abs.Chest.SleeveR.UpperarmR.ForearmR turn forward 0.12 revolutions