My first library. in Off Topic
|
|
Came up with this very convenient proc will coding Faymoor and thought other people might get some use from it.
Wasn't to sure if there was anything out there like this and could be asked to look lol. So here it is, http://www.byond.com/developer/GreatFisher/Path_setLibrary, the Path_set library. It lets you set a mobs movement path through a list var containing the letters N,S,W and E.(it can contain other letters but if they are there they will be filtered out)
That's all I can think of telling you that's not in the read me so please, check it out and give some feedback. Note I will only update if I need to or if there is a high demand for it.
P.s. I know this isn't my best written post but I was rushing and wasn't paying a lot of attention.
|
When writing code, always consider the DRY principle: Don't Repeat Yourself. Looking at your Path_set() process, 90% of the code is repeated for each of the directions. The only thing that varies is the direction passed into step().
There is also no reason to be using goto in this code, a while() or even a for() loop would be trivial to implement and much cleaner.
Instead of storing a character (N, S, E, W), you could store the actual direction in the list (NORTH, SOUTH, EAST, WEST, NORTHEAST, NORTHWEST, ect). Then you could just pass that value directly to step() and not need a chain of if() statements.
It's unnecessary to strip out invalid values from the sequence list when only valid values have any actions (and if you switch to using the direction constants instead of strings, step() will handle any validation for you)
If you're passing the target mob as an argument, it doesn't make sense to also have the process defined under /mob (in other words, both M and src are being set, when you only need M). I would suggest just making it a global process like the built-in step().
Your process should work for any atom/movable, so it's misleading to define the argument as a mob.
This is a personal preference of mine, but if you're going to implement a feature as game-specific as randomized delays for movement between tiles, I would make an argument to control (or disable) it. Something like delayRange.
If you're interested in implementing any of these suggestions and would like a more thorough explanation, just let me know. Also, don't let my criticisms devalue your achievement. Releasing a library is a big step. My only goal is to help you make it even better.