Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. // Collect 25 gold, and then tell Naria the total.
  2. // Use break to stop collecting when totalGold >= 25.
  3.  
  4. var totalGold = 0;
  5. while(true) {
  6. var coin = hero.findNearestItem();
  7. if(coin) {
  8. // Pick up the coin.
  9. hero.moveXY(coin.pos.x, coin.pos.y);
  10. // Add the coin's value to totalGold.
  11. // Get its value with: coin.value
  12. totalGold += coin.value;
  13. }
  14. if (totalGold >= 25) {
  15. // This breaks out of the loop to run code at the bottom.
  16. // The loop ends, code after the loop will run.
  17. break;
  18. }
  19. }
  20.  
  21. // Done collecting gold!
  22. hero.moveXY(58, 33);
  23. // Go to Naria and say how much gold you collected.
  24. hero.moveXY(63, 33);
  25. hero.say(totalGold);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement