Skip to content

Commit

Permalink
Allow displaying image in POIs (#36)
Browse files Browse the repository at this point in the history
* Allow displaying image on POIs

* Fix metadata
  • Loading branch information
Emojigit authored Jun 28, 2024
1 parent e660eeb commit 1ab5ddd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions poi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ local update_formspec = function(meta)
local name = meta:get_string("name")
local icon = meta:get_string("icon") or "home"
local url = meta:get_string("url") or ""
local image = meta:get_string("image") or ""

meta:set_string("infotext", "POI, name:" .. name .. ", icon:" .. icon)

meta:set_string("formspec", "size[8,4;]" ..
meta:set_string("formspec", "size[8,5;]" ..
-- col 1
"field[0.2,1;4,1;name;Name;" .. name .. "]" ..
"field[4.2,1;4,1;icon;Icon;" .. icon .. "]" ..
Expand All @@ -18,7 +19,10 @@ local update_formspec = function(meta)
"field[0.2,2;8,1;url;URL;" .. url .. "]" ..

-- col 3
"button_exit[0,3;8,1;save;Save]" ..
"field[0.2,3;8,1;image;Image;" .. image .. "]" ..

-- col 4
"button_exit[0,4;8,1;save;Save]" ..
"")

end
Expand All @@ -34,6 +38,7 @@ local on_receive_fields = function(pos, formname, fields, sender)
if fields.save then
meta:set_string("name", fields.name)
meta:set_string("url", fields.url)
meta:set_string("image", fields.image)
meta:set_string("icon", fields.icon or "home")
end

Expand All @@ -60,6 +65,7 @@ local register_poi = function(color, dye)
meta:set_string("name", "<unconfigured>")
meta:set_string("icon", "home")
meta:set_string("url", "")
meta:set_string("image", "")

update_formspec(meta)
end,
Expand Down

0 comments on commit 1ab5ddd

Please sign in to comment.