Jump to content

Problem with craftable item mod


Recommended Posts

Hi, I recently made a mod that adds Tam o' Shanter as a craftable item but I ran into some problems.

So this is my code (modmain):

STRINGS = GLOBAL.STRINGS
RECIPETABS = GLOBAL.RECIPETABS
Recipe = GLOBAL.Recipe
Ingredient = GLOBAL.Ingredient
TECH = GLOBAL.TECH

STRINGS.RECIPE_DESC.WALRUSHAT = "Sadly not accompanied by a manly skirt."

local ingredients = {
    Ingredient("silk", GetModConfigData("webs"))
}

if GetModConfigData("wool") > 0 then
    ingredients[2] = Ingredient("beefalowool", GetModConfigData("wool"))
    end
if GetModConfigData("fur") > 0 then
    ingredients[3] = Ingredient("bearger_fur", GetModConfigData("fur"))
    end
if GetModConfigData("tuft") > 0 then
    ingredients[4] = Ingredient("furtuft", GetModConfigData("tuft"))
    end
if GetModConfigData("tooth") > 0 then
    ingredients[5] = Ingredient("houndstooth", GetModConfigData("tooth"))
    end
    
Recipe("walrushat", ingredients, RECIPETABS.DRESS, TECH.SCIENCE_TWO)

This works fine, but only as a host. As soon as someone joins a server with my mod their hunger is set to a semi-random high number (one time it was 5k, another time 25k) and the UI for both health and sanity does not update. Also, colors were all dark like when you're dead or insane.

I ended up reducing my code to this (taking code from another working mod):

STRINGS = GLOBAL.STRINGS
RECIPETABS = GLOBAL.RECIPETABS
Recipe = GLOBAL.Recipe
Ingredient = GLOBAL.Ingredient
TECH = GLOBAL.TECH

Recipe( "gears", { Ingredient("cutstone", 4), Ingredient("twigs", 6), Ingredient("goldnugget", 4), Ingredient("flint", 6) }, RECIPETABS.REFINE, TECH.SCIENCE_TWO )

This one worked great, but once I replaced "gears" with "walrushat" it stopped working again. I tried changing that to "silk" instead just to see what would happen and it ended up also causing issues, only this time all stats were set to 100 (Still not updating UI but normal colors this time). Am I missing something here? They're all correct names, right? So why is this happening? And with so odd results, as well...

Edited by Treezzy
Link to comment
Share on other sites

@Treezzy, welcome to the forums.

The symptoms described happen when there are network synchronization issues.

Does you mod have all_clients_require_mod = true in modinfo? A recipe has to be added both on the server and the client, as its existence creates net_vars for a player, and net_vars have to be paired for network synchonization to work correctly.

Also in DST it's recommended to use AddRecipe instead of Recipe.

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