Page 1 of 1

Help with simple code

Posted: Fri Dec 24, 2010 7:37 am
by deveyus
I seem to be failing at making a very simple piece of code work. It seems that it just causes the bot to hang, but I don't know enough to know what I'm doing wrong as I'm operating by example.

Code: Select all

	filename = getExecutionPath() .. "/logs/" .. io.stdin:read() .. ".txt";
	toFileLine ="Harvested: %s, %d \n", arg1.X, arg1.Z;
	file, err = io.open(filename, "w");
	file:write(toFileLine);
	file:close();

Re: Help with simple code

Posted: Fri Dec 24, 2010 11:11 am
by Administrator
Probably because you're telling it to wait for user input (io.stdin:read()). I don't know why you would ever possibly want to ask the user for the filename every time it attempts to harvest something. Get rid of that and just replace it with:

Code: Select all

filename = getExecutionPath() .. "/logs/harvest.txt";

Re: Help with simple code

Posted: Fri Dec 24, 2010 4:59 pm
by deveyus
Because I was learning by using createpath.lua at 7am with no sleep. That's why. Thanks much though!