Jump to content

Simple repair mod, how do I properly use wildcard?


Recommended Posts

I'm making a simple mod to repair armor using ingots of the same type.  This is my first mod and I'm hoping to refine it and put it out for other people too. Well I'm stuck!

I explored the .json files first and then made my own.  I started with chain body armor.  I want you to be able to take your armor in upper slot, put in ingot of same type in the lower, and get your repaired armor back!

The thing is it won't work unless I hard code the ingot type. I'd rather not have to do that as using the variables with name= is a lot more elegant, but is it possible?

    {
        ingredientPattern: "A    L",
        ingredients: {
            "A": { type: "item", code: "armor-body-chain-*", name: "metal"},
            "L": { type: "item", code: "ingot-{metal}" }
        },
        width: 1,
        height: 2,
        output: { type: "item", code: "armor-body-chain-{metal}", quantity: 1  }
    }
    
]

That's the whole JSON, the error I get is this.

 

16:04:36 [Server Error] Grid Recipe with output Item code game:armor-body-chain-copper contains an ingredient that cannot be resolved: Item code game:ingot-{metal}
16:04:36 [Server Error] Grid Recipe with output Item code game:armor-body-chain-tinbronze contains an ingredient that cannot be resolved: Item code game:ingot-{metal}
16:04:36 [Server Error] Grid Recipe with output Item code game:armor-body-chain-bismuthbronze contains an ingredient that cannot be resolved: Item code game:ingot-{metal}
16:04:36 [Server Error] Grid Recipe with output Item code game:armor-body-chain-blackbronze contains an ingredient that cannot be resolved: Item code game:ingot-{metal}
16:04:36 [Server Error] Grid Recipe with output Item code game:armor-body-chain-iron contains an ingredient that cannot be resolved: Item code game:ingot-{metal}
16:04:36 [Server Error] Grid Recipe with output Item code game:armor-body-chain-meteoriciron contains an ingredient that cannot be resolved: Item code game:ingot-{metal}
16:04:36 [Server Error] Grid Recipe with output Item code game:armor-body-chain-steel contains an ingredient that cannot be resolved: Item code game:ingot-{metal}
16:04:36 [Server Error] Grid Recipe with output Item code game:armor-body-chain-gold contains an ingredient that cannot be resolved: Item code game:ingot-{metal}
16:04:36 [Server Error] Grid Recipe with output Item code game:armor-body-chain-silver contains an ingredient that cannot be resolved: Item code game:ingot-{metal}


So it is definitely storing the text at the wildcard in "metal" but .. then can only fetch it for the output.

I've tried hard-coding the ingot type, ex ingot-tinbronze and it works. But why doesn't this?

 

Thank you!

 

Link to comment
Share on other sites

Thank you to everyone for the help. Shout out to Tels on the Discord that let me know that you can't use name: identifier for the other ingredients, only in the output.

Still struggling though.

I think I may have encountered some kind of bug though I do admit I am using the crafting system in a way not currently in game.

I stripped it all down as if I was going to type out each one by hand and got an interesting result, here's the .json in its entirety:

[
	{
		ingredientPattern: "A	L",
		ingredients: {
			"A": { type: "item", code: "game:armor-body-chain-copper"},
			"L": { type: "item", code: "game:metalchain-copper"}
		},
		width: 1,
		height: 2,
		output: { type: "item", code: "game:armor-body-chain-copper"  }
	
	}
]

 

No server errors when this is loaded but something bizarre happens. I'd expect the recipe to consume the two items above and then hand back a new item defined by output.

Something weird happens. I let a drifter hit my armor to see what would happen and then tried my recipe and the output chain was not a new item, but was the same item

with 32 durability added.  What in the world.

There is one mod for repairing armor up on the mod database called ArmorRepair by Asraiel.  I tested this mod and got the same result. His .json files look good but produce the same effect. 

So far the only way I've found to get a new chain is to use the returnedStack option to return a new chain mail. This does actually create a new chain mail item with full durability.

Of course I need an output to make a valid recipe. For a quick hack I can make this create a dirt block or something, and that's fine for me and my friends... but not something I'd package as a mod for the community!

Anyone know what could be going on here, or how I could force the crafting system to give me a new item as an output?

I know C# so I'll see about setting up a proper dev environment and seeing if I can find what is wrong... but I don't think all the code of the game is exposed like that.

Edit: It is totally there to look at. My hypothesis is they want to make sure if you use items with lower durability in crafting, you get lower durability items back.  Time for some coffee and some browsing. I'm impressed at the openness of this game. 

 

 

 

2021-10-12_19-43-56.png

2021-10-12_19-43-58.png

Edited by BluePsion Gamer
  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.