UserFunction; HW2Path - HWRM/KarosGraveyard Wiki
Finds the path of the Homeword2 folder. Returns nil if nothing is found.
local path = HW2Path() local filename = path..[[data\readthis.lua]] local handle = openfile(filename,"r") local filecontents = read(handle,"*a") closefile(handle)
- Seems a little hard on HW2. It does a DOS command which causes a shell window to open for a second.
- It also might not work on all systems. This was tested on windows98 (dos). I don't know if the format of DOS directory outputs varies across platforms. note: tried the "path" DOS command but it doesn't return the current path for some reason
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
Updated Formatting? Initial
Updated for HWRM? Initial