Dissi is correct, but a greater thing to understand with this game is that every command you put into the server is *NOT* resolved immediately. Your code runs, generates some calls against the game server (along with all the other players), and then the game server resolves all of the different calls made by the different players. This means some interesting things:
1. move can return a 0 (success) but your creep may not move on the next tick (for various reasons, but most generally because another creep had a move call to move to the same location and the server chose that other one to "win")
2. any action to create things (spawning creeps, creating construction sites, creating flags, etc...) only happens on the next tick.
3. any action to destroy things (creep suicide, building destruction, flag destruction, construction site removal) only happens on the next tick.
4. related to this, creep actions that require resources (like repair, building, or transferring) require that the resource be contained in the creep (or structure, as this is also true of labs, towers, storages, etc..) before your code gets run (i.e. on the last tick). which means you can't say harvest energy and immediately use it to upgrade a controller on the same tick.