This file is indexed.

/usr/share/games/minetest/mods/maidroid/maidroid_tool/nametag.lua is in minetest-mod-maidroid 0.1.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
------------------------------------------------------------
-- Copyright (c) 2016 tacigar. All rights reserved.
-- https://github.com/tacigar/maidroid
------------------------------------------------------------

local formspec = "size[4,1.25]"
			.. default.gui_bg
			.. default.gui_bg_img
 			.. default.gui_slots
			.. "button_exit[3,0.25;1,0.875;apply_name;Apply]"
			.. "field[0.5,0.5;2.75,1;name;name;]"

local maidroid_buf = {} -- for buffer of target maidroids.

minetest.register_craftitem("maidroid_tool:nametag", {
	description      = "maidroid tool : nametag",
	inventory_image  = "maidroid_tool_nametag.png",
	stack_max        = 1,

	on_use = function(itemstack, user, pointed_thing)
		if pointed_thing.type ~= "object" then
			return nil
		end

		local obj = pointed_thing.ref
		local luaentity = obj:get_luaentity()

		if not obj:is_player() and luaentity then
			local name = luaentity.name

			if maidroid.registered_maidroids[name] and not luaentity:is_named() then
				local player_name = user:get_player_name()

				minetest.show_formspec(player_name, "maidroid_tool:nametag", formspec)
				maidroid_buf[player_name] = luaentity

				itemstack:take_item()
				return itemstack
			end
		end
		return nil
	end,
})

minetest.register_on_player_receive_fields(function(player, formname, fields)
	if formname ~= "maidroid_tool:nametag" then
		return
	end

	if fields.name then
		local luaentity = maidroid_buf[player:get_player_name()]
		luaentity.nametag = fields.name

		luaentity.object:set_nametag_attributes{
			text = fields.name,
		}
	end
end)