Page 1 of 1

Lua Scripting problems

Posted: Thu Mar 19, 2020 9:46 am
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!

Re: Lua Scripting problems

Posted: Thu Mar 19, 2020 11:00 am
by Vadi
Did you import it twice by accident? Try searching in the editor for it :)

Re: Lua Scripting problems

Posted: Sun Mar 22, 2020 10:45 am
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.

Re: Lua Scripting problems

Posted: Sun Mar 22, 2020 11:39 am
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 557 times

Re: Lua Scripting problems

Posted: Mon Mar 23, 2020 8:10 am
by Vonlocof
just brings up the one alias.