summaryrefslogtreecommitdiff
path: root/sfinv.lua
blob: 7febe26e32be31751c5aeb269ed8b13d6b0efd1c (plain)
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
if minetest.get_modpath("sfinv") then
	local S
	if minetest.get_modpath("intllib") then
		S = intllib.Getter()
	else
		S = function ( s ) return s end
	end

	sfinv.register_page("awards:awards", {
		title = S("Awards"),
		on_enter = function(self, player, context)
			context.awards_idx = 1
		end,
		get = function(self, player, context)
			local name = player:get_player_name()
			return sfinv.make_formspec(player, context,
				awards.getFormspec(name, name, context.awards_idx or 1),
				false, "size[11,5]")
		end,
		on_player_receive_fields = function(self, player, context, fields)
			if fields.awards then
				local event = minetest.explode_textlist_event(fields.awards)
				if event.type == "CHG" then
					context.awards_idx = event.index
					sfinv.set(player, context)
				end
			end
		end
	})
end