Ceeser Posted December 13, 2019 Share Posted December 13, 2019 (edited) Hey, for a UI lib I want to create textures for all image files included to the resource. So when it starts, it calls the function to load the images, create and store textures for them. My problem is now, how to get all image paths / names? Since the meta.xml doesn't get downloaded, the client file cant open the meta.xml and search for file src's (like i tried in the example). Manually use downloadFile("meta.xml") doesnt work and using the event "onClientFileDownloadComplete" to get the names of downloaded images doesn't work as well. Example: (What ive tried) function loadTextures() local sourceResource = sourceResource or getThisResource(); -- This is if the call comes from another resource to load in the images of that resource local strResourePath = ":" .. getResourceName(sourceResource) .. "/"; local tblImages = loadMetaImages(strResourePath); if (tblImages) then for _, image in pairs(tblImages) do local strName = removeImagePath(image); if (ELIB.textures[strName]) then outputDebugString("@ELIB - loadTextures: Dublicated image name found in" .. strResourePath .. " old image overwritten!", 2); end ELIB.textures[strName] = dxCreateTexture(image, "dxt5", true, "clamp"); end end end function loadMetaImages(strResourePath) local uFile = xmlLoadFile(strResourePath .. "meta.xml"); if (uFile) then local tblImages = {}; for _, node in ipairs(xmlNodeGetChildren(uFile)) do if (xmlNodeGetName(node) == "file") then local strImagePath = xmlNodeGetAttribute(node, "src"); if (string.find(strImagePath, ".png") or string.find(strImagePath, ".jpg") or string.find(strImagePath, ".dds")) then table.insert(tblImages, strImagePath); end end end return tblImages; end end function removeImagePath(strPath) while (string.find(strPath, "/")) do strPath = string.sub(strPath, 2); end end Edited December 13, 2019 by Ceeser Link to comment
JeViCo Posted December 14, 2019 Share Posted December 14, 2019 You can't manage meta.xml file client-side (security reasons) however you can do whatever you want server-side get everything you need server-side, trigger client event to transfer data and use it Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now