Skip to content

Commit 1ab5ddd

Browse files
authored
Allow displaying image in POIs (#36)
* Allow displaying image on POIs * Fix metadata
1 parent e660eeb commit 1ab5ddd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

poi.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ local update_formspec = function(meta)
66
local name = meta:get_string("name")
77
local icon = meta:get_string("icon") or "home"
88
local url = meta:get_string("url") or ""
9+
local image = meta:get_string("image") or ""
910

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

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

2021
-- col 3
21-
"button_exit[0,3;8,1;save;Save]" ..
22+
"field[0.2,3;8,1;image;Image;" .. image .. "]" ..
23+
24+
-- col 4
25+
"button_exit[0,4;8,1;save;Save]" ..
2226
"")
2327

2428
end
@@ -34,6 +38,7 @@ local on_receive_fields = function(pos, formname, fields, sender)
3438
if fields.save then
3539
meta:set_string("name", fields.name)
3640
meta:set_string("url", fields.url)
41+
meta:set_string("image", fields.image)
3742
meta:set_string("icon", fields.icon or "home")
3843
end
3944

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

6470
update_formspec(meta)
6571
end,

0 commit comments

Comments
 (0)