Skip to content

Conversation

@Yoppez
Copy link

@Yoppez Yoppez commented Mar 21, 2025

I thought it would be interesting having the capability to display individual pixels on the LCD screen, so I made this feature.

It doesn't change the behavior when the LCD receives a string, but when it receives a table it will draw each individual pixel with 4096 possible colors (4 bits per channel).

@Desour
Copy link
Contributor

Desour commented Mar 27, 2025

Isn't this better suited as separate mod?
(I think I've seen it implemented already, btw. (And I've attempted it myself (but wasn't satisfied because of the limit on texture name size IIRC).))

Also, if this is added, it probably would make more sense as separate node.
And nowadays, one can use [png for cheaper texture generation and shorter texture names.

@Yoppez
Copy link
Author

Yoppez commented Mar 28, 2025

Isn't this better suited as separate mod?

It's a very small addition that I thought it would be OK for displaying things very quickly.

I think I've seen it implemented already, btw.

Digiscreens already exists, but it has a lower resolution (16x16 vs 56x48) and it is intended to be used with more screens to make a bigger one, while this implementation is intended for one single screen and quicker usage.

Also, if this is added, it probably would make more sense as separate node.

I also thought initially that making a new node made more sense, but then I wanted to try on giving more functionalities to the same screen and see how it would be. I personally think that it is not bad.

And nowadays, one can use [png for cheaper texture generation and shorter texture names.

I'll take a look, thanks.

Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering how this is quite low in complexity and Lines of Code, I think this can be merged into digilines.

However, the PR needs rebasing and here's a few remarks...

meta:set_string("message_type", type(msg))

if msg ~= "" then
if type(msg) ~= string or msg ~= "" then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type(msg) ~= string is always true because type returns a string, and not a table (reference).

end
pixels[i] = color
end
local png = minetest.encode_base64(minetest.encode_png(width, height, pixels))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core could be used instead of minetest. Both are the same, but since the engine was renamed, this notation seems dated. (all occurrences)

return "#0000"
end

return string.format("#%X%X%X", num / 16^2, num / 16 % 16, num % 16 )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the string.format? Couldn't we just use 0x notation in Lua?


local number_to_color = function(num)
if type(num) ~= "number" or num >= 4096 or num < 0 then
return "#0000"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of an error, it might make more sense to either:

  • fall back to 0xF00 (red = error)
  • or convert to 0x000 (black = error)
  • or pass tonumber(num) or 0 to the numeric computation below and let the user see when it looks strange.

Also: What if nan is passed to this function?

if message_type == "string" then
texture = generate_text_texture(create_lines(message))
else
texture = generate_raster_texture(minetest.deserialize(message))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be documented somewhere. Otherwise no-one else would know about this raster feature.

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

Successfully merging this pull request may close these issues.

3 participants