Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[GW2 UI loader, made by Vadi ]]
- local _sep
- if string.char(getMudletHomeDir():byte()) == "/" then _sep = "/" else _sep = "\\" end
- function GW2_LOAD()
- GW2_LOAD = function () end
- if gw2_path then return end -- don't load already if we are
- local gw2_location = getMudletHomeDir() .. _sep .. "gw2_location"
- gw2_path = "images/" -- location of the images folder with a trailing slash
- local f,msg
- -- first-time launch on profile - no location file
- if not io.open(gw2_path) then
- if not io.open(gw2_location) then
- gw2_path = gw2_whereisit()
- if not gw2_path then return end
- else
- f,msg = io.open(gw2_location, "r+")
- assert(f, msg)
- -- this should give us the folder it's in
- gw2_path = f:read("*all")
- if string.sub(gw2_path, -1) == "/" or string.sub(gw2_path, -1) == [[\]] then
- gw2_path = string.sub(gw2_path, 1, -2)
- end
- -- if we had an invalid path stored
- if not io.open(gw2_path) then
- f = nil -- invalidate handler, so we'll write the new location to disk
- gw2_path = gw2_whereisit()
- if not gw2_path then return end
- end
- end
- end
- -- re-add the suffix that we might have had to strip earlier for lfs.attributes to work on Windows
- if not (string.sub(gw2_path, -1) == "/" or string.sub(gw2_path, -1) == [[\]]) then
- gw2_path = gw2_path .. "/"
- end
- -- update file
- if not f then
- f,msg = io.open(gw2_location, "w")
- if not f then display(msg) return end
- else
- f:seek("set",0)
- end
- f:write(gw2_path)
- f:close()
- end
- -- find the folder
- function gw2_whereisit()
- local path = invokeFileDialog(false, "Where is the GW2 images folder? Select it and click Open")
- if path == "" then return nil else return path .. _sep end
- end
- GW2_LOAD()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement