Closed ghost closed 11 years ago
I don't think you understand the concept of "indentation". By the way, don't close this pull request, instead, modify it. So we'll be able to keep the discussion.
Check this out, for a good pull request workflow: https://www.openshift.com/wiki/github-workflow-for-submitting-pull-requests
Check this out for a good "squash" example: «What this does is take smaller commits and combine them into larger ones» http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html http://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits
ok, how can I indent it properly.
Also, the link I sent explain how and where you should put spaces in front of your lines of code. http://site.chronic667.com/gm/tutorials/Tutorial%20-%20Indenting%20your%20code.html
So, basically, every lines inside a "block" should be indented (mean: you add 2 spaces in front of them). example:
instead of
if () {
CODE;
CODE;
}
you will have
if () {
..CODE;
..CODE;
}
(where the dots are in fact "spaces")
so, should I use the Tab button or the Space Bar
In my text editor, the tab button is adding two space.
ok, I use Notepad++
you can (should) change the setting. So the tab button will add spaces instead. http://stackoverflow.com/questions/455037/notepad-tabs-to-spaces
ok, I checked the settings and there was no option to make the tab button add spaces instead.
ok, thanks
Does it look good enough to merge.
Not at all. Indent your code.
ok, thanks for the quick response.
Get Sublime Text 2 http://www.sublimetext.com and add Package Control and the JsFormat package. Create a new file, paste your code in, change syntax to Javascript, select all (CTRL+A) and press CTRL+ALT+F to Beautify your code automatically! Default is two spaces for TAB, and looks good. Hopefully 4 spaces is not necessary because once you start nesting a bunch of code it's going to get out of control! Here's what it looks like with 2 spaces. http://i.imgur.com/DoOpgVQ.png
Also something that sticks out to me is your
javascript bot.roomInfo(true, function(data) {
should be
javascript bot.roomInfo(false, function(data) {
to save time on the call and amount of data returned. "false" doesn't include all of the song log info. So if you don't need that, it's a good idea not to ask for it.
ok
@Turntablelover, your indenting is still off. http://i.imgur.com/Ma8T6en.png
Does the coding look right with the correct indentions
lot better, but still wrong !
you shouldn't have these
});
});
on the same line... if it was good.
Pushing out a commit right now, that will fix it. It should appear in here in a bit for you to look at.
I said "fix the indentation", not "break your code"
Now, if you try to run your code, you'll end up with a lot of errors saying that you are missing some }
.
I don't know, maybe you should test the code you are committing (?) And learn how to properly indent your code. (http://www.cs.arizona.edu/~mccann/indent_c.html) (following the style of the project)
@Turntablelover this is what ur code should look like... although i won't test it for u :p
var Bot = require('ttapi');
var AUTH = 'xxxxxxxxxxxxxxxxxxxxxxxx';
var USERID = 'xxxxxxxxxxxxxxxxxxxxxxxx';
var ROOMID = 'xxxxxxxxxxxxxxxxxxxxxxxx';
var imDjing = false;
var getDownAfterSong = false;
var bot = new Bot(AUTH, USERID, ROOMID);
bot.on('roomChanged', function (data) {
bot.roomInfo(false, function (data) {
// Get the DJ count upon entering the room
var djcount = data.room.metadata.djcount;
// If DJ count less than or equal to 1, get on decks
if (djcount <= 1) {
bot.addDj();
}
});
});
bot.on('newsong', function (data) {
// Check if bot is the new DJ when new song begins
var djid = data.room.metadata.current_song.djid;
if (djid == USERID) {
imDjing = true;
}
});
bot.on('endsong', function (data) {
// Update 'imDjing' when Bot's song ends
var djid = data.room.metadata.current_song.djid;
if (djid == USERID) {
imDjing = false;
}
// If triggered to get down during Bot's song, step down now
if (getDownAfterSong == true) {
bot.remDj(USERID);
getDownAfterSong = false;
}
});
bot.on('add_dj', function (data) {
// Check the DJ count when a new DJ steps up
bot.roomInfo(false, function (data) {
var djcount = data.room.metadata.djcount;
// If there's enough DJ's now, bot steps down.
if (djcount >= 3) {
// If bot's song is currently playing, let's have the bot step down when it ends
if (imDjing) {
getDownAfterSong = true;
} else {
bot.remDj(USERID);
}
}
});
});
bot.on('rem_dj', function (data) {
// Checks DJ count when a DJ steps down
bot.roomInfo(false, function (data) {
var djcount = data.room.metadata.djcount;
// If there aren't enough DJ's, bot steps up
if (djcount <= 1) {
bot.addDj();
}
});
});
this is very stressful, but is the code for all 3 examples wrong or not.
just do it the lazy way... copy paste ur code into here and specify parameters :p
but yeah as far as indentations go, one thing to note is to never use tabs since they show up differently in every editor. and if you are going to use tabs find the area in the editor and set it to represent tabs as spaces... the standard is 2 - 4. i personally prefer braces on their own line but i know most ppl dont. but theres more than one way to legitimately indent your code.
this is braces on own line... u can do it this way too
bot.on('rem_dj', function (data)
{
// Checks DJ count when a DJ steps down
bot.roomInfo(false, function (data)
{
var djcount = data.room.metadata.djcount;
// If there aren't enough DJ's, bot steps up
if (djcount <= 1)
{
bot.addDj();
}
});
});
That looks great ! You only forgot what I said before, that you should use ("2" / "two" / "deux") spaces. Actually you use 4 spaces.
Fix that, squash your 14 commits into one with git rebase -i master
(http://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
And I'll merge it right away !
squashing the 14 commits into one is pretty confusing.
I used git rebase -i master and it said it's not a git repository
I really admire the determination of this thread... it's like an everlasting gobstopper. Not even Willy Wonka himself is going to tell you what to do with it, you just have to figure it out for yourself.
I have to agree w/@DubbyTT. Some flavors are good and some are hilariously awful.
I am doing this the simplest way possible, so I went ahead and made a new pull request for the final code.
Added Auto DJ Bot, Autosnag, and Manual DJ Bot. Fixed coding to 2 spaces indented with the Tab button.
I used the link you gave me and it said to use the tab button. I hope this is correct.
:)