• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

 SUGGESTION Game Maker 2

zendraw

Member
i suggest there be an option where you highlight some code and compare it with another code and it highlights the diffrences betwean the 2. so after that you can set the diffrences to variables and delete one of the codes. this is not only effective but it will help teach newbs about using variables efficiently.
 

kburkhart84

Firehammer Games
Hmmm...that's a pretty specific suggestion. I don't see it being a priority thing but it could be quite useful. The only thing we really have that comes close to doing something like it is the little yellow triangle saying we only used a variable/value once.

I've always said that Yoyo has a hard battle, because they want to appeal to the more professional crowd, while still appealing to the newer coder kind of crowd. This suggestion actually fits in perfect with that as it could be useful for both crowds, although if they really do refactor the auto-complete to where it shows only what is actually a viable value, the suggestion will be less useful since it is less likely that variables will be miss-spelt. It would still have a place though.
 

Rob

Member
Wouldn't you use a function for that?

Copy/paste and then change variable names can be a big source of typos and then what if you want to change something that affects all of those similar blocks of code?
 

zendraw

Member
i think some of you dont understand the purpose for this.
the purpose of this is for more easy optimisation of your code. you find samey code and you make it one and turn it into a function with arguments. there is aways samey code that can be turned into a function when in prototype stage or writing somthing new. if anyone tells me they never write samey codes, theyr either lying, or not writing any new code and not facing any new problems in code. they are basicly stale.

this perk is an aid in the optimisation process
 
As others have said

If you're using code that's exactly the same save for variable values or asset calls you're better off writing a script function that has those variables flagged as the arguments instead of copying and pasting the block of code all over the place
 

Tyg

Member
i think some of you dont understand the purpose for this.
the purpose of this is for more easy optimisation of your code. you find samey code and you make it one and turn it into a function with arguments. there is aways samey code that can be turned into a function when in prototype stage or writing somthing new. if anyone tells me they never write samey codes, theyr either lying, or not writing any new code and not facing any new problems in code. they are basicly stale.

this perk is an aid in the optimisation process
As to using the same code, thats what parameters are for
i can see your option of the editor pointing out code reuse
and if the editor kept pointing out, hey you used that over here
i would get very mad and slap my monitor
because i know i did, and it has another purpose
even if it had highlighted a section of code that was repeating
it may not warrant it to be a function and it would highlight a million little could be functions and now you have
to decide if you want to make a function and to remember all those function names
only to later realize, damn i forgot i need this variable in there, thats why i didnt make it a function
at what point do you determine it should be highlighted?
and when you highly optimize, you lose readabilty
and now its, which function did i put that code in
interesting thought, but i can't see it being practical, or anything i would use :)
 

zendraw

Member
you guys seriously have no idea whats been talked about and what its for.
1st thing that i notice from your comments: you think there is a problem and i am suggesting a solution to fix my problem. like in any other programming topic.

there is no problem and this is not a topic about how to do, or what to do. this is a topic about adding a highlight that will make optimising code more easy.
this is not a solution, this is an extra. the same way autofilling functions and variables is an extra. it is the same in the sense that it is an extra it is not the same in the way it aids the programmer.

autofill:
-you know a function.
-you type some part of the function
-autofill suggests the function
-you press enter and it autowrites the function for you

code compare:
-you have 2 or more pieces of code
-they have pretty much the same function
-you select one of the code
-you press a button to compare with the rest of the code in the code block
-it detects whre the code is very similar and highlights it, also highlighting the diffrences in the codes
-you then make a function with that code and the diffrences modifiable.

if its not clear now then i dont know.
 

zendraw

Member
You just double click the functions or numbers and any other instances of them are highlighted.
that doesnt work for this case atall. that functionality is for finding the same variable. and what im suggesting is finding a diffrence in a sselected code. by code i dont mean a variable, but lets say a for loop, ir a with, or somthing else that can be made into a function after the optimisation.

currently the only way to optimise a code into a function is by tracing by eye the diffrences. thus my suggestion.
 
Again, I get it. I was stating that there's a limited method for small tasks, which feels appropriate enough. I personally don't see the need for such a feature because unless you find yourself rewriting gigantic blocks of similar yet varying code all the time, it shouldn't take long to just throw it all into a script, switch the values into arguments, and place the function where necessary. This feature sounds more like overkill to me, being more useful for retroactively fixing bad planning rather than optimizing the engine.
 

zendraw

Member
if you see it in general sure, it seems like overkill. but every game first goes thru prototype stage where you write new code and test and so on, no matter how much you plan, most if not all outcomes in a game come from code that doesnt follow superficial ideas strictly.
i agree that in general use its not that big of a deal, but when prototyping and you dont want to slow yourself down, its rather helpful.
 
It feels useless to me because it doesn't come across as an optimizing tool, which is why it seems like it's to retroactively fix mistakes. If you're only changing a few things, such a feature is overkill. If you're changing a lot, then your functions are bloated. I mean, my game as a whole is definitely in the 7 digits in terms of lines of code, but I couldn't see myself accidentally rewriting so much code to the point where I'd need a tool to help me find similarities and differences for code I completely forgot about so that I could combine them into a function in order to create some form of optimization. As I stated, if the code blocks are small enough, the tool is mostly useless. If the blocks are large but the differences are minute, it's still mostly useless. If both are large enough to necessitate a tool to cut down on what's probably 5 minutes of work in an absolute worst-case scenario, then the single function is probably doing too much anyway. I don't see how this keeps momentum going when it's more of a lateral move.
 
You should throw your suggestions here, that's the place to send feature requests.
If you do it here on the forums, there's a good chance it will go under the radar.
 

Rob

Member
To suggest this, you're already aware of the problem (you said there's no problem but then if aint broke, don't fix it, so I'll assume you do have an identified problem)

The solution is already there - use a function.

I do find myself making repeat code or code that should really be a function but isnt, but then...guess what!? I make a function! (Or don't because I decided that was easier)

Either way, in aware of the not-a-problem, as you are, and the solution already exists.
 
Top