Help with simple code

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
deveyus
Posts: 14
Joined: Tue Dec 14, 2010 10:02 pm

Help with simple code

#1 Post by deveyus » Fri Dec 24, 2010 7:37 am

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();

User avatar
Administrator
Site Admin
Posts: 5333
Joined: Sat Jan 05, 2008 4:21 pm

Re: Help with simple code

#2 Post by Administrator » Fri Dec 24, 2010 11:11 am

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";

deveyus
Posts: 14
Joined: Tue Dec 14, 2010 10:02 pm

Re: Help with simple code

#3 Post by deveyus » Fri Dec 24, 2010 4:59 pm

Because I was learning by using createpath.lua at 7am with no sleep. That's why. Thanks much though!

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 11 guests