Find all occurences of a string in a text?

Get help using Construct 2

Post » Tue Feb 10, 2015 9:00 pm

Kan wrote:@codah This is a great way of doing it, thanks. :) And it seems pretty fast even when going through longer texts.

I've simplified it a bit and I think that's what I'm gonna be using then. Thank you.


Aẃesome. I'm always interested in how things can be simplified..
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Tue Feb 10, 2015 10:28 pm

Well, let me remember... I basically removed a few "every ticks" conditions here and there (and left the events with no condition instead since they'll be processed one after the other in the function call anyway) and removed local variables (see file).

Also I finally meet someone else who uses the latest stable release, instead of the latest beta. :D
You do not have the required permissions to view the files attached to this post.
B
11
S
3
G
3
Posts: 206
Reputation: 2,379

Post » Tue Feb 10, 2015 10:37 pm

Kan wrote:Well, let me remember... I basically removed a few "every ticks" conditions here and there (and left the events with no condition instead since they'll be processed one after the other in the function call anyway) and removed local variables (see file).

Also I finally meet someone else who uses the latest stable release, instead of the latest beta. :D


heh.. I just downloaded the beta! Because the stable freezes on me anyway..

About the 'everty tick', it's a choice thing for me. I prefer not to have any 'empty' lines because then I know C2 hasn't deleted any code due to me incorrectly removing an object that was in actually use.. So if I see emptiness, I know something is astray. I realise it's not necessary for functioning :)

As for local variables... it is better for debugging and easier to read IMO, especially a few weeks/months later when you revisit the code... As they say, "eschew obfuscation!" (and early optimisation).
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Wed Feb 11, 2015 1:10 am

That's cool. :)

Personally, since I've learned that sub-events are executed one after the other, I like to separate events - especially functions - into several "steps" to make it more clear. As or variables, I like to give them the shorter yet clearer name possible, and have as little as possible to make it less confusing.

In the end we both want our code to be simpler for when we (or somebody else) will have to look at it later, we just have different ways of doing it. ;)
B
11
S
3
G
3
Posts: 206
Reputation: 2,379

Previous

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 20 guests