Lua Scripting problems

Post Reply
Vonlocof
Posts: 8
Joined: Fri Feb 21, 2020 12:08 am

Lua Scripting problems

Post by Vonlocof »

I am having an issue with a lua script on my machine (ubuntu machine)
when i type the alias "expdalaria" it is making a double return,
e.g.
Setting up a new queue.
n
Waiting 3 seconds.
1

Setting up a new queue.
n
Waiting 3 seconds.
2

It is setting up 2 ques at the same time.

the script i have works perfectly on my windows machine but when importing to settings to linux machine is giving me this weird double up. any help would be great!

User avatar
Vadi
Posts: 4833
Joined: Sat Mar 14, 2009 3:13 pm

Re: Lua Scripting problems

Post by Vadi »

Did you import it twice by accident? Try searching in the editor for it :)

Vonlocof
Posts: 8
Joined: Fri Feb 21, 2020 12:08 am

Re: Lua Scripting problems

Post by Vonlocof »

I cant see anything, it just seems to be sending 2 steps at once? or something bizarre like that.

here is the script.
Code: [show] | [select all] lua
sendQueueTable = sendQueueTable or {}

function sendQueue(...)
	local id
	if arg.n == 1 and type(arg[1]) == "table" then	--Create a new queue
		echo("Setting up a new queue.\n")
		id = #sendQueueTable + 1
		sendQueueTable[id] = {q=arg[1]}	
	elseif arg.n == 2 and sendQueueTable[arg[1]] then
		id = arg[1]
		if arg[2] == "abort" then 
			echo("Aborting this queue.\n")
			table.remove(sendQueueTable, id)
			return id
		elseif arg[2] == "pause" then
			echo("Pausing this queue.\n")
			sendQueueTable[id].paused = true
			return id
		elseif arg[2] == "continue" then
			echo("Continuing this queue.\n")
			sendQueueTable[id].paused = false
		elseif arg[2] == "next" then
			if sendQueueTable[id].paused then
				echo("Paused. Doing nothing.\n")
				return false
			else
				echo("Executing next queue item.\n")
			end
		else
			return false
		end
	elseif type(arg[1]) == "string" then 	--check if this event matches any current queues
		for i,v in ipairs(sendQueueTable) do
			if v.waitingfor == arg[1] then
				sendQueue(i, "next")
			end
		end
	else
		return false
	end

	if sendQueueTable[id].trigger then killTrigger(sendQueueTable[id].trigger) end
	if sendQueueTable[id].timer then killTimer(sendQueueTable[id].timer) end

	if #sendQueueTable[id].q > 0 then			--still have things in the queue
		expandAlias(sendQueueTable[id].q[1])	--execute the current action
		table.remove(sendQueueTable[id].q, 1)	--remove the action from the queue
		if #sendQueueTable[id].q > 0 then		--if I still have more things to do
			if type(sendQueueTable[id].q[1]) == "number" then	--next condition is a timeout
				if sendQueueTable[id].q[1]>0 then
					echo("Waiting "..sendQueueTable[id].q[1].." seconds.\n")
					sendQueueTable[id].timer = tempTimer(sendQueueTable[id].q[1], [[sendQueue(]]..id..[[, "next")]])
					table.remove(sendQueueTable[id].q, 1)
				else
					table.remove(sendQueueTable[id].q, 1)
					sendQueue(id, "next")
				end
			elseif type(sendQueueTable[id].q[1]) == "table" then	--next condition is a trigger
				echo("Waiting for regex pattern: "..sendQueueTable[id].q[1][1].."\n")
				sendQueueTable[id].trigger = tempRegexTrigger(sendQueueTable[id].q[1][1], [[sendQueue(]]..id..[[, "next")]])
				table.remove(sendQueueTable[id].q, 1)
			elseif type(sendQueueTable[id].q[1]) == "string" then	--next condition is an event
				echo("Waiting for event: "..sendQueueTable[id].q[1]..".\n")
				sendQueueTable[id].waitingfor = sendQueueTable[id].q[1]
				table.remove(sendQueueTable[id].q, 1)
			else
				echo("Unknown condition: Executing next action immediately.\n")
				table.remove(sendQueueTable[id].q, 1)
				sendQueue(id, "next")
			end
		else
			echo("Queue completed.\n")
			table.remove(sendQueueTable, id)
		end
	end
	return id
end
it works perfectly fine on my windows machine.. and no double up on folder/files
any help would be great!

Regards.

User avatar
Vadi
Posts: 4833
Joined: Sat Mar 14, 2009 3:13 pm

Re: Lua Scripting problems

Post by Vadi »

Right, did you import it twice by accident? Search for it in the script editor.
Selection_491.png
Selection_491.png (6.69 KiB) Viewed 559 times

Vonlocof
Posts: 8
Joined: Fri Feb 21, 2020 12:08 am

Re: Lua Scripting problems

Post by Vonlocof »

just brings up the one alias.

Post Reply