Pages: [1]
  Print  
Author Topic: Tutorial: Code Searching  (Read 939 times)
kinnik
Bean
*
Posts: 193


View Profile
« on: March 07, 2010, 07:36:36 PM »

Hey All!  I'm stoked on the progresses everyones been making in learning the code.  Especialy those just learning programming.

So I though I put something up to help people who are having a hard time finding where the code is located that we want to alter for our mods or the code that is causeing the bugs that we will be introducing. Smiley  A whole other tutorial on how to debug with game maker and in programming in general would be REALLY useful. To me as well as others I'm sure. I'll see if I can find one allready made... I found a tutorial on writing easy to maintain code:

http://code-spot.co.za/2008/09/06/60-ways-to-make-game-maker-projects-more-maintainable/

if anyone else can find good resourses for learning debuging please post.




ANYWAY.  TUTORIAL ON CODE SEARCHING


By being able to search for keywords in all the scripts and (umm..??) 'code chunks' imbedded in the objects, you will more easily be able to find the code you need to alter in order for your mods to work properly and without many bugs.

If you havn't found out yet (or if you happen to know better ways that I? please share!) searching for code in game maker has afew anoying hitches. I'll explain:


Usualy, to find a peice of code, you would use one of two methods.

1:  Under the 'scripts' drop down menu (on the top) there is a option to 'Search in Scripts...'.  If you use this, you can put a keyword, or few, and search all the *'scripts'* in the program and show you where that word apears in each case.

2:  Much limited in scope but not in usefulness is the 'find and replace' option. If you open any script or 'code chunk' (inside objects -> events -> actions) you can click on a tiny magnifine glass icon in the middleish of the script box and bring up this magnificent tool.  This lets you type any number of keywords and search though the currently open script. It highlights, it scrolls, it EVEN lets you replace! All for a low low scope of ONE SCRIPT!  too bad, eh?


The major drawback of both these tools... The scope.

(if you didn't know, scope is a geeky programmer term describing how 'far reaching' something is. If a variable can be referanced from anywhere in a program it's said to have a 'global' scope.)

The second option obviously lacks because it can only search in the one script.
The first option is ideal... but.   
It only searchs inside the 'scripts' and not the 'code chunks'!

This is a huge problem because a VAST magority of code, in spelunky, is held inside objects. Open any of the things on the left with a little 'o' in front ot the name and your likely to find all these things that read

"Execute a peice of code"

It's these that most of the work happens and it's here that the code is hardest to search though.

I've only figured out two ways of dealing with this... and if you know better or even just more, please post them!!

One way is to pick the object you think is most likely to have the code your looking for. open it. There is a button that says 'Show information'.  If you click this you get a text that writes every line of code embedded in the object.  You can then copy the code into notepad or somthing and search though it from there.

Again, you have to guess where it will be when you pick the object to search though...

The other way is much much better..  BUT. again, I know! Sad  This way will involve some very kind souls making it work for everyone else.. painstakingly.

If all the 'execute a peice of code' chunks were carefully copied into actual scripts and then each 'execute a peice' was deleted (or comented out).  Then replaced with 'execute script' actions.  We would all be able to search though all that code to find what we needed. So long as nothing gets broken in the conversion.


there it is.  It's not great.  I feel like there must be a way to search though everything without all that work.  Is there a way to copy all the code to a text file?  Someone must have some better advice?!
Logged
gummybears123
Mossy
*
Posts: 5781


Yummy Gummy!


View Profile
« Reply #1 on: March 07, 2010, 07:38:50 PM »

THANK YOU THANK YOU THANK YOU!
Logged

I made a rap.
It sounds dumb, like reading a map
I really should stop this thing before it goes too far
But I don't really car as long as I stay below the radar
Those big companies won't get me no
I'll get away before the fuzz show

-Most famous rapper of Mossmouth
Kirbylord
idoru
Shoot
*
Posts: 32


View Profile
« Reply #2 on: March 07, 2010, 08:26:13 PM »

Is there a way to copy all the code to a text file?

Yes, and it's extremely helpful because otherwise it would be near impossible to find things.

Go to Edit > Show Object Information. This gathers all the code for every object and displays it in a window (it may hang while it does this). There is no search function in this window, but the contents can be saved to a text file which you can then search.
Logged
kinnik
Bean
*
Posts: 193


View Profile
« Reply #3 on: March 07, 2010, 09:29:00 PM »

bloody fantastic!  thank you idoru!  it was near imposible.  Cry  thank you.
Logged
Sudonimus
Mossy
*
Posts: 2743


Stop staring.


View Profile
« Reply #4 on: March 09, 2010, 05:16:53 PM »

Wow, cool!
Great, kinnik!
Logged

How is there no such thing as non-existence?!
Pages: [1]
  Print  
 
Jump to: