As an example, from my repo:
function readTime(file) local f = io.open(rootDir() .. "TT2/" .. file .. ".txt", "r")
local time = f:read("*n") f:close()
return time end
function writeTime(file) local f = io.open(rootDir() .. "TT2/" .. file .. ".txt", "w") f:write(os.time()) f:close() -- write time to log as well log(file .. " at " .. os.date("%X")) end
writeTime()
will create the file if it doesn't already exist, if it does it will overwrite it. readTime()
will open the file, read the time, and return it. You can read more about the complete i/o model if you're looking for more info.
I've never used LuaStudio before so I'm not sure if it does syntax checking for you but that looks kind of wierd to me. The repeat until block you have doesn't seem in order per the docs.
results = nil; -- set results to nil to enter while loop
while results == nil do results = findColor(0xff0000, 0, {200, 300, 400, 500}); -- set results to autotouch find color
if results ~= nil then -- if results not empty then you've succeeded alert("SUCCESS"); end end -- results no longer nil so you exit the loop
This is something I've just put together but I think the logic works for what you want to accomplish.
To OP: Size doesn't matter. The only way you'd see an issue is if it's in the MB size - and even then, it would just take a few seconds longer to start running the script.
Your issue is most likely a syntax problem - do you have alert/log for errors turned off? If you do, it would do exactly what you're describing. Try turning it on, or toggling it off/on and rerunning it.
Edit: There's many problems with your script. See here - bolded lines = errors.
What do you mean customisation of text? Can you elaborate on it?
If you mean printing results from a getcolor or such, simple example is:
x = 1 y = 40 color = 1678295 toast(string.format("Result: %f, %f \n Color: %f", x,y,color)) usleep(10000000);
To toast result of findcolor is likely
findColor(15527916, 1, {400, 400, 20, 20}) for i, v in pairs(result) do toast(string.format("Found pixel: %f, %f ",v[1], v[2])) usleep(10000000); end
But this useless for any developer I wont bother to test since you should be using log not a visual thing..
This was all in the AutoTouch documentation if you understand lua, obviously aren't familiar with lua yet, so please read Lua 5.2 reference manual and maybe buy "Programming in lua 3".
Edit: I didnt do one for returning color, and pixel locations because its complex and slow as hell + not worth my time writing since its like driving a ferrari encrusted with diamonds
I think is a step in the right direction...but I'm an accountant and not a software engineer.
https://www.lua.org/pil/22.1.html or this http://openrb.com/example-change-timedate-from-lua-script-on-lm2/