![]() |
Switch and case?
What does this mean, and how do I use it. Its in the end of my staff boots script?
PHP Code:
|
It's just a different way to write an if-else when you're working with a single variable (a in this case).
That switch statement in your code translates to PHP Code:
|
Try using the forum's search function, may save you some time. Search for 'Spoils of the Switch'. It helped me a lot when I first read it.
|
For staff boots you will never need to know this.. instead use something more along the lines of:
PHP Code:
This greatly reduces your script length and makes it easier to modify. |
I'm not a particularly big fan of that transformation. I find the if statement much clearer.
|
Nice job bringing up another old thread! :p
Anywho, vex/vecy will return the direction in which the operation points. So, let's say your xVal is 32 and you want it to be 30. So vecx( 32-30) would give you -1 since you are to move left. Up would -1 of vecy and so forth, if you aren't moving it will return 0. By graal magic it works with direction values too, 0-3. So if your face south your vecx would be 0 and vecy would be 1. |
Hi Switch, who's Case?
gj @ bumping an old thread for no reason |
Is providing a better solution a bad or useless thing to do?
|
Quote:
|
Thanks for reference Tigairius, will come in hand I'm sure. :)
|
All times are GMT +2. The time now is 07:25 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.