minetest-mods / digilines

Digilines is a mod for minetest which adds data bus wires
Other
40 stars 38 forks source link

LCD: Make the text left-aligned #41

Open numberZero opened 7 years ago

numberZero commented 7 years ago

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

TangentFoxy commented 5 years ago

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)

Desour commented 5 years ago

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

PeterNerlich commented 3 years ago

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 commented 3 years ago

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.