FurryEskimo Posted January 27, 2021 Share Posted January 27, 2021 (edited) So I have some experience now with adding and editing content, and thought I'd make a cheap version of the bird trap. To quickly test this I imported the original bird trap code, renamed the prefab file and inside the code (at the bottom), then added the recipe in the modmain file: local cheapbirdtrap = AddRecipe("cheapbirdtrap",{ Ingredient("twigs", 1), Ingredient("cutgrass", 1) }, RECIPETABS.SURVIVAL, TECH.SCIENCE_ONE, nil, nil, nil, nil, "furryeskimo") --Cheap bird trap. The game doesn't crash, but the game doesn't seem to recognize this new code. The recipe is added, but it uses a placeholder image, and attempting to spawn-in the item fails, since the game doesn't recognize the item's name. Any idea what I've missed? cheapbirdtrap.lua Edited January 27, 2021 by FurryEskimo Link to comment https://forums.kleientertainment.com/forums/topic/126483-custom-bird-trap-failing-to-load/ Share on other sites More sharing options...
Combustiblemon Posted January 27, 2021 Share Posted January 27, 2021 (edited) This is really basic one but in case you missed it you'll need to add PrefabFiles = { "cheapbirdtrap" } in your modmain.lua. Edit: And you have to add image and atlas by writing these lines: inst.components.inventoryitem.atlas = "here_comes_atlas" inst.components.inventoryitem.image = "here_comes_image" but I don't know how to set atlas and image for already existing ones... I guess you have to extract inventoryimages and find bird trap and direct that? Edited January 27, 2021 by Combustiblemon 1 Link to comment https://forums.kleientertainment.com/forums/topic/126483-custom-bird-trap-failing-to-load/#findComment-1422151 Share on other sites More sharing options...
FurryEskimo Posted January 27, 2021 Author Share Posted January 27, 2021 (edited) @Combustiblemon Thanks a lot! The item is working now, and just the inventory and crafting images are missing. I've never extracted image files from the base game before. I know it's possible, it can be done with most animations after all. I found an anim file called "birdtrap", maybe that's what I need? Edit: So far I've been unable to find the file location where inventory image files are stored. I could make a version from scratch, I think, but I'd like to find the original. Edited January 27, 2021 by FurryEskimo Link to comment https://forums.kleientertainment.com/forums/topic/126483-custom-bird-trap-failing-to-load/#findComment-1422253 Share on other sites More sharing options...
Combustiblemon Posted January 28, 2021 Share Posted January 28, 2021 inventoryimages.tex has every default items' inventory images, including bird trap. and inventoryimages.xml is like guide book, directing where to where game should find image. <Element v2="0.906005859375" v1="0.875244140625" u2="0.124755859375" u1="0.093994140625" name="birdtrap.tex"/> and this one is directing bird trap. that means you could just use entire .tex file and make .xml and write that line(but this will use unnecessary storage because of tex file have lot of images - it is 5.33MB!), or you have to edit inventoryimages.tex, using TEXtool to decompress tex file, take bird trap from file, make new tex and xml. I'm finding way to use default inventoryimages.tex, but don't think it would work... Link to comment https://forums.kleientertainment.com/forums/topic/126483-custom-bird-trap-failing-to-load/#findComment-1422573 Share on other sites More sharing options...
FurryEskimo Posted January 29, 2021 Author Share Posted January 29, 2021 @Combustiblemon Cool, cool. How do you know the image’s coordinates? Are they listed in another file somewhere? Also, does it list where the mini-map icon is? I haven’t found it in the inventory images file yet. Link to comment https://forums.kleientertainment.com/forums/topic/126483-custom-bird-trap-failing-to-load/#findComment-1423017 Share on other sites More sharing options...
Combustiblemon Posted January 29, 2021 Share Posted January 29, 2021 (edited) I don't know image's coordinates but I found it how to work (at least): 1. You should add original inventoryimages.tex file in (yourmod)/images/inventoryimages folder. 2. And then, make inventoryimages.xml file in same folder, code should be like: <?xml version="1.0"?> <Atlas> <Texture filename="inventoryimages.tex"/> <Elements> <Element v2="0.906005859375" v1="0.875244140625" u2="0.124755859375" u1="0.093994140625" name="birdtrap.tex"/> </Elements> </Atlas> 3. Add assets to your cheapbirdtrap.lua. Asset("IMAGE", "images/inventoryimages/inventoryimages.tex"), Asset("ATLAS", "images/inventoryimages/inventoryimages.xml"), 4. Add codes to your cheapbirdtrap.lua. inst.components.inventoryitem.imagename = "birdtrap" inst.components.inventoryitem.atlasname = "images/inventoryimages/inventoryimages.xml" But still, this need to be entire inventoryimages.tex in your mod, which means your mod will use up an unnecessary storage... I'm finding more better way, although I can't decompress tex file because I have some restrictions now. Nevermind upper all of that. Just add xml and tex files into (yourmod)/images/inventoryimages folder and add these codes in your cheapbirdtrap.lua. local assets = { Asset("IMAGE", "images/inventoryimages/cheapbirdtrap.tex"), Asset("ATLAS", "images/inventoryimages/cheapbirdtrap.xml"), } --------------------------------------------------------------------- inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "cheapbirdtrap" inst.components.inventoryitem.atlasname = "images/inventoryimages/cheapbirdtrap.xml" That's all. Well my modding skills are not so good, so sorry for taking your time. About minimap image - it is in data/minimap folder, but why are you finding this? I'm sure icon will work without changing codes or images. cheapbirdtrap.xml cheapbirdtrap.tex Edited January 29, 2021 by Combustiblemon entirely better solution is made 1 Link to comment https://forums.kleientertainment.com/forums/topic/126483-custom-bird-trap-failing-to-load/#findComment-1423058 Share on other sites More sharing options...
FurryEskimo Posted January 29, 2021 Author Share Posted January 29, 2021 @Combustiblemon Thanks a lot! I'll give these a try once I have time! And I don't mind the extra words, heck, it's an honor to get help from others, and I really appreciate it! Link to comment https://forums.kleientertainment.com/forums/topic/126483-custom-bird-trap-failing-to-load/#findComment-1423120 Share on other sites More sharing options...
FurryEskimo Posted January 30, 2021 Author Share Posted January 30, 2021 (edited) @Combustiblemon Thanks a lot! I just input your code, aaaaaandd,,,, it crashes.. darn.. I also noticed that the item name and description are missing, even though I coded them, but the mini-map image Is there, even though I never programmed it. Edit: To be more clear, the map does not even launch, and the error code does not appear in the server log. I'm simply told the map failed to load, and to try again, but it fails every time. cheapbirdtrap.lua modmain.lua Edited January 30, 2021 by FurryEskimo Link to comment https://forums.kleientertainment.com/forums/topic/126483-custom-bird-trap-failing-to-load/#findComment-1423423 Share on other sites More sharing options...
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