MOARdV / AvionicsSystems

MOARdV's Avionics Systems for Kerbal Space Program - a new generation of IVA enhancement.
Other
52 stars 26 forks source link

Question. Vertical text. #136

Closed Alexustas closed 6 years ago

Alexustas commented 6 years ago

I need to convert plain text to vertical. like this.

S
o
l
i
d
F
u
e
l

I made a script that adds after each character in the line the string "$$$. So the string is looks like this: S$$$o$$$l$$$i$$$d$$$F$$$u$$$e$$$l$$$

But on the MFD screen I get. this:

screenshot88 (Do not pay attention to the fact that the letters gradually go up, this is normal)

although if I put the same line in the text field in the "TEXT" node , then I get the correct result. It looks that the MAS handles the $$$in the text if it directly entered, but does not handles in the string returned by the script

Alexustas commented 6 years ago

By the way, tags([#rrggbbaa] and [@x..]) in the string returned by the script are processed perfectly

MOARdV commented 6 years ago

The '$$$' is processed before the tags or anything else, so if the script returns '$$$' for a variable, it will work as you show it. I will need to add support for vertical text.

Alexustas commented 6 years ago

I will need to add support for vertical text.

It will be great!

MOARdV commented 6 years ago

I think I can add this only for fixed-width text. Instead of '$$$', it will be the tag '[n]' (n = new line). It will behave strangely for any justification except left/upper, but that is not a problem for MFD.

For variable-width text on labels, '$$$' already works. Adding support for '[n]' will be very difficult, since it requires me to know what the previous character advance was so I can back up far enough. Likewise, supporting text anchors other than left/upper is a lot of effort.

Alexustas commented 6 years ago

Is it possible to configure the space between the lines? this is a very important point

MOARdV commented 6 years ago

Is it possible to configure the space between the lines? this is a very important point

Maybe tag [n] means 'advance one line', [n#] (eg, [n1.5]) means 'advance this number of lines'?

Alexustas commented 6 years ago

Now I'm using a script that uses X and Y Nudge Tags to offset each next character in a string

function ASET_VERTICAL_TEXT_CONVERTER(text,vertShift,upperCase)

    if text ~= nil and text ~= "" then

        local stringLength  = string.len(text)

        if upperCase ~= nil or upperCase == true then text = string.upper(text) end

        if vertShift == nil then vertShift = 0 end

        if stringLength > 1 then

            local newText = ""

            for i=1,stringLength,1 do

            newText = newText .. string.sub(text,i,i) .. "[@x" .. -10*i .. "][@y" .. 20*i-vertShift*i .. "]"

            end

            return newText

        else

            return text

        end

    else

        return ""

    end

end
Alexustas commented 6 years ago

(eg, [n1.5]) means 'advance this number of lines'?

it would be quite good, if it support value less 1

MOARdV commented 6 years ago

it would be quite good, if it support value less 1 Yes, any number, including negative numbers or 0.

Alexustas commented 6 years ago

Excellent!

MOARdV commented 6 years ago

Okay - now on DropBox. I tested [n] (1 line) and [n#] with integer, fraction, zero, and negative values.

Alexustas commented 6 years ago

I changed the script using the [n] tag, and everything works fine. Thank you!