diff options
Diffstat (limited to 'unified_inventory')
| -rw-r--r-- | unified_inventory/README.md | 50 | ||||
| -rw-r--r-- | unified_inventory/image_credits.txt | 3 | ||||
| -rw-r--r-- | unified_inventory/internal.lua | 4 | ||||
| -rw-r--r-- | unified_inventory/item_names.lua | 70 | 
4 files changed, 94 insertions, 33 deletions
diff --git a/unified_inventory/README.md b/unified_inventory/README.md index d0ca9cf..1de7256 100644 --- a/unified_inventory/README.md +++ b/unified_inventory/README.md @@ -13,11 +13,49 @@ Unified inventory code is licensed under the GNU LGPLv2+.  Licenses for textures: -VanessaE: (WTFPL) +VanessaE: (CC-BY-4.0)    * `ui_group.png` -RealBadAngel: (WTFPL) -  * Everything else. - -Tango Project: (WTFPL) -  * `ui_reset_icon.png` +Tango Project: (Public Domain, CC-BY-4.0) +  * [`ui_reset_icon.png`](https://commons.wikimedia.org/wiki/File:Edit-clear.svg) +  * [`ui_doubleleft_icon.png`](http://commons.wikimedia.org/wiki/File:Media-seek-backward.svg) +  * [`ui_doubleright_icon.png`](http://commons.wikimedia.org/wiki/File:Media-seek-forward.svg) +  * [`ui_left_icon.png` / `ui_right_icon.png`](http://commons.wikimedia.org/wiki/File:Media-playback-start.svg) +  * [`ui_skip_backward_icon.png`](http://commons.wikimedia.org/wiki/File:Media-skip-backward.svg) +  * [`ui_skip_forward_icon.png`](http://commons.wikimedia.org/wiki/File:Media-skip-forward.svg) + +From http://www.clker.com (Public Domain, CC-BY-4.0): +  * [`bags_small.png`](http://www.clker.com/clipart-moneybag-empty.html) +  * [`bags_medium.png`](http://www.clker.com/clipart-backpack-1.html) +  * [`bags_large.png` / `ui_bags_icon.png`](http://www.clker.com/clipart-backpack-green-brown.html) +  * `ui_trash_icon.png`: <http://www.clker.com/clipart-29090.html> and <http://www.clker.com/clipart-trash.html> +  * [`ui_search_icon.png`](http://www.clker.com/clipart-24887.html) +  * [`ui_off_icon.png` / `ui_on_icon.png`](http://www.clker.com/clipart-on-off-switches.html) +  * [`ui_waypoints_icon.png`](http://www.clker.com/clipart-map-pin-red.html) +  * [`ui_circular_arrows_icon.png`](http://www.clker.com/clipart-circular-arrow-pattern.html) +  * [`ui_pencil_icon.pnc`](http://www.clker.com/clipart-2256.html) +  * [`ui_waypoint_set_icon.png`](http://www.clker.com/clipart-larger-flag.html) + +Everaldo Coelho (YellowIcon) (LGPL v2.1+): +  * [`ui_craftguide_icon.png` / `ui_craft_icon.png`](http://commons.wikimedia.org/wiki/File:Advancedsettings.png) + +Gregory H. Revera: (CC-BY-SA 3.0) +  * [`ui_moon_icon.png`](http://commons.wikimedia.org/wiki/File:FullMoon2010.jpg) + +Thomas Bresson: (CC-BY 3.0) +  * [`ui_sun_icon.png`](http://commons.wikimedia.org/wiki/File:2012-10-13_15-29-35-sun.jpg) + +Fibonacci: (Public domain, CC-BY 4.0) +  * [`ui_xyz_off_icon.png`](http://commons.wikimedia.org/wiki/File:No_sign.svg) + +Gregory Maxwell: (Public domain, CC-BY 4.0) +  * [`ui_ok_icon.png`](http://commons.wikimedia.org/wiki/File:Yes_check.svg) + +Adrien Facélina: (LGPL v2.1+) +  * [`inventory_plus_worldedit_gui.png`](http://commons.wikimedia.org/wiki/File:Erioll_world_2.svg) + +Other files from Wikimedia Commons: +  * [`ui_gohome_icon.png` / `ui_home_icon.png` / `ui_sethome_icon.png`](http://commons.wikimedia.org/wiki/File:Home_256x256.png) (GPL v2+) + +RealBadAngel: (CC-BY-4.0) +  * Everything else.
\ No newline at end of file diff --git a/unified_inventory/image_credits.txt b/unified_inventory/image_credits.txt index b1489e4..12fbc65 100644 --- a/unified_inventory/image_credits.txt +++ b/unified_inventory/image_credits.txt @@ -25,6 +25,9 @@ ui_skip_backward_icon.png  ui_skip_forward_icon.png  	http://commons.wikimedia.org/wiki/File:Media-skip-forward.svg +ui_reset_icon.png +	https://commons.wikimedia.org/wiki/File:Edit-clear.svg +  ui_gohome_icon.png / ui_home_icon.png / ui_sethome_icon.png  	http://commons.wikimedia.org/wiki/File:Home_256x256.png diff --git a/unified_inventory/internal.lua b/unified_inventory/internal.lua index 5732971..4e78a89 100644 --- a/unified_inventory/internal.lua +++ b/unified_inventory/internal.lua @@ -290,6 +290,7 @@ function unified_inventory.apply_filter(player, filter, search_dir)  			return string.find(lname, lfilter, 1, true) or string.find(ldesc, lfilter, 1, true)  		end  	end +	local is_creative = unified_inventory.is_creative(player_name)  	unified_inventory.filtered_items_list[player_name]={}  	for name, def in pairs(minetest.registered_items) do  		if (not def.groups.not_in_creative_inventory @@ -297,8 +298,7 @@ function unified_inventory.apply_filter(player, filter, search_dir)  		and def.description  		and def.description ~= ""  		and ffilter(name, def) -		and (unified_inventory.is_creative(player_name) -			or unified_inventory.crafts_for.recipe[def.name]) then +		and (is_creative or unified_inventory.crafts_for.recipe[def.name]) then  			table.insert(unified_inventory.filtered_items_list[player_name], name)  		end  	end diff --git a/unified_inventory/item_names.lua b/unified_inventory/item_names.lua index 243b938..d374b14 100644 --- a/unified_inventory/item_names.lua +++ b/unified_inventory/item_names.lua @@ -1,55 +1,75 @@  -- Based on 4itemnames mod by 4aiman -local wield = {} -local huds = {} -local dtimes = {} +local item_names = {} -- [player_name] = { hud, dtime, itemname }   local dlimit = 3  -- HUD element will be hidden after this many seconds  local air_hud_mod = minetest.get_modpath("4air")  local hud_mod = minetest.get_modpath("hud")  local hudbars_mod = minetest.get_modpath("hudbars")  local function set_hud(player) -	local player_name = player:get_player_name()  +	local player_name = player:get_player_name()  	local off = {x=0, y=-70}  	if air_hud_mod or hud_mod then  		off.y = off.y - 20  	elseif hudbars_mod then  		off.y = off.y + 13  	end -	huds[player_name] = player:hud_add({ -		hud_elem_type = "text", -		position = {x=0.5, y=1}, -		offset = off, -		alignment = {x=0, y=0}, -		number = 0xFFFFFF , -		text = "", -	}) +	item_names[player_name] = { +		hud = player:hud_add({ +			hud_elem_type = "text", +			position = {x=0.5, y=1}, +			offset = off, +			alignment = {x=0, y=0}, +			number = 0xFFFFFF, +			text = "", +		}), +		dtime = dlimit, +		index = 1, +		itemname = "" +	}  end  minetest.register_on_joinplayer(function(player)  	minetest.after(0, set_hud, player)  end) +minetest.register_on_leaveplayer(function(player) +	item_names[player:get_player_name()] = nil +end) +  minetest.register_globalstep(function(dtime)  	for _, player in pairs(minetest.get_connected_players()) do -		local player_name = player:get_player_name() -		local wstack = player:get_wielded_item():get_name() +		local data = item_names[player:get_player_name()] +		if not data or not data.hud then +			data = {} -- Update on next step +			set_hud(player) +		end -		if dtimes[player_name] and dtimes[player_name] < dlimit then -			dtimes[player_name] = dtimes[player_name] + dtime -			if dtimes[player_name] > dlimit and huds[player_name] then -				player:hud_change(huds[player_name], 'text', "") +		local index = player:get_wield_index() +		local stack = player:get_wielded_item() +		local itemname = stack:get_name() + +		if data.hud and data.dtime < dlimit then +			data.dtime = data.dtime + dtime +			if data.dtime > dlimit then +				player:hud_change(data.hud, 'text', "")  			end  		end -		if wstack ~= wield[player_name] then -			wield[player_name] = wstack -			dtimes[player_name] = 0 -			if huds[player_name] then  -				local def = minetest.registered_items[wstack] -				local desc = def and def.description or "" -				player:hud_change(huds[player_name], 'text', desc) +		if data.hud and (itemname ~= data.itemname or index ~= data.index) then +			data.itemname = itemname +			data.index = index +			data.dtime = 0 + +			local desc = stack.get_meta +				and stack:get_meta():get_string("description") + +			if not desc or desc == "" then +				-- Try to use default description when none is set in the meta +				local def = minetest.registered_items[itemname] +				desc = def and def.description or ""  			end +			player:hud_change(data.hud, 'text', desc)  		end  	end  end)  | 
