Copy Paste.

Post Reply
User avatar
Quirunerk
Posts: 65
Joined: Sun Aug 20, 2017 3:06 pm
Has thanked: 24 times
Been thanked: 1 time

Copy Paste.

Post by Quirunerk » Sat Aug 26, 2017 2:57 pm

Can anybody paste official crafting code without this :
--if Player:GetTargetID() == 0 then
-- PlayerInput:Escape()
--end

I deselected it but it still stopping after 1times

unkn0wnus3r
Posts: 75
Joined: Wed Jan 18, 2017 12:27 pm
Has thanked: 10 times
Been thanked: 13 times

Re: Copy Paste.

Post by unkn0wnus3r » Sun Aug 27, 2017 1:04 am

Code: Select all

--[[

	--------------------------------------------------
	Copyright (C) 2011 TheyRot

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
	--------------------------------------------------
	
	--------------------------------------------------
	Material List : https://www.nyerk.xyz/viewtopic.php?f=7&t=121
	--------------------------------------------------

--]]

--- OnLoad is called when the script initially loads.
--
-- @return	void
function OnLoad()
	Write( "Make sure you have sufficient items in your inventory" )
	Write( "Your starting position should be in the crafting area" )
	Write( "Close all work orders in progress before starting" )
	Write( "" )
	Write( "Material List: https://www.nyerk.xyz/viewtopic.php?f=7&t=121")
	
	-- Script settings, never go below 500 milliseconds. Increase for higher latency.
	click_wait_time = 1000			-- Wait time in milliseconds after each click.
	move_via_auto_approach = true	-- Set to true when you want to use auto approach for move to NPC.
	
	-- Script settings, do not touch
	learning = 1 					-- Initially the script needs to learn the htmls
	first_screen = 0				-- First screen html index
	timer = 0						-- Restrict clicking using this timer.
	crafting_step = 0				-- Crafting step
	enable_craft = 0				-- The script determines if the starting position is correct to start crafting
	abandon_workorder = 0;			-- Used to select work order in the journal to close failed work orders
	learned = 0;					-- Check if the screens have been learned
	enough_materials = 0			-- Material check
	
	-- Check which NPC with workorders is closest to you and do the work orders.
    NPC_name = CheckWorkorder()
	
	-- Non-configurable variables, do not touch any of these.
    start_location = Player:GetPosition();	-- Starting position to run to. This HAS to be in the crafting area!
	
end

--- OnRun is called each frame.
--
-- @return	void

function OnRun()
	-- Delay to skip YAY-crafted-an-item-animation
	if DialogList:GetDialog( "making_dialog" ):IsVisible() then
		timer = Time() + 4000 
		return
	end

	if Time() > timer and not Player:IsMoving() then

		if InventoryList:GetSlotCurrent() == InventoryList:GetSlotMaximum() then
			Write("Your inventory is full, aborting script")
			Close()
		end
		
		-- Initial set-up of closing all screens
		if crafting_step == 0 then 
		
			if DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- close dialog screen
				stop_chat();
			elseif DialogList:GetDialog( "tool_making_dialog" ):IsVisible() then -- Crafting screen
				DialogList:GetDialog( "tool_making_dialog" ):SetVisible(false)
			else
				if learned == 0 then
					crafting_step = 1
				else
					crafting_step = 2
				end
			end
			
		-- Learn first screen dialog code
		elseif crafting_step == 1 then
		
			if not DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- no dialog, talk to npc
				start_chat()
			elseif first_screen == 0 then -- Learn the html code of the first screen
				first_screen = DialogList:GetDialog( "dlg_dialog/html_view" ):GetHTML()
				DialogList:GetDialog( "dlg_dialog/html_view/2" ):Click()
			elseif DialogList:GetDialog( "dlg_dialog/accept" ):IsVisible() then -- Accepting quest
				DialogList:GetDialog( "dlg_dialog/accept" ):Click()
				learned = 1
				crafting_step = 4
			elseif DialogList:GetDialog( "dlg_dialog/ok" ):IsVisible() then -- Already have the crafting quest accepted
				stop_chat();
				crafting_step = 3 -- stop the current work order
			else
				DialogList:GetDialog( "dlg_dialog/html_view/1" ):Click()
			end
			
		-- Aquiring the work order
		elseif crafting_step == 2 then 
		
			if not DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- no dialog, talk to npc (trying to make it idiot proof)
				start_chat()
			elseif DialogList:GetDialog( "dlg_dialog/html_view" ):GetHTML() == first_screen then -- First screen is open
				DialogList:GetDialog( "dlg_dialog/html_view/2" ):Click()
			elseif DialogList:GetDialog( "dlg_dialog/accept" ):IsVisible() then -- Accepting quest
				DialogList:GetDialog( "dlg_dialog/accept" ):Click()
				crafting_step = 4 -- go to starting position and close dialogs
			elseif DialogList:GetDialog( "dlg_dialog/ok" ):IsVisible() then -- Already have the crafting quest accepted
				stop_chat();
				crafting_step = 3 -- stop the current work order
			else -- second screen is open
				DialogList:GetDialog( "dlg_dialog/html_view/1" ):Click()
			end
			
		-- Stop the current work order (failed to craft everything)
		elseif crafting_step == 3 then
			
			if not DialogList:GetDialog( "quest_dialog" ):IsVisible() then -- Journal is not opened
				DialogList:GetDialog( "quest_dialog" ):SetVisible(true)
			else -- Journal is open
				if not DialogList:GetDialog( "quest_dialog/1/working_page/task_tab" ):IsVisible() then -- work order is not yet selected
					DialogList:GetDialog( "quest_dialog/quest_tabframe/quest_tab_task" ):Click()
				elseif not DialogList:GetDialog( "quest_dialog/giveup" ):IsEnabled() then -- work order tab is selected, work order is not selected
					local hDialog = DialogList:GetDialog( "quest_dialog/1/working_page/task_tab/working_list/0/1" )
					PlayerInput:Click( hDialog:GetPosition().X + ( 0.5 * hDialog:GetSize().X ), hDialog:GetPosition().Y + 5 )
				else
					local DidFindMatch = false;
					-- Iterate through the dialog to find a non-named confirmation dialog.
					for i = 0, DialogList:GetDialogSize() - 1 do
						-- Retrieve the dialog.
						local CurrentDialog = DialogList:GetDialogIndex( i, false );
						-- Check if the dialog matches expectations.
						if CurrentDialog ~= nil and CurrentDialog:GetName() == "" then
							-- Check if the dialog is visible and the OK button can be clicked.
							if CurrentDialog:IsVisible() and CurrentDialog:GetDialog( "ok" ) ~= nil then
								CurrentDialog:GetDialog( "ok" ):Click()
								DialogList:GetDialog( "quest_dialog" ):SetVisible(false)
								crafting_step = 2
								DidFindMatch = true;
							end
						-- Otherwise break from the iteration.
						else
							break;
						end
					end
					-- If a match was not found, the quest has to be abandoned.
					if not DidFindMatch then
						DialogList:GetDialog( "quest_dialog/giveup" ):Click()
					end
				end
			end

		-- Close dialogs and move to starting position
		elseif crafting_step == 4 then

			if DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- close dialog screen
				stop_chat();
			elseif DialogList:GetDialog( "tool_making_dialog" ):IsVisible() then -- Crafting screen
				DialogList:GetDialog( "tool_making_dialog" ):SetVisible(false)
			else 
				Player:SetMove( start_location )
				crafting_step = 5
			end
			
		-- Crafting
		elseif crafting_step == 5 then
			if DialogList:GetDialog( "tool_making_dialog" ):IsVisible() then -- craft screen is open
			
				if enable_craft == 0 then -- initially click the correct work order
					local hDialog = DialogList:GetDialog( "tool_making_dialog/making_scroll/making_ext0/making_list0" )
					PlayerInput:Click( hDialog:GetPosition().X + ( 0.5 * hDialog:GetSize().X ), hDialog:GetPosition().Y + 5 )
					enable_craft = 1
				else
				
					-- Check if you have enough materials on you
					if not DialogList:GetDialog( "tool_making_dialog/button_start_all" ):IsEnabled() and enough_materials == 0 then
						Write("Not enough materials/Incorrect starting position")
						Close()
						return
					else
						enough_materials = 1
					end
				
					if DialogList:GetDialog( "tool_making_dialog/button_start_all" ):IsEnabled() then
						DialogList:GetDialog( "tool_making_dialog/button_start_all" ):Click()
					else
						if enable_craft then -- reset script for next crafting iteration
							enable_craft = 0
							enough_materials = 0
							crafting_step = 6
							timer = Time() + 1000
						else
							Write( "Your starting location is not in a crafting area/nor you do not have the required items" )
							Close()
						end
					end
				end
			-- Craft screen has to be opened
			else
				if NPC_name == "Lainita" or NPC_name == "Hestia" then -- Cooking
					PlayerInput:Console("/skill Cooking")
				elseif NPC_name == "Honir" or NPC_name == "Diana" then -- Alchemy
					PlayerInput:Console("/skill Alchemy")
				elseif NPC_name == "Zyakia" or NPC_name == "Daphnis" then -- Tailoring
					PlayerInput:Console("/skill Tailoring")
				elseif NPC_name == "Kinterun" or NPC_name == "Vulcanus" then -- Armorsmithing
					PlayerInput:Console("/skill Armorsmithing")
				elseif NPC_name == "Logi" or NPC_name == "Anteros" then -- Weaponsmithing
					PlayerInput:Console("/skill Weaponsmithing")
				elseif NPC_name == "Lanse" or NPC_name == "Utsida" then -- Handicrafting
					PlayerInput:Console("/skill Handicrafting")
				end
			end
			
		-- Close crafting dialog
		elseif crafting_step == 6 then 
		
			if DialogList:GetDialog( "tool_making_dialog" ):IsVisible() then -- craft screen is open
				DialogList:GetDialog( "tool_making_dialog" ):SetVisible(false)
			else
				crafting_step = 7
			end
			
		-- hand in work order
		elseif crafting_step == 7 then
		
			if not DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- no dialog, talk to npc
				start_chat()
			elseif DialogList:GetDialog( "dlg_dialog/html_view" ):GetHTML() == first_screen then
				DialogList:GetDialog( "dlg_dialog/html_view/2" ):Click()
			elseif DialogList:GetDialog( "dlg_dialog/ok" ):IsVisible() then -- Hand in the work order
				DialogList:GetDialog( "dlg_dialog/ok" ):Click()
				crafting_step = 2 -- Blastradius: No need for Step #0, we can go to Step #2 and avoid dialog bugs.
			else -- second screen is open
				DialogList:GetDialog( "dlg_dialog/html_view/1" ):Click()
			end
			
		end
		
		timer = Time() + click_wait_time

	end
	
end

function start_chat()
	if Player:GetTargetID() == 0 then
		PlayerInput:Escape()
	end

	local Entity = EntityList:GetEntity( NPC_name )
	if Player:GetTargetID() ~= Entity:GetID()  then -- Move to the target NPC
		Player:SetTarget( Entity )
		if not move_via_auto_approach then
			Player:SetMove( Entity:GetPosition())
		end
	else -- start dialog
		PlayerInput:Console( '/attack' )
	end

end	

function stop_chat()

	-- Get the information for the dialog.
	local DlgDialog = DialogList:GetDialog( "dlg_dialog" );
	local DlgPosition = DlgDialog:GetPosition();
	local DlgSize = DlgDialog:GetSize();
	
	-- Get the information for the cancel button. Avoid names, there are two similar named buttons.
	local CnlDialog = DialogList:GetDialog( "dlg_dialog/8" );
	local CnlSize = CnlDialog:GetSize();
	
	-- Calculate the real position on the X- and Y-axis.
	local Real_X = DlgPosition.X + DlgSize.X - ( DlgSize.X / 100 * 4 );
	local Real_Y = DlgPosition.Y + CnlSize.Y - ( CnlSize.Y / 100 * 4 );

	-- Click the button and continue.
	PlayerInput:Click( Real_X, Real_Y );
	
end

function CheckWorkorder()

	local NPCs = {"Lainita", "Honir", "Zyakia", "Kinterun", "Logi", "Lanse", "Diana", "Vulcanus", "Hestia", "Utsida", "Daphnis", "Anteros"}
	local Distance1 = 100
	local Distance2 = 100
	local NPC_name = ""
	
	for ID, Entity in DictionaryIterator( EntityList:GetList()) do
		for i = 1, #NPCs, 1 do
			if Entity:GetName() == NPCs[i] then
				Distance2 = Entity:GetPosition():DistanceToPosition( Player:GetPosition());
				if Distance2 <= Distance1 then
				Write("Setting " .. NPCs[i] );
				Write(Distance2);
					NPC_name = NPCs[i]
					Distance1 = Distance2
				end
			end
		end
	end
	
	-- Visual verification
	if Distance1 == 100 then
		Write("No NPC nearby to do crafting")
		Close()
	else
		Write("NPC found with name " .. NPC_name)
		Write("with distance of " .. Distance1 .. " units")
		
		return NPC_name
	end

end

User avatar
Quirunerk
Posts: 65
Joined: Sun Aug 20, 2017 3:06 pm
Has thanked: 24 times
Been thanked: 1 time

Re: Copy Paste.

Post by Quirunerk » Sun Aug 27, 2017 2:47 pm

it's working THANK YOU

User avatar
Quirunerk
Posts: 65
Joined: Sun Aug 20, 2017 3:06 pm
Has thanked: 24 times
Been thanked: 1 time

Re: Copy Paste.

Post by Quirunerk » Sun Aug 27, 2017 2:55 pm

But its opening system menu why ?

unkn0wnus3r
Posts: 75
Joined: Wed Jan 18, 2017 12:27 pm
Has thanked: 10 times
Been thanked: 13 times

Re: Copy Paste.

Post by unkn0wnus3r » Sun Aug 27, 2017 11:07 pm

Because its pressing esc so that the target gets deselected.
I can fix that if its too anoying^^

User avatar
Quirunerk
Posts: 65
Joined: Sun Aug 20, 2017 3:06 pm
Has thanked: 24 times
Been thanked: 1 time

Re: Copy Paste.

Post by Quirunerk » Mon Aug 28, 2017 12:32 am

its stopping cuz of that esc i think u should change it with f1 (selecting self)

unkn0wnus3r
Posts: 75
Joined: Wed Jan 18, 2017 12:27 pm
Has thanked: 10 times
Been thanked: 13 times

Re: Copy Paste.

Post by unkn0wnus3r » Mon Aug 28, 2017 11:54 am

I made it /attack instead of pressing escape, didnt try it tho

Code: Select all

--[[

	--------------------------------------------------
	Copyright (C) 2011 TheyRot

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
	--------------------------------------------------
	
	--------------------------------------------------
	Material List : https://www.nyerk.xyz/viewtopic.php?f=7&t=121
	--------------------------------------------------

--]]

--- OnLoad is called when the script initially loads.
--
-- @return	void
function OnLoad()
	Write( "Make sure you have sufficient items in your inventory" )
	Write( "Your starting position should be in the crafting area" )
	Write( "Close all work orders in progress before starting" )
	Write( "" )
	Write( "Material List: https://www.nyerk.xyz/viewtopic.php?f=7&t=121")
	
	-- Script settings, never go below 500 milliseconds. Increase for higher latency.
	click_wait_time = 1000			-- Wait time in milliseconds after each click.
	move_via_auto_approach = true	-- Set to true when you want to use auto approach for move to NPC.
	
	-- Script settings, do not touch
	learning = 1 					-- Initially the script needs to learn the htmls
	first_screen = 0				-- First screen html index
	timer = 0						-- Restrict clicking using this timer.
	crafting_step = 0				-- Crafting step
	enable_craft = 0				-- The script determines if the starting position is correct to start crafting
	abandon_workorder = 0;			-- Used to select work order in the journal to close failed work orders
	learned = 0;					-- Check if the screens have been learned
	enough_materials = 0			-- Material check
	
	-- Check which NPC with workorders is closest to you and do the work orders.
    NPC_name = CheckWorkorder()
	
	-- Non-configurable variables, do not touch any of these.
    start_location = Player:GetPosition();	-- Starting position to run to. This HAS to be in the crafting area!
	
end

--- OnRun is called each frame.
--
-- @return	void

function OnRun()
	-- Delay to skip YAY-crafted-an-item-animation
	if DialogList:GetDialog( "making_dialog" ):IsVisible() then
		timer = Time() + 4000 
		return
	end

	if Time() > timer and not Player:IsMoving() then

		if InventoryList:GetSlotCurrent() == InventoryList:GetSlotMaximum() then
			Write("Your inventory is full, aborting script")
			Close()
		end
		
		-- Initial set-up of closing all screens
		if crafting_step == 0 then 
		
			if DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- close dialog screen
				stop_chat();
			elseif DialogList:GetDialog( "tool_making_dialog" ):IsVisible() then -- Crafting screen
				DialogList:GetDialog( "tool_making_dialog" ):SetVisible(false)
			else
				if learned == 0 then
					crafting_step = 1
				else
					crafting_step = 2
				end
			end
			
		-- Learn first screen dialog code
		elseif crafting_step == 1 then
		
			if not DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- no dialog, talk to npc
				start_chat()
			elseif first_screen == 0 then -- Learn the html code of the first screen
				first_screen = DialogList:GetDialog( "dlg_dialog/html_view" ):GetHTML()
				DialogList:GetDialog( "dlg_dialog/html_view/2" ):Click()
			elseif DialogList:GetDialog( "dlg_dialog/accept" ):IsVisible() then -- Accepting quest
				DialogList:GetDialog( "dlg_dialog/accept" ):Click()
				learned = 1
				crafting_step = 4
			elseif DialogList:GetDialog( "dlg_dialog/ok" ):IsVisible() then -- Already have the crafting quest accepted
				stop_chat();
				crafting_step = 3 -- stop the current work order
			else
				DialogList:GetDialog( "dlg_dialog/html_view/1" ):Click()
			end
			
		-- Aquiring the work order
		elseif crafting_step == 2 then 
		
			if not DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- no dialog, talk to npc (trying to make it idiot proof)
				start_chat()
			elseif DialogList:GetDialog( "dlg_dialog/html_view" ):GetHTML() == first_screen then -- First screen is open
				DialogList:GetDialog( "dlg_dialog/html_view/2" ):Click()
			elseif DialogList:GetDialog( "dlg_dialog/accept" ):IsVisible() then -- Accepting quest
				DialogList:GetDialog( "dlg_dialog/accept" ):Click()
				crafting_step = 4 -- go to starting position and close dialogs
			elseif DialogList:GetDialog( "dlg_dialog/ok" ):IsVisible() then -- Already have the crafting quest accepted
				stop_chat();
				crafting_step = 3 -- stop the current work order
			else -- second screen is open
				DialogList:GetDialog( "dlg_dialog/html_view/1" ):Click()
			end
			
		-- Stop the current work order (failed to craft everything)
		elseif crafting_step == 3 then
			
			if not DialogList:GetDialog( "quest_dialog" ):IsVisible() then -- Journal is not opened
				DialogList:GetDialog( "quest_dialog" ):SetVisible(true)
			else -- Journal is open
				if not DialogList:GetDialog( "quest_dialog/1/working_page/task_tab" ):IsVisible() then -- work order is not yet selected
					DialogList:GetDialog( "quest_dialog/quest_tabframe/quest_tab_task" ):Click()
				elseif not DialogList:GetDialog( "quest_dialog/giveup" ):IsEnabled() then -- work order tab is selected, work order is not selected
					local hDialog = DialogList:GetDialog( "quest_dialog/1/working_page/task_tab/working_list/0/1" )
					PlayerInput:Click( hDialog:GetPosition().X + ( 0.5 * hDialog:GetSize().X ), hDialog:GetPosition().Y + 5 )
				else
					local DidFindMatch = false;
					-- Iterate through the dialog to find a non-named confirmation dialog.
					for i = 0, DialogList:GetDialogSize() - 1 do
						-- Retrieve the dialog.
						local CurrentDialog = DialogList:GetDialogIndex( i, false );
						-- Check if the dialog matches expectations.
						if CurrentDialog ~= nil and CurrentDialog:GetName() == "" then
							-- Check if the dialog is visible and the OK button can be clicked.
							if CurrentDialog:IsVisible() and CurrentDialog:GetDialog( "ok" ) ~= nil then
								CurrentDialog:GetDialog( "ok" ):Click()
								DialogList:GetDialog( "quest_dialog" ):SetVisible(false)
								crafting_step = 2
								DidFindMatch = true;
							end
						-- Otherwise break from the iteration.
						else
							break;
						end
					end
					-- If a match was not found, the quest has to be abandoned.
					if not DidFindMatch then
						DialogList:GetDialog( "quest_dialog/giveup" ):Click()
					end
				end
			end

		-- Close dialogs and move to starting position
		elseif crafting_step == 4 then

			if DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- close dialog screen
				stop_chat();
			elseif DialogList:GetDialog( "tool_making_dialog" ):IsVisible() then -- Crafting screen
				DialogList:GetDialog( "tool_making_dialog" ):SetVisible(false)
			else 
				Player:SetMove( start_location )
				crafting_step = 5
			end
			
		-- Crafting
		elseif crafting_step == 5 then
			if DialogList:GetDialog( "tool_making_dialog" ):IsVisible() then -- craft screen is open
			
				if enable_craft == 0 then -- initially click the correct work order
					local hDialog = DialogList:GetDialog( "tool_making_dialog/making_scroll/making_ext0/making_list0" )
					PlayerInput:Click( hDialog:GetPosition().X + ( 0.5 * hDialog:GetSize().X ), hDialog:GetPosition().Y + 5 )
					enable_craft = 1
				else
				
					-- Check if you have enough materials on you
					if not DialogList:GetDialog( "tool_making_dialog/button_start_all" ):IsEnabled() and enough_materials == 0 then
						Write("Not enough materials/Incorrect starting position")
						Close()
						return
					else
						enough_materials = 1
					end
				
					if DialogList:GetDialog( "tool_making_dialog/button_start_all" ):IsEnabled() then
						DialogList:GetDialog( "tool_making_dialog/button_start_all" ):Click()
					else
						if enable_craft then -- reset script for next crafting iteration
							enable_craft = 0
							enough_materials = 0
							crafting_step = 6
							timer = Time() + 1000
						else
							Write( "Your starting location is not in a crafting area/nor you do not have the required items" )
							Close()
						end
					end
				end
			-- Craft screen has to be opened
			else
				if NPC_name == "Lainita" or NPC_name == "Hestia" then -- Cooking
					PlayerInput:Console("/skill Cooking")
				elseif NPC_name == "Honir" or NPC_name == "Diana" then -- Alchemy
					PlayerInput:Console("/skill Alchemy")
				elseif NPC_name == "Zyakia" or NPC_name == "Daphnis" then -- Tailoring
					PlayerInput:Console("/skill Tailoring")
				elseif NPC_name == "Kinterun" or NPC_name == "Vulcanus" then -- Armorsmithing
					PlayerInput:Console("/skill Armorsmithing")
				elseif NPC_name == "Logi" or NPC_name == "Anteros" then -- Weaponsmithing
					PlayerInput:Console("/skill Weaponsmithing")
				elseif NPC_name == "Lanse" or NPC_name == "Utsida" then -- Handicrafting
					PlayerInput:Console("/skill Handicrafting")
				end
			end
			
		-- Close crafting dialog
		elseif crafting_step == 6 then 
		
			if DialogList:GetDialog( "tool_making_dialog" ):IsVisible() then -- craft screen is open
				DialogList:GetDialog( "tool_making_dialog" ):SetVisible(false)
			else
				crafting_step = 7
			end
			
		-- hand in work order
		elseif crafting_step == 7 then
		
			if not DialogList:GetDialog( "dlg_dialog" ):IsVisible() then -- no dialog, talk to npc
				start_chat()
			elseif DialogList:GetDialog( "dlg_dialog/html_view" ):GetHTML() == first_screen then
				DialogList:GetDialog( "dlg_dialog/html_view/2" ):Click()
			elseif DialogList:GetDialog( "dlg_dialog/ok" ):IsVisible() then -- Hand in the work order
				DialogList:GetDialog( "dlg_dialog/ok" ):Click()
				crafting_step = 2 -- Blastradius: No need for Step #0, we can go to Step #2 and avoid dialog bugs.
			else -- second screen is open
				DialogList:GetDialog( "dlg_dialog/html_view/1" ):Click()
			end
			
		end
		
		timer = Time() + click_wait_time

	end
	
end

function start_chat()
	if Player:GetTargetID() == 0 then
--		PlayerInput:Escape()
		PlayerInput:Console( '/attack' )
		
	end

	local Entity = EntityList:GetEntity( NPC_name )
	if Player:GetTargetID() ~= Entity:GetID()  then -- Move to the target NPC
		Player:SetTarget( Entity )
		if not move_via_auto_approach then
			Player:SetMove( Entity:GetPosition())
		end
	else -- start dialog
		PlayerInput:Console( '/attack' )
	end

end	

function stop_chat()

	-- Get the information for the dialog.
	local DlgDialog = DialogList:GetDialog( "dlg_dialog" );
	local DlgPosition = DlgDialog:GetPosition();
	local DlgSize = DlgDialog:GetSize();
	
	-- Get the information for the cancel button. Avoid names, there are two similar named buttons.
	local CnlDialog = DialogList:GetDialog( "dlg_dialog/8" );
	local CnlSize = CnlDialog:GetSize();
	
	-- Calculate the real position on the X- and Y-axis.
	local Real_X = DlgPosition.X + DlgSize.X - ( DlgSize.X / 100 * 4 );
	local Real_Y = DlgPosition.Y + CnlSize.Y - ( CnlSize.Y / 100 * 4 );

	-- Click the button and continue.
	PlayerInput:Click( Real_X, Real_Y );
	
end

function CheckWorkorder()

	local NPCs = {"Lainita", "Honir", "Zyakia", "Kinterun", "Logi", "Lanse", "Diana", "Vulcanus", "Hestia", "Utsida", "Daphnis", "Anteros"}
	local Distance1 = 100
	local Distance2 = 100
	local NPC_name = ""
	
	for ID, Entity in DictionaryIterator( EntityList:GetList()) do
		for i = 1, #NPCs, 1 do
			if Entity:GetName() == NPCs[i] then
				Distance2 = Entity:GetPosition():DistanceToPosition( Player:GetPosition());
				if Distance2 <= Distance1 then
				Write("Setting " .. NPCs[i] );
				Write(Distance2);
					NPC_name = NPCs[i]
					Distance1 = Distance2
				end
			end
		end
	end
	
	-- Visual verification
	if Distance1 == 100 then
		Write("No NPC nearby to do crafting")
		Close()
	else
		Write("NPC found with name " .. NPC_name)
		Write("with distance of " .. Distance1 .. " units")
		
		return NPC_name
	end

end

User avatar
Quirunerk
Posts: 65
Joined: Sun Aug 20, 2017 3:06 pm
Has thanked: 24 times
Been thanked: 1 time

Re: Copy Paste.

Post by Quirunerk » Fri Sep 01, 2017 11:13 am

I'm getting inventory is full aborting script error now :/

User avatar
Diavolakos
Posts: 114
Joined: Thu Apr 20, 2017 5:05 am
Has thanked: 31 times
Been thanked: 13 times

Re: Copy Paste.

Post by Diavolakos » Sat Sep 02, 2017 9:53 am

Quirunerk wrote:
Fri Sep 01, 2017 11:13 am
I'm getting inventory is full aborting script error now :/
I also had this ESC problem so instead I kept it as it is and I lpace and /attack on the next thing it does and it works.

The full inventory thing is an AS error, the ommand that sees the inventory is falwed and it gives wrong data.
I play on NA Server Siel

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest