forked from nalc/awards
		
	Add sfinv support
This commit is contained in:
		
							
								
								
									
										9
									
								
								api.lua
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								api.lua
									
									
									
									
									
								
							@@ -299,7 +299,7 @@ awards.give_achievement = awards.unlock
 | 
				
			|||||||
})]]--
 | 
					})]]--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function awards.getFormspec(name, to, sid)
 | 
					function awards.getFormspec(name, to, sid)
 | 
				
			||||||
	local formspec = "size[11,5]"
 | 
						local formspec = ""
 | 
				
			||||||
	local listofawards = awards._order_awards(name)
 | 
						local listofawards = awards._order_awards(name)
 | 
				
			||||||
	local playerdata = awards.players[name]
 | 
						local playerdata = awards.players[name]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -338,8 +338,8 @@ function awards.getFormspec(name, to, sid)
 | 
				
			|||||||
				if perc > 1 then
 | 
									if perc > 1 then
 | 
				
			||||||
					perc = 1
 | 
										perc = 1
 | 
				
			||||||
				end
 | 
									end
 | 
				
			||||||
				formspec = formspec .. "background[0,4.80;" .. barwidth ..",0.25;awards_progress_gray.png]"
 | 
									formspec = formspec .. "background[0,4.80;" .. barwidth ..",0.25;awards_progress_gray.png;false]"
 | 
				
			||||||
				formspec = formspec .. "background[0,4.80;" .. (barwidth * perc) ..",0.25;awards_progress_green.png]"
 | 
									formspec = formspec .. "background[0,4.80;" .. (barwidth * perc) ..",0.25;awards_progress_green.png;false]"
 | 
				
			||||||
				if label then
 | 
									if label then
 | 
				
			||||||
					formspec = formspec .. "label[1.75,4.63;" .. label .. "]"
 | 
										formspec = formspec .. "label[1.75,4.63;" .. label .. "]"
 | 
				
			||||||
				end
 | 
									end
 | 
				
			||||||
@@ -414,7 +414,8 @@ function awards.show_to(name, to, sid, text)
 | 
				
			|||||||
			sid = 1
 | 
								sid = 1
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
		-- Show formspec to user
 | 
							-- Show formspec to user
 | 
				
			||||||
		minetest.show_formspec(to,"awards:awards", awards.getFormspec(name, to, sid))
 | 
							minetest.show_formspec(to,"awards:awards",
 | 
				
			||||||
 | 
								"size[11,5]" .. awards.getFormspec(name, to, sid))
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
awards.showto = awards.show_to
 | 
					awards.showto = awards.show_to
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,2 +1,3 @@
 | 
				
			|||||||
intllib?
 | 
					intllib?
 | 
				
			||||||
 | 
					sfinv?
 | 
				
			||||||
unified_inventory?
 | 
					unified_inventory?
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								init.lua
									
									
									
									
									
								
							@@ -25,6 +25,7 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
dofile(minetest.get_modpath("awards").."/api.lua")
 | 
					dofile(minetest.get_modpath("awards").."/api.lua")
 | 
				
			||||||
dofile(minetest.get_modpath("awards").."/chat_commands.lua")
 | 
					dofile(minetest.get_modpath("awards").."/chat_commands.lua")
 | 
				
			||||||
 | 
					dofile(minetest.get_modpath("awards").."/sfinv.lua")
 | 
				
			||||||
dofile(minetest.get_modpath("awards").."/unified_inventory.lua")
 | 
					dofile(minetest.get_modpath("awards").."/unified_inventory.lua")
 | 
				
			||||||
dofile(minetest.get_modpath("awards").."/triggers.lua")
 | 
					dofile(minetest.get_modpath("awards").."/triggers.lua")
 | 
				
			||||||
awards.set_intllib(S)
 | 
					awards.set_intllib(S)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										23
									
								
								sfinv.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								sfinv.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					if minetest.get_modpath("sfinv") then
 | 
				
			||||||
 | 
						sfinv.register_page("awards:awards", {
 | 
				
			||||||
 | 
							title = "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
 | 
				
			||||||
		Reference in New Issue
	
	Block a user