 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Fri Oct 24, 2003 12:31 am Post subject: |
|
|
You can't do case statements. You'll have to put up with lots of if statements. But you can speed it up a little...
If you have, lets say 32 values to check for, instead of getting the script interpreter to execute 32 if statements, you could do something like this:
Code: |
#x is a value between 0 and 31
if (x >= 16) then (
if (x >= 24) then (
if (x >= 28) then (
#4 ifs
) else (
#4 ifs
)
) else (
if (x >= 20) then (
#4 ifs
) else (
#4 ifs
)
)
) else (
if (x >= 8) then (
if (x >= 12) then (
#4 ifs
) else (
#4 ifs
)
) else (
if (x >= 4) then (
#4 ifs
) else (
#4 ifs
)
)
)
|
So instead of 32 ifs, only 7 are processed. This gets more efficent the larger the range of x, but it needs a lot of thinking and is even more annoying to debug! Having an else on the if doesn't slow it down at all, Hspeak adds dummy elses to all ifs anyway.
Its also about two times as much typing
Custom menus a whole lot of if statements? I really hate lots of if statement or lines of repetic code, and always write dynamic procedures to cover it... even if its 10 times harder that way  _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Minnek Conjurer

Joined: 03 Jun 2003 Posts: 430 Location: Somewhere
|
Posted: Fri Oct 24, 2003 1:12 am Post subject: |
|
|
Oi, I've had experience there, Flamer. Did something like OHR Tactics from scratch. Never saw Moogle's code. I was speaking from experience, of how they make my head hurt, not just from the example, but in general. (That sentence probably made no sense, but... oh well. 4AM. Sue me.) I'm goin' to try my hand yet -again- at a custom battle system, this time with LeRoy backin' me up graphics-wise and idea-wise. When you get him in the mode, he's incredibly productive. Then he runs out of ideas and guess what happens Anyways, I'm goin' to look into making a switch/case thing. I think I have a way to do it, but it'll take me a long time to tweak around, and it may just end up a failure. Still a learnin' experience though.  _________________ * SDHawk has joined #Minnek
SDHawk> AAAAAAAAAAAAAUUUUUUUUUGH
* SDHawk has left #Minnek (Leaving) |
|
Back to top |
|
 |
Flamer The last guy on earth...

Joined: 04 Feb 2003 Posts: 725 Location: New Zealand (newly discovered)
|
Posted: Fri Oct 24, 2003 6:29 pm Post subject: |
|
|
yeah, experience is experience...
The Mad Cacti, are you mad... with all those if statements, it just takes more time to debug something that does the same job... sure it maaay look more interesting but it can also be more disorganised, it really depends on whether you are willing to think more just to make it... _________________ If we were a pack of dogs, IM would be a grand Hound, CN would be a very ficious little pitball, and Giz...well, it doesn't matter breed he is, he'd still be a bitch
(no offense to anyone that was mentioned) |
|
Back to top |
|
 |
MC as guest Guest
|
Posted: Sat Oct 25, 2003 9:03 pm Post subject: |
|
|
But its way faster too! Especially if you have 150 if statements..
However, your code is also about 1/3 longer, so it probably overflow custom. Well, it'll over flow it anyway.
Hard to debug? Yeah, it is, but that sturture is based on the idea that if your debugging if statements, you've got it very, very easy.
Still, I advice noone uses it. |
|
Back to top |
|
 |
Minnek Conjurer

Joined: 03 Jun 2003 Posts: 430 Location: Somewhere
|
Posted: Sun Oct 26, 2003 1:52 am Post subject: |
|
|
No one uses it? Bad statement. I'm sure some people'll use it. Just for an update, I've begun work on the switch/case thing, and if it works, I'll post it up here (probably in a new thread) so y'all can take a look (and if I manage to get it to be universal, download it.) That'll be all for tonight....this morning....... probably 4 AM again. Off to bed with me, now! (I sound like my mother. ) _________________ * SDHawk has joined #Minnek
SDHawk> AAAAAAAAAAAAAUUUUUUUUUGH
* SDHawk has left #Minnek (Leaving) |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|