Guest User

Untitled

a guest
Jan 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. for(var x = SCREEN.corner.x ; x < (SCREEN.corner.x+20) ; x++) {
  2. for(var y = SCREEN.corner.y ; y < (SCREEN.corner.y+12) ; y++) {
  3. db.get('map:'+x+':'+y, function (err, data) {
  4. if (data != null) {
  5. var params = data.split(':'); // split data for parsing
  6. switch (params[0]) { // determine what's here and send to client
  7. case 'player': {
  8. db.get('player:'+params[1]+':name', function(err, name) {
  9. client.send('DRAW PLAYER '+name+' AT '+x+' '+y);
  10. });
  11. }
  12. }
  13. }
  14. });
  15. }
  16. }
  17.  
  18. //The x and y in client.send are the very last values that the for loop can have. They are not actually passed in per for loop... It seems like the for loop iterates all the way to the end before the callback actually grabs the values of the counters x and y.
Add Comment
Please, Sign In to add comment