<commit_before>-- UPDATE common SET com_script='item.id_463_quill' WHERE com_itemid IN (463);
require("base.common")
require("alchemy.base.alchemy")
require("base.lookat")
require("alchemy.base.recipe_creation")

module("item.id_463_quill", package.seeall)

function UseItem(User, SourceItem, ltstate)
    
	if SourceItem.itempos ~= 5 and SourceItem.itempos ~= 6 then
	    User:inform("Du musst die Schreibfeder in der Hand halten.","You have to hold the quill in your hand.",Character.lowPriority)
		return
	end	
	
	local callback = function(dialog) 
		local success = dialog:getSuccess() 
		if success then
			local selected = dialog:getSelectedIndex()+1
			if selected == 1 then
			    if not CheckIfBottleInHand(User) then
				    User:inform("Du brauchst eine Flasche, um diese zu beschrfiten.","You need a bottle if you want to label one.",Character.lowPriority)
				    return
                else
                    WriteLabel(User,SourceItem)
			    end
			elseif selected == 2 then
			    local parchment = alchemy.base.recipe_creation.GetParchmentQuill(User)
				parchment = alchemy.base.recipe_creation.IsParchmentOK(User,parchment,ingredientsList)
				if not parchment then
					return
				else
				    alchemy.base.recipe_creation.FirstMenu(User, ingredientsList)
				end
			elseif selected == 3 then
			    if not CheckIfContainerPresent(User) then
				    User:inform("Du brauchst eine Tasche, um diese zu beschrfiten.","You need a bag if you want to label one.",Character.lowPriority)
				    return
                else
                    WriteContainerLabel(User,SourceItem)
			    end
            end    			
		end
	end

	local dialog = SelectionDialog(getText(User,"Schreibfeder","Quill") , getText(User,"Whle aus, was du machen willst.","Select what you want to do.") , callback)
	dialog:addOption(0, getText(User,"Trankflasche beschriften","Label potion bottle"))
	dialog:addOption(0, getText(User,"Alchemierezept schreiben","Write an alchemy recipe"))
	dialog:addOption(0, getText(User,"Tasche beschriften","Label bag"))

	User:requestSelectionDialog(dialog)
	
	
end

containerList = {97,320, 321, 799, 1367, 2830};

function CheckIfCotainerPresent(User)
	local containerItem;

	for i=1,#containerList do
		containerItem = User:getItemAt(0);
		if (containerItem.id == containerList[i]) then
			return containerItem;
		end
	end
	return nil;		
end

function CheckIfBottleInHand(User)

	local bottleList = alchemy.base.alchemy.bottleList
	for i=1,((#bottleList)+1) do
		local ItemA = User:getItemAt(5)
		local ItemB = User:getItemAt(6)
		if (ItemA.id == bottleList[i]) or (ItemA.id == 164) then
			return ItemA
		elseif (ItemB.id == bottleList[i]) or (ItemB.id == 164) then
			return ItemB
		end
	end
	return nil		
end<commit_msg>Bag Labeling<commit_after>-- UPDATE common SET com_script='item.id_463_quill' WHERE com_itemid IN (463);
require("base.common")
require("alchemy.base.alchemy")
require("base.lookat")
require("alchemy.base.recipe_creation")

module("item.id_463_quill", package.seeall)

function UseItem(User, SourceItem, ltstate)
    
	if SourceItem.itempos ~= 5 and SourceItem.itempos ~= 6 then
	    User:inform("Du musst die Schreibfeder in der Hand halten.","You have to hold the quill in your hand.",Character.lowPriority)
		return
	end	
	
	local callback = function(dialog) 
		local success = dialog:getSuccess() 
		if success then
			local selected = dialog:getSelectedIndex()+1
			if selected == 1 then
			    if not CheckIfBottleInHand(User) then
				    User:inform("Du brauchst eine Flasche, um diese zu beschrfiten.","You need a bottle if you want to label one.",Character.lowPriority)
				    return
                else
                    WriteLabel(User,SourceItem)
			    end
			elseif selected == 2 then
			    local parchment = alchemy.base.recipe_creation.GetParchmentQuill(User)
				parchment = alchemy.base.recipe_creation.IsParchmentOK(User,parchment,ingredientsList)
				if not parchment then
					return
				else
				    alchemy.base.recipe_creation.FirstMenu(User, ingredientsList)
				end
			elseif selected == 3 then
				User:inform("in selected == 3");
			    if not CheckIfContainerPresent(User) then
				    User:inform("Du brauchst eine Tasche, um diese zu beschrfiten.","You need a bag if you want to label one.",Character.lowPriority)
				    return
                else
                    WriteContainerLabel(User,SourceItem)
			    end
            end    			
		end
	end

	local dialog = SelectionDialog(getText(User,"Schreibfeder","Quill") , getText(User,"Whle aus, was du machen willst.","Select what you want to do.") , callback)
	dialog:addOption(0, getText(User,"Trankflasche beschriften","Label potion bottle"))
	dialog:addOption(0, getText(User,"Alchemierezept schreiben","Write an alchemy recipe"))
	dialog:addOption(0, getText(User,"Tasche beschriften","Label bag"))

	User:requestSelectionDialog(dialog)
	
	
end

containerList = {97,320, 321, 799, 1367, 2830};

function CheckIfContainerPresent(User)
	local containerItem;

	for i=1,#containerList do
		containerItem = User:getItemAt(0);
		if (containerItem.id == containerList[i]) then
			return containerItem;
		end
	end
	return nil;		
end

function CheckIfBottleInHand(User)

	local bottleList = alchemy.base.alchemy.bottleList
	for i=1,((#bottleList)+1) do
		local ItemA = User:getItemAt(5)
		local ItemB = User:getItemAt(6)
		if (ItemA.id == bottleList[i]) or (ItemA.id == 164) then
			return ItemA
		elseif (ItemB.id == bottleList[i]) or (ItemB.id == 164) then
			return ItemB
		end
	end
	return nil		
end
{'fraction_non_alphanumeric': 0.10070384407146725, 'fraction_numerical': 0.017866811044937737, 'mean_word_length': 3.785837651122625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2932715', 'n_tokens_mistral': 2039, 'n_tokens_neox': 1745, 'n_words': 463}