Can different checks be converted into single check?
#5

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
That doesn't really change anything though, he's looking for code optimization.

@TahaMhr, I think that the issue here is the way you've designed this code, can you explain what you're doing exactly? So we can get the better picture.
The code is already as optimized as it can possibly be. There's no way to make it "faster" or more "optimized". If you crammed everything into a single line you'd be unable to differentiate the different error codes for each error. The solution was creating a function that returns a value to determine whether you are able to teleport or not, and that way you can edit that single function instead of editing all the commands if you want to alter the criteria needed to perform the command. Read the original post and the part I've highlighted in bold letters and you'll see that I literally provided the right solution for the problem they are addressing:

Quote:
Originally Posted by TahaMhr
Посмотреть сообщение
Hello, a question just popped in my mind to make my script a bit more efficient(I guess so xd), but have no idea how to do this. I know the topic name isn't self explanatory so here's what Im thinking:
for example, in my script I have many teleports, and for each of them I have to check the player condition one by one like this;

that means if I add something new, I would have to go add new piece of code in each of the teleport code lines. What I want is I make something like
Код:
TeleportRestrictions
containing all of the above checks and use it in the code(where ever these checks are required) so I'll just have to update this when a new thing is added, and all the teleports will be updated. Ofcourse, these kinds of checks ar not only used in teleports, they're almost everywhere. Im sure this can be done in one way or another, but I don't exactly know how?

Any help would be appreciated and thanks.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)