So I am using LGS to write macro scripts and I am trying to make a script that I can stop without having to run through then entire script. Assume a very, very long script.
Normally, the script would have to execute to completion in complex scripts. I want to make a table with functions in it that I can call them in order but stop execution at will.
--Arbitary code:
TextEditor = {39393, 739937}
SomeString = "A very long novel"
WriteString = function(str)
--Some code to type to a text editor
end
OtherFunction = function(arg1, arg2)
-- do something
end
AnotherFunction = function(arg1, arg2, arg3)
-- do something
end
ReadSomething = function()
-- arbitrary code
end
-- Problem:
Script = {
MoveMouseTo(TextEditor)
WriteString(SomeString)
OtherFunction(arg1, arg2)
AnotherFunction(arg1, arg2, arg3)
ReadSomeString()
}
f = 1
while IsKeyLockOn("scrolllock") && f <= Script.Length() do
Script[f]
f = f + 1
end
In this script it should call each function one at a time until either condition is not true but this doesn't work and I am not sure what I should be doing.
This is the answer: