forked from Sokomine/yl_speak_up
		
	auto-refuse unwanted items and let the player take them back
This commit is contained in:
		
							parent
							
								
									a1cae79266
								
							
						
					
					
						commit
						45616bb4ba
					
				| @ -334,6 +334,22 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec | ||||
|         return yl_speak_up.get_fs_talkdialog(player, n_id, target_dialog, res.alternate_text, | ||||
| 		recursion_depth + 1) | ||||
|     end | ||||
| 
 | ||||
|     -- is the player comming back from trying to offer something to the NPC? | ||||
|     -- And is the NPC trying to return the item? | ||||
|     if(not(edit_mode) and d_id == "d_got_item") then | ||||
| 	local pname = player:get_player_name() | ||||
| 	local trade_inv = minetest.get_inventory({type="detached", name="yl_speak_up_player_"..pname}) | ||||
| 	if(not(trade_inv:is_empty("npc_wants"))) then | ||||
| 		return "size[8,1.5]".. | ||||
| 			"label[0.2,-0.2;".. | ||||
| 			minetest.formspec_escape(dialog.n_npc or "- ? -").. | ||||
| 			" does not seem to be intrested.\n".. | ||||
| 			"Please take your item back and try something else.]".. | ||||
| 			"button[2,1.0;1.5,0.9;show_player_offers_item;Ok]" | ||||
| 	end | ||||
|     end | ||||
| 
 | ||||
|     yl_speak_up.speak_to[pname].allowed = allowed | ||||
| 
 | ||||
|     local portrait = calculate_portrait(pname, n_id) | ||||
| @ -1667,6 +1683,13 @@ yl_speak_up.input_talk = function(player, formname, fields) | ||||
|             return | ||||
|         end | ||||
| 
 | ||||
| 	-- allow the player to take the item back | ||||
| 	if(fields.show_player_offers_item and fields.show_player_offers_item ~= "") then | ||||
| 	    yl_speak_up.show_fs(player, "player_offers_item", nil) | ||||
| 	    return | ||||
| 	end | ||||
| 
 | ||||
| 
 | ||||
|         if fields.button_up then | ||||
|             yl_speak_up.speak_to[pname].option_index = | ||||
|                 yl_speak_up.speak_to[pname].option_index + yl_speak_up.max_number_of_buttons | ||||
|  | ||||
| @ -125,6 +125,7 @@ yl_speak_up.show_fs = function(player, fs_name, param) | ||||
| 	elseif(fs_name | ||||
| 	  -- msg is just a loop for displaying (mostly error) messages | ||||
| 	  and fs_name ~= "msg" | ||||
| 	  and fs_name ~= "player_offers_item" | ||||
| 	  -- is the player editing the NPC? that is: might there be any changes? | ||||
| 	  and (yl_speak_up.edit_mode[pname] == yl_speak_up.speak_to[pname].n_id)) then | ||||
| 		local last_fs = yl_speak_up.speak_to[pname].last_fs | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user