digilines icon indicating copy to clipboard operation
digilines copied to clipboard

LCD: Make the text left-aligned

Open numberZero opened this issue 8 years ago • 4 comments

Center alignment annoys. It is nice for signs, but the LCD should avoid that. Also, the LCD dimensions (in letters) should be documented.

numberZero avatar Feb 19 '17 19:02 numberZero

Agreed. For now, if you hadn't seen it, the dimensions are 12x5 characters, and there is automatic word-wrapping it seems. (https://github.com/minetest-mods/digilines/blob/master/lcd.lua#L27)

TangentFoxy avatar May 03 '19 16:05 TangentFoxy

There are other mods which add other lcds, eg.: https://forum.minetest.net/viewtopic.php?t=20794

Desour avatar May 03 '19 19:05 Desour

With #64, you will have the option to use multiple spaces or characters not in the very limited charset (like ´ or ä) to control the spacing of characters. For left aligned text, this is still just a workaround, but it at least will be possible then.

EDIT: Please note that while you now can use chars like ´ or ä as spacing, they are encoded as two byte. Lua assumes each character in a string is only one byte long and the typesetting algorithm will thus allocates two spaces for them.

PeterNerlich avatar Dec 07 '20 17:12 PeterNerlich

#64 is merged, you can now just add spaces to the right of the line until it is full:

local line_width = 12
local to_display = "fill up!"
local pad_right = function(s, times, char)
  char = char or " "
  return tostring(s) .. string.rep(char, times)
end
digiline_send('screen', pad_right(to_display, line_width - string.len(to_display)))

This will send fill up! (with 4 spaces to the right, thank you very much github) to screen and any LCD set to this channel will display fill up! all the way to the left.

PeterNerlich avatar Dec 10 '20 23:12 PeterNerlich