Forum

> > Off Topic > [solved] Quick Efficiency Script
Forums overviewOff Topic overviewLog in to reply

English [solved] Quick Efficiency Script

No replies
To the start Previous 1 Next To the start

old [solved] Quick Efficiency Script

Apache uwu
User Off Offline

Quote
Here is a template script:

1
2
3
4
5
6
7
8
9
10
11
12
if (condition==true) {
	if (condition2==true) {
		condition3=action(condition,condition2);
		if (condition3==true) {
			action2(condition3);
		} else {
			action3();
		}
	} else {
		action3();
	}
}

In this example, action3 is different from action2, and in reality action2 is actually very long. I would not want to copy and paste action2 twice--nor do I want to make a separate method for it.

Is it possible via syntax to compress this into a more efficient script?

Edit: Hahaha I think I have the solution:

1
2
3
4
5
6
7
8
if ((condition==true) && (condition2==true)) {
	condition3=action(condition,condition2);
	if (condition3==true) {
		action2(condition3);
	}
} else {
	action3();
}

The reason I couldn't see it was because actions were extremely long, after typing it in a template form it was very simple to see how that could have been simpler.
To the start Previous 1 Next To the start
Log in to replyOff Topic overviewForums overview