if(src.bladelvl == 5)
bladetalent(src)
return
What is the best way to go about programming this to say "Every 5 skillpoints, run bladetalent()?
Will I need to manually do every level?
ID:164940
Mar 24 2007, 7:54 am
|
|
if(src.bladelvl == 5) What is the best way to go about programming this to say "Every 5 skillpoints, run bladetalent()? Will I need to manually do every level? |
In response to Lummox JR
|
|
Oh, wonderful! I guess I never looked at what "%" did. Thanks for your help.
|
In response to Lummox JR
|
|
which would be more efficient...
if(bladelvl % 5 == 0) or... if(!(bladelvl % 5)) I know this has nothing to do with the topic of the post, but I use the latter example and was wondering if it really made a difference or not. |
In response to KirbyAllStar
|
|
The latter approach (! operator) is useless, since the result of the % operator (or most mathematical operators for that matter) will never be an empty text string ("") or null, it will only be 0.
|
In response to Kaioken
|
|
Ok thanks.
|
In response to KirbyAllStar
|
|
Because it's part of a procedure that's probably run very infrequently, there is really no reason to fret about it. If it were part of a recursive procedure that would be run through 500 times every tick, then the tiny difference in calculation time one way or the other might become significant -- but since you're probably only checking this every time you increase bladelvl, there isn't much point stress-testing to see which one is faster.
If you're curious, just try mob/verb/test() I really don't know which method would work best, but this might give you better resolution since it doesn't involve world.realtime's inaccuracy. mob/Login() |
In response to PirateHead
|
|
Amazingly enough neither took up enough time to let the time change when it was run.
Also I don't use bladelvl, just using that from Lummox Jr's post as an example. |
In response to KirbyAllStar
|
|
You could try increasing one million to ten million, or one billion, to increase the time to the point where it stalls the processor.
|
Nope, you just need to use a formula:
Lummox JR