I've got a function which converts a supplied number of seconds into hour, minute, second format. It's supposed to just convert to the best solution, then return the remainder, so that 300 becomes 5 minutes with 0's elsewhere, and 301 returns 5 minutes, 1 second. This all works great, until I go passed the 1 hour mark. Here's the block of code, and examples of it failing. Anyone with a much better grasp of math mind correcting my function? I basically just copied the formula from the mushclient source for DoAfterSpecial, since I would've been lost otherwise. I'm apparently missing something, however, as I typing DoAfter(5400) doesn't fail the way my function does.

Highly amused. I got it to work this way, but of course, I still can't work with seconds higher than 3600, at which point the system goes into negatives. Ah well. Limit input at 3600 seconds and have at it. Thanks for the input guys!

I also figured that flooring all the results wasn't doing me any good either.

However, now when I remove all the flooring and fixed that dual subtraction, I get even stranger results.

You're flailing. That's bad.

If you ask for help and get it, implement the suggestion and see if it works before doing anything else. If you want to know why a suggestion was made, ask. Don't make changes that you don't understand.

I do like the version you posted much better, Meerclar. Will try that in my function to see if things turn out better, though will I still have issues with values higher than 3600?

Flailing? Maybe. I'd been searching for tons of examples on Google, reading over them, and also trying them. For now, the last block I posted works well enough, if albeit with a caveat that I can't input rangers higher than an hour, so if this approach doesn't work out for me, I'll revert to that.

Going to switch around the function now with the new suggestions and see how it goes, and thanks again for the help.

Update: Meerclar, you are my hero. Thanks for helping out an admitted math subnormal -- equasions hurt my head. What's more, this version works great for values over 1 hour, too!

Thanks a lot. I know I never would've been able to figure that out on my own. If it was pure scripting syntax, yes, but when it comes to mathematical stuff, I'm out of the loop.

I'm only as good as I am with math operations because of Eve Online - it's not called spreadsheets in space for giggles. I've had to cook up some ridiculously complicated resource trackers over the years to be certain I wasn't about to shortchange myself on a supply run.