Jump to content

Adding a secondary recipe using a Dummy prefab on a Skinnable item


Recommended Posts

Hello everyone,

lately I've been fiddling around with secondary recipes and stuff (a second recipe to an existing item and recipe while keeping the original recipe intact) according to the thread here:

After some messing around and a few frustrating hours I figured out why it wasn't working for me whatsoever: This only works for skinless/unskinned items. To be more precise:

This works for:
1. Items that don't support skins.
2. Items that support skins, but are crafted with the default skin.
 

This doesn't work for:
1. Items that are crafted with a skin. (Official skin that you own on the official item.)

 

In my case I'm trying to add a second recipe to the football helmet like this:

local AllRecipes = GLOBAL.AllRecipes
local RECIPETABS = GLOBAL.RECIPETABS
local STRINGS = GLOBAL.STRINGS
local TECH = GLOBAL.TECH

-----BOOSTER SHOT-----
local footballhat_sortkey = AllRecipes["footballhat"]["sortkey"]

local footballhatr = AddRecipe("footballhatr", {Ingredient("rope", 1), Ingredient("footballhat", 1)}, RECIPETABS.WAR, TECH.SCIENCE_ONE)
footballhatr.product = "footballhat"
footballhatr.image = "footballhat.tex"
footballhatr.sortkey = footballhat_sortkey + 0.1
footballhatr.numtogive = 1
STRINGS.NAMES.FOOTBALLHATR = "Protects your Braincase"
STRINGS.RECIPE_DESC.FOOTBALLHATR = "Protects your Braincase."

(Kinda a repair recipe for now, but is pretty much just a proof of concept.)

image.thumb.png.1cc9672b4f2d57d4f305a45f8cbf8b53.png

Client crashes, dedicated server keeps running perfectly fine. (I'm always testing on a dedicated server, cause that's usually what I'm running, and where usually the most issues arise if any.)

 

I assume it's crashing due to having a second dummy item used in the recipe itself, which isn't configured to have a skin, and therefore fails.

Does anyone have any ideas how I can fix this. (Or tell me what's wrong ofc., if I'm totally mistaken on what happened.)

 

Thanks for reading, and thanks for any help in advance! :wilsconnivingsmile:

Link to comment
Share on other sites

My playercontroller.lua is a bit different from yours, but some time has passed since you made this thread. I can see from the line numbers that it is this line it i crashing on:

local skin_index = skin ~= nil and PREFAB_SKINS_IDS[recipe.name][skin] or nil

Since it uses the name of the recipe to find the skins, instead of the name of the product of the recipe, it fails to find recipe.name in the PREFAB_SKINS_IDS dictionary (which holds lists of IDs for each skinnable item), but the code doesn't check that a list with the key/name is actually in the dictionary, before trying to look up the skin in the list.

@bizziboi Are you guys looking into this? Skinnable items are a real problem. Unless we're missing something here. Would it not make sense for this code to use recipe.product.name instead of recipe.name?

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...