Toribash
Original Post
file.read help
hey guys,
i just made a quick simple little friends list lua program
i was wondering how to use the file.read command and how to read the names of your friends from a .txt file
function Display_Friends(key)
	if (key == string.byte("q")) then
		run_cmd("sa 'friend'")
	end
end

add_hook("key_down", "Friendslist", Display_Friends)
thanks in advance
Nice idea. Here you go. world_builder.lua is a good place to look to see how to do file io. Also the lua reference manual is useful.

function Display_Friends(key)
	if (key == string.byte("q")) then
		file = io.open("friends.txt", "r")
		friend = file:read("*l")
		while friend ~= nil do
			run_cmd("sa "..friend)
			friend = file:read("*l")	
		end
		file:close()
		
		-- sa sets the number of chatlines to 1 for some reason...
		run_cmd("chl 20")
		return 1
	end	
end

add_hook("key_down", "Friendslist", Display_Friends)