Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LCD: Make the text left-aligned #41

Open
numberZero opened this issue Feb 19, 2017 · 4 comments
Open

LCD: Make the text left-aligned #41

numberZero opened this issue Feb 19, 2017 · 4 comments

Comments

@numberZero
Copy link

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

@TangentFoxy
Copy link

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
Copy link
Contributor

Desour commented May 3, 2019

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

@PeterNerlich
Copy link
Contributor

PeterNerlich commented Dec 7, 2020

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
Copy link
Contributor

PeterNerlich commented Dec 10, 2020

#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants