Label (right alignment)

I trying to label scores on the left and right side of the screen. but I cant keep it a uniform distance away from the right.

my request to improve this is have the option to right align text so it builds from right to left.

You could try and check the length of the string and offset it based on that, assuming you're drawing a number, the following could work:

on draw do
  x = 24
  if score>999 then
    x--
  end
  if score>99 then
    x--
  end
  if score>9 then
    x--
  end
  label score at x,0
end

It's not ideal, it would be great to set the alignment, but this should work in the meantime.

1 Like

We just added simple left and right padding formatting options to PulpScript. Now you can do something like this:

label “{6, :score}” at 15,0 // left pad the variable “score" to length 6 with spaces
2 Likes

Ooh that's definitely the best solution! Thanks Shaun!