Jump to content

Custom Bird Trap failing to load


Recommended Posts

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 by FurryEskimo
Link to comment
Share on other sites

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 by Combustiblemon
  • Like 1
Link to comment
Share on other sites

@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 by FurryEskimo
Link to comment
Share on other sites

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
Share on other sites

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 by Combustiblemon
entirely better solution is made
  • Health 1
Link to comment
Share on other sites

@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 by FurryEskimo
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...