ID:164982
 
var
pixels = (_IconWidth * width)
tiles = ceil(pixels / 32)
modifier = ((width>=7)?(3.5):(2.5))
startloc = round((pixels + tiles*32)/modifier)
for(var/i=1, i<=width, ++i)
_DrawNumber(copytext(number,i,i+1), -startloc+((i-1)*_IconWidth), location, color)


I need to know how to center the numbers. startloc is the position I start from. I can't seem to figure it out.

[Edit]
I used a variable called modifier to divide pixels+tiles*32 and it works perfectly. I don't remember my reason for doing this, though.
CaptFalcon33035 wrote:
> var
> pixels = (_IconWidth * width) - 1
> tiles = ceil(pixels / 32)
> startloc = -((tiles*32) - (pixels/2))
> for(var/i=1, i<=width, ++i)
> _DrawNumber(copytext(number,i,i+1), startloc+((i-1)*_IconWidth), location, color)
>


I need to know how to center the numbers. startloc is the position I start from. I can't seem to figure it out.

Here's your problem:

startloc = -((tiles*32) - (pixels/2))


Randomly changing the math around isn't going to help you. You need to think through the problem. When you posted this in chat earlier you were much closer to being correct, but I see you've done some wacky stuff like put parentheses around pixels/2 instead of leaving the /2 outside of it all, or putting - in front of the whole thing. What you're doing here makes no sense.

This is the correct formula:

startloc = round((tiles*32 - pixels)/2)


Lummox JR
In response to Lummox JR (#1)
Lummox JR wrote:
CaptFalcon33035 wrote:
> > var
> > pixels = (_IconWidth * width) - 1
> > tiles = ceil(pixels / 32)
> > startloc = -((tiles*32) - (pixels/2))
> > for(var/i=1, i<=width, ++i)
> > _DrawNumber(copytext(number,i,i+1), startloc+((i-1)*_IconWidth), location, color)
> >


I need to know how to center the numbers. startloc is the position I start from. I can't seem to figure it out.

Here's your problem:

startloc = -((tiles*32) - (pixels/2))


Randomly changing the math around isn't going to help you. You need to think through the problem. When you posted this in chat earlier you were much closer to being correct, but I see you've done some wacky stuff like put parentheses around pixels/2 instead of leaving the /2 outside of it all, or putting - in front of the whole thing. What you're doing here makes no sense.

This is the correct formula:

startloc = round((tiles*32 - pixels)/2)


Lummox JR

I was holding undo to go back to the formula I showed you in wiz_chat, but it went too far back. I was starting to use linear functions. I just kept having ideas.

As for your soultion, that is the exact same thing I had, minus an extra pair of parenthesis, and it does not work. I don't know why it doesn't.