Jump to content


Photo

GM LOC Counter


  • This topic is locked This topic is locked
31 replies to this topic

#1 Aragon1029

Aragon1029

    GMC Member

  • New Member
  • 940 posts

Posted 24 December 2010 - 07:43 PM

GameMaker Lines Of Code Counter
Program in use


What is it?
This is a simple Lines of code counter program. Since I couldn't ever find another program for GM that did this I decided to make it myself. It's more a plugin type application than anything, so hopefully YYG eventually writes plugins into the IDE. Anyway, LOC comes in various flavors, I was lazy and only counted PLOC (Physical), CLOC (Comment) and BLOC (Blank). This tool counts all the LOC in the file, including code in scripts, objects, room creation code and instance creation code.

So how does this work?
Take the following snippet of code:
/*
 *  doSomething();
 *  Does something
 */

var i, j, myArray;

// Populate a completely useless array
j = irandom(512);
for(i = 0; i < j; i += 1)
    myArray[i] = irandom(255);

// Search through the array again to find a value larger than 128
for(i = 0; i < j; i += 1) {
    if (myArray[i] > 128)
        show_message("Item " + string(i) + " is larger than 128!");
}

// Return the array size
return j;
In this instance there is:
PLOC: 21
CLOC: 7
BLOC: 4

Meaning the lines of code that actually do something is 21 - 7 - 4 = 10.

Why is it useful?
Knowing the LOC of your game is very useful in various situations. Knowing the LOC is a good way to tell how large (not complex) a program is, which can be used to compare various aspects of your game (Amount of C++ vs. GML used in a game for instance). On top of that it's just an interesting piece of information to know about your game.

Where do I get it?
http://www.x2048.com/gm/gmloc.exe


C&C and bug/crash reports would be appreciated, and I already checked with FredFredrickson about where to create this thread.

Edited by Aragon1029, 24 December 2010 - 09:35 PM.

  • 7


Rave Breakout! A new game for iOS devices!
Ever wondered how many lines of code your game has?
Guys, I have a great idea, let's protect the public through censorship.


#2 LoopStan

LoopStan

    North-See Developer

  • GMC Member
  • 1398 posts

Posted 24 December 2010 - 07:46 PM

Thank you sooo much! I've been waiting for one of these. I've really wanted to count up all the lines in my game maker projects to see how much i've done, but never have been able too because gm doesn't have a tool like this. It rocks, thanks!
  • 0

Posted Image


#3 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 24 December 2010 - 07:53 PM

It works.

I can't close it with the nice X button, but it doesn't appear to do this for everyone. You can click on the icon (top left of window) and click close to close it, though.
  • 1

#4 KnnO

KnnO

    GMC Member

  • GMC Member
  • 65 posts
  • Version:Unknown

Posted 24 December 2010 - 07:55 PM

Hi,

thank you for this program, just
what i m looking for.

knno
  • 0
asdsadsdaas gfhgfhfghfghgff jkljkljkljkl czxczxcxzcxc yuyuyuyiuyiyui weqwewqreqweqw

#5 Aragon1029

Aragon1029

    GMC Member

  • New Member
  • 940 posts

Posted 24 December 2010 - 07:59 PM

It works.

I can't close it with the nice X button, but it doesn't appear to do this for everyone. You can click on the icon (top left of window) and click close to close it, though.

Strange, I'll look into it, I also noticed that something along the lines of "/* foobar */" causes the PLOC to jump 2000 lines. I think it's trolling me.
  • 0


Rave Breakout! A new game for iOS devices!
Ever wondered how many lines of code your game has?
Guys, I have a great idea, let's protect the public through censorship.


#6 Erik Leppen

Erik Leppen

    GMC Member

  • GMC Member
  • 2751 posts
  • Version:GM:Studio

Posted 24 December 2010 - 08:06 PM

Nice :D

Shoot 3: p - c - b = 1823 :D

I can't close it either, by the way.

Also, question: does it count Actions? If not, is this a possible future feature?
  • 0

promo_briquidmini_500x150.png


#7 Venomous

Venomous

    GMC Member

  • GMC Member
  • 1626 posts
  • Version:GM:Studio

Posted 24 December 2010 - 08:07 PM

It's great, thanks. This will be staying on my computer.
The X button to close doesn't work though.
  • 0

#8 Aragon1029

Aragon1029

    GMC Member

  • New Member
  • 940 posts

Posted 24 December 2010 - 08:13 PM

Fixed the can't close and "/* foobar */" bug.
I'm not going to add D&D support simply because it's kinda iffy on how to count D&D.

Edited by Aragon1029, 24 December 2010 - 09:03 PM.

  • 0


Rave Breakout! A new game for iOS devices!
Ever wondered how many lines of code your game has?
Guys, I have a great idea, let's protect the public through censorship.


#9 sigonasr

sigonasr

    Hard Code that Works

  • GMC Member
  • 412 posts
  • Version:GM8

Posted 24 December 2010 - 09:21 PM

Haha, I can finally put an accurate LOC count in my signature for games on working on. This will become the new signature trend, just wait. :rolleyes:

Thanks for the program. Mind if I ask what it was written in? ()
  • 0
Need a quick and simple upload place to show your friends that one gmk?
You can upload it at My Uploader.

#10 PwnageMage

PwnageMage

    Nobody Pwns This Mage

  • New Member
  • 1864 posts

Posted 24 December 2010 - 09:34 PM

Nice program. Great work!
  • 0

Prepare yourself for the Phlud


#11 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 25 December 2010 - 01:25 AM

Mind if I ask what it was written in?

C++
  • 1

#12 Revel

Revel

    ɹǝqɯǝɯ ɔɯƃ

  • GMC Member
  • 4935 posts
  • Version:GM8

Posted 25 December 2010 - 07:21 AM

Did you release Debug, or did you get GMKFile working in Release mode Posted Image
  • 0

#13 weckar

weckar

    Helping Hand

  • GMC Member
  • 2616 posts
  • Version:Unknown

Posted 25 December 2010 - 10:35 AM

Hmmmm... so how does it count lines part active / part comment?
  • 0
Just had my 10-year forum anniversary. Feeling - Even - Older.
Awards & Recognitions:
Spoiler

[I have a nasty habit of writing "it is" simply as "it". Please forgive me, I try to avoid it.]

#14 Aragon1029

Aragon1029

    GMC Member

  • New Member
  • 940 posts

Posted 25 December 2010 - 02:38 PM

Did you release Debug, or did you get GMKFile working in Release mode Posted Image

Debug D:. Hopefully I'll finish my own GMK parsing library soon enough.

Hmmmm... so how does it count lines part active / part comment?

Like this. Called once per script.
It's a little preemptive but it gets the job done.
  • 0


Rave Breakout! A new game for iOS devices!
Ever wondered how many lines of code your game has?
Guys, I have a great idea, let's protect the public through censorship.


#15 JAk HAk

JAk HAk

    sepius fidelis

  • New Member
  • 713 posts
  • Version:GM:HTML5

Posted 01 January 2011 - 11:11 AM

Works just fine for me. Thank you very much.
  • 0

Posted Image


#16 weckar

weckar

    Helping Hand

  • GMC Member
  • 2616 posts
  • Version:Unknown

Posted 01 January 2011 - 11:22 AM

I just broke the 3000 LOC mark xD
  • 0
Just had my 10-year forum anniversary. Feeling - Even - Older.
Awards & Recognitions:
Spoiler

[I have a nasty habit of writing "it is" simply as "it". Please forgive me, I try to avoid it.]

#17 Aragon1029

Aragon1029

    GMC Member

  • New Member
  • 940 posts

Posted 01 January 2011 - 07:23 PM

Worked on several projects, but I went to try it on an older, more sizable (and messy) project and it crashed.

Debug error!

R6010
- abort() has been called


But yeah, very cool!

Actually, I got this when I tried counting the LOC on a 6MB large game, at the time I didn't know what caused it, but I think I know now...
I'll recompile using my new GMK library instead of the old one, see if that helps any.
  • 0


Rave Breakout! A new game for iOS devices!
Ever wondered how many lines of code your game has?
Guys, I have a great idea, let's protect the public through censorship.


#18 Andy

Andy

    GMC Veteran

  • GMC Member
  • 1988 posts
  • Version:GM:Studio

Posted 01 January 2011 - 07:23 PM

My game must be good because it breaks your program. :medieval:
  • 0

Please visit my website, Andygames.com today!

 


#19 Aragon1029

Aragon1029

    GMC Member

  • New Member
  • 940 posts

Posted 01 January 2011 - 09:36 PM

Yeah, I don't know what's wrong.
But I updated it anyway, uses my GmkParse library so it's now built in release mode, making it faster and smaller.
I'll look into the crash, the stack trace goes through some random addresses, leaving the CRT and _main calls intact, so I'm assuming that the stack is getting corrupted, as for why, I have no clue.
  • 0


Rave Breakout! A new game for iOS devices!
Ever wondered how many lines of code your game has?
Guys, I have a great idea, let's protect the public through censorship.


#20 Tumetsu

Tumetsu

    GMC Member

  • New Member
  • 433 posts

Posted 01 January 2011 - 09:53 PM

Yeah, it worked for some projects for me but didn't do anything on others. It didn't actually crash when I tried it on one of my older projects. It first sit on like frozen (supposedly processing) and afterwards it woke up but didn't show results (button were pressable etc. not crashed).
  • 0
Posted Image

#21 Chrscool8

Chrscool8

    Call me Chris.

  • GMC Member
  • 2399 posts
  • Version:GM:Studio

Posted 02 January 2011 - 01:00 AM

Love it. This is what I was looking for a while back. :P
http://gmc.yoyogames...1

NOTE: Something I noticed is that all of my games that had the FMOD script set froze your program. I delete them and it works fine again. Strange.


Just for fun:

My super old mario game: http://gmc.yoyogames...1
2257-77-241 = 1939 Lines

Dungeon (Prequel to Suh Burb):
5414-898-565 = 3951 Lines

Suh Burb (minus the fmod scripts): http://gmc.yoyogames...1
10777-2534-1155 = 7088 Lines (Holy crap)

And I ran some others. One thing I'd suggest, make a loading action/screen/something to hold the program, rather than going into a non-responding state while working. Awesome, though. Thanks!
  • 0

Click the banner to check out my game, Suh Burb!

XPTintI.gif

Add me on Steam! Let's talk about making games!


#22 Camman

Camman

    UnReal Software CEO

  • GMC Member
  • 639 posts
  • Version:GM:Studio

Posted 07 January 2011 - 04:49 AM

I was trying to get this to work on my machine (Windows 7 - 64 bit), but it kept throwing the error "The program can't start because MSVCR100.dll is missing from your computer. Try reinstalling the program to fix this problem." at me.

The solution is to download the Microsoft Visual C++ 2010 Redistributable Package from here:
http://www.microsoft...&displaylang=en

Just thought that would help anyone else if they get the same problem ;).

-Cameron
  • 0

#23 BlueMoonProductions

BlueMoonProductions

    BlueMoonProductions

  • GMC Member
  • 241 posts
  • Version:GM:Studio

Posted 07 January 2011 - 10:11 AM

I'm afraid your program actually crashed when trying to read the GMK of my RPG.. It probably has over a 100 scripts now and thousands of lines of code..

I tested it on a small GMK, and that worked.. But it seems my RPG is to big :P
  • 0

#24 Skarik

Skarik

    GMC member

  • GMC Member
  • 1068 posts
  • Version:GM:Studio

Posted 07 January 2011 - 04:18 PM

Doesn't start. Asks me for a DLL that suspiciously looks like one from the MSVC++ Runtime. Even if you're compiling in debug mode, can you set the compile settings to not require the MSVCR installed? I mean, I have it installed, but seemingly not the right one.

Edit: Saw Camman's post, and I am not going to download another MSVC++ Runtime. It's a single option in the compile settings to change it to not require the redist.

Although if this doesn't count actions, specifically code block actions, then this is useless. (And don't give me sh1t for using them either. I keep my games optimized to the point it shouldn't matter.)

Edited by Skarik, 07 January 2011 - 04:20 PM.

  • 0

#25 Pie Person!

Pie Person!

    GM 6+ Lover

  • GMC Member
  • 1973 posts

Posted 07 January 2011 - 04:26 PM

I used to just count how many scripts I had in a system, then look at the two biggest scripts and the two smallest. Using an average of 25 lines per script, and a main handling script worth a couple hundred, I found 3000 lines of code in my inventory system! However my inventory system is like Diablo's, times 10 (had an INSANE amount of features built-in). So, seeking for a much stronger language which doesn't limit you by arrays, I moved onto C++; however GML is still quite handy for hobbyists.

Thanks for this tool.

Cheers

Edited by Pie Person!, 07 January 2011 - 04:27 PM.

  • 0
Cool.

#26 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 07 January 2011 - 07:46 PM

Doesn't start. Asks me for a DLL that suspiciously looks like one from the MSVC++ Runtime. Even if you're compiling in debug mode, can you set the compile settings to not require the MSVCR installed? I mean, I have it installed, but seemingly not the right one.

Edit: Saw Camman's post, and I am not going to download another MSVC++ Runtime. It's a single option in the compile settings to change it to not require the redist.

Although if this doesn't count actions, specifically code block actions, then this is useless. (And don't give me sh1t for using them either. I keep my games optimized to the point it shouldn't matter.)

Aragon1029 and Revel were banned so...yeah.

Well, all it counts is code actions. I don't know if it crashes if you have other actions or even multiple code actions.

How would you count non-code actions? One LOC each? Besides, I don't know if this is still being developed...
  • 1

#27 Revel

Revel

    ɹǝqɯǝɯ ɔɯƃ

  • GMC Member
  • 4935 posts
  • Version:GM8

Posted 07 January 2011 - 07:50 PM

Aragon1029 and Revel were banned so...yeah.

Posted Image
  • 0

#28 PwnageMage

PwnageMage

    Nobody Pwns This Mage

  • New Member
  • 1864 posts

Posted 07 January 2011 - 08:07 PM

Aragon1029 and Revel were banned so...yeah.

Posted Image

Posted Image
  • 0

Prepare yourself for the Phlud


#29 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 07 January 2011 - 08:38 PM

snip

I LOVE YOU (no homo)

Around 5000 lines of code in Melody Maker v2 so far :3
  • 0

#30 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 07 January 2011 - 08:46 PM

Aragon1029 and Revel were banned so...yeah.

Posted Image

Already?
  • 1

#31 Camman

Camman

    UnReal Software CEO

  • GMC Member
  • 639 posts
  • Version:GM:Studio

Posted 08 January 2011 - 08:00 AM

I'm afraid your program actually crashed when trying to read the GMK of my RPG.. It probably has over a 100 scripts now and thousands of lines of code..

I tested it on a small GMK, and that worked.. But it seems my RPG is to big :P


Yeah, I had the same problem. The current game I'm working on is way to big. Crashes straight away. =/
  • 0

#32 Davve

Davve

    GMC Member

  • GMC Member
  • 4091 posts
  • Version:GM:Studio

Posted 26 September 2011 - 06:49 PM

The link's broken. Please fix.
  • 0