codecombat / codecombat

Game for learning how to code.
http://codecombat.com
MIT License
7.97k stars 4.13k forks source link

Use simple loops in all levels' Lua sample code #2422

Closed nwinter closed 9 years ago

nwinter commented 9 years ago

We used to have to have code like this for Lua, since we had no simple loop keyword, and so we had to help the player avoid infinite loops:

while true do
    -- whatever the sample code is

    self:say("Remove this line once your loop is finite.")
end

Now we can rewrite that to:

loop
    -- whatever the sample code is
end

(The simple loop will automatically yield for one frame if no action is taken, so you can't get an infinite loop by not doing move, attack, say, or some other blocking action.)

We need to update the Lua sample code in pretty much all levels to use the new loop keyword instead, and to get rid of the placeholder say lines. The first few levels have no loops, and some of the last ones in the desert actually are teaching while true do loops, and some levels have just comments for sample code, but everything else will need updating.

To update the Lua sample code:

  1. Open the level editor
  2. Double-click the Hero Placeholder
  3. Click programming.Programmable on the left
  4. Open programmableMethods -> plan -> languages -> lua
  5. Update the Lua sample code.
  6. Submit a patch
  7. Post (or update) your comment here saying which ones you've done.

screenshot 2015-02-27 14 22 41

I've definitely missed some that actually just have comments for sample code, but this is the list I know about so far:

h3yduck commented 9 years ago

Submitted patch for: Haunted Kithmaze Riddling Kithmaze Hack and Dash Patrol Buster Endangered Burl

The Second Kithmaze - it has comment only Breakout - no default source code Dueling Grounds - it has comment only Kithgard Gates - no loop in default source code Kithgard Brawl - it has comment only

Khoffee commented 9 years ago

Submitted patch for:

wincheng commented 9 years ago

Submitted patch for:

tvdang commented 9 years ago

submitted patch for -back to back -Rich forager -drop the flag -Unfair support -Thunderhooves -Medical attention -sarven sentry -decoy drill -Shine getter

divyanshu013 commented 9 years ago

Submitted patch for:

  1. Village Guard
  2. The Agrippa Defense

Shield rush has comments only

laituan245 commented 9 years ago

Submitted patch for:

Mirage Maker - it has comment only Backwoods Treasure - it has comment only Minesweeper - it has comment only Dust - no loop in default source code

nwinter commented 9 years ago

Awesome, great work so far y'all! A bunch of the remaining levels might be because they're paid levels, and I guess maybe the level editor doesn't let you open those. But there are still some free ones left that either need doing or need a heads up that they don't need simple loops in them.

laituan245 commented 9 years ago

Submitted patch for:

Clash of Clones - it has comment only Backwoods Brawl - it has comment only The Great Yak Stampede - it has comment only

laituan245 commented 9 years ago

Tactical Timing - it has comment only Doom Glade - no default Lua source code Defend the Garrison - it has comment only Yakstraction - it has comment only Sarven Brawl - it has comment only Sarven Rescue - it has comment only Preferential Treatment - no loop in default source code

divyanshu013 commented 9 years ago

The Dunes -> Patch submitted Copper Meadows -> Patch submitted Swift Dagger -> Patch submitted

Harrowland -> Comments only Preferential Treatment -> Comments only Mirage Maker -> Comments only Sacred Statue -> Comments only Yakstraction -> Comments only Hoarding Gold -> No Lua source Keeping Time -> Comments only Cavern Survival -> No Lua source Multiplayer Treasure Grove -> Comments only Defend the Garrison -> Comments only Doom Glade -> No Lua source Tactical Timing -> Comments only Arcane Ally -> Comments only Munchkin Harvest -> Comments only Shield Rush -> Comments only

Lurker -> Uses a while loop Odd Sandstorm -> Uses a while loop Desert Combat -> Uses a while loop

Sarven Seige -> Unable to access

divyanshu013 commented 9 years ago

That should cover all @nwinter

nwinter commented 9 years ago

Wonderful! Good hustle, team. Hopefully we can soon apply the same simple loop logic for CoffeeScript and do the same thing for those levels.