Homeworld 2 : UserFunctionHW2Path
Karos Graveyard ::
Function Reference :: Scope Reference :: Variable Reference
HW2Path()

Description
Finds the path of the Homeword2 folder. Returns nil if nothing is found.

Example
local path = HW2Path()
local filename = path..[[data\readthis.lua]]
local handle = openfile(filename,"r")
local filecontents = read(handle,"*a")
closefile(handle)

Notes
Declaration

function HW2Path()

	execute("dir > dir.txt")
	local handle = openfile([[dir.txt]],"r")
	local filestring = read(handle,"*a")
	closefile(handle)
	local start_of_string
	local count = 65
	while not start_of_string and count < (65+26) do
		start_of_string = strfind(filestring,strchar(count)..[[:\]])
		count = count + 1
	end
	if start_of_string then
		return strsub(filestring,start_of_string,strfind(filestring,[[\Bin\Release]]))
	end
end

Author

Related Pages:

There are 11 comments on this page. [Display comments]

:: ::