gibbert Posted June 29, 2024 Share Posted June 29, 2024 I understand that there is currently no official modding support yet, but I just wanted to share and ask some questions surrounding the topic of loading textures and images outside of the game, and hopefully understand more about all this. Can anyone please lend me a hand, I'm kinda lost here So as far as I knowm, and through testing, Rotwood does support loading .PNG textures along with the normal .TEX, like Griftlands, because both game use some similar technologies. A while ago I tried loading .TEX files from mods but it totally didn't work. Just very recently (beta), a new MotD manager system was added, and in that code I found some TheSim functions that handled downloading images from URLs and store them in the game image data, so I messed around with it and found the method to load and use a PNG image from any links, based on how MotD images are fetched, it basically goes like this: TheSim:DownloadMOTDImage(url, file, function(image_results) if image_results then TheSim:LoadMOTDImage(file) -- example of using the downloaded image: -- Image("images/motd_"..file..".png") end end) The images are downloaded from `url`, stored as images/motd_`file`.png and you can load them like any built in textures. There's also TheSim:HasMOTDImage(file) that checks if the specified image file has been cached before so you don't need to download it again. But anyway, using the method above I could show custom images inside the game, provided that I have the URLs for them. But this is clearly not the best way to load outside textures in. So now that I know that the game can load PNGs, I no longer need to worry about converting them to .TEX and all the incompatibility issues that current tools cause, right? So I just tried putting a .PNG in my mod folder and from my modmain created an Image widget using just a filename, let's say it's "slowpoke.png", but there was an issue, it couldn't find the image I provided at all. After a lot of debugging and looking through the scripts, I found a few problems. Firstly, the game couldn't find where my image was because there are a set of search paths that it will go through, and my mod directory was not included. That can be fixed that by adding the mod's directory to package.path for every mod loaded, even the built-in modloader code does that. After doing that, the game could find my file if I made it look for that file name, but there was another issue, it wouldn't bother searching at all when I add an image, because according to GetAtlasTex in util.lua, whenever the game searches for tex and atlas stuff, there's only 1 thing it cares about, if that image is .TEX or not, and it will only resolve the file path if it's a .TEX file. I'm pretty sure that the reason that loading a PNG from the internet worked before (using motd download functions) is because that image is placed inside the game data, so the filename I gave to Image() is already a valid path, there is no need to search for that file anymore. So I modified the GetAtlasTex function to include a PNG condition, to return true for the third value, which is used as checkatlas in the Image widget, if this is true, it will try resolving the path for the given filename. And this worked, it found the correct file, all was good. But still, it didn't work, the path is correct, the widget nor the util functions complained, but no image was shown. Please tell me if I'm missing something here, so far this has been the furthest I can go and it seemed to fail for no apparent reason. Link to comment https://forums.kleientertainment.com/forums/topic/157718-loading-custom-textures-via-modding/ Share on other sites More sharing options...
Hanging Posted June 30, 2024 Share Posted June 30, 2024 I do not think .png can be loaded by the game Link to comment https://forums.kleientertainment.com/forums/topic/157718-loading-custom-textures-via-modding/#findComment-1730787 Share on other sites More sharing options...
gibbert Posted June 30, 2024 Author Share Posted June 30, 2024 36 minutes ago, Hanging said: I do not think .png can be loaded by the game Yes they can, the game also loads MotD images that way. in MainScreen:InitializeMotD(): MotDLayout(self.motd:AddChild(Image("images/motd_"..motd_info.meta.image_file..".png"))) Link to comment https://forums.kleientertainment.com/forums/topic/157718-loading-custom-textures-via-modding/#findComment-1730793 Share on other sites More sharing options...
Hanging Posted June 30, 2024 Share Posted June 30, 2024 5 hours ago, gibberish said: Yes they can, the game also loads MotD images that way. in MainScreen:InitializeMotD(): MotDLayout(self.motd:AddChild(Image("images/motd_"..motd_info.meta.image_file..".png"))) all right, so the system may be incompleted and does not support mod Link to comment https://forums.kleientertainment.com/forums/topic/157718-loading-custom-textures-via-modding/#findComment-1730852 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.