Jump to content

[Help] Custom Containers


Recommended Posts

So I have mod which adds more chests (same as normal chest just different look). It seems to work for hosts but clients crash with this error:

39fd160d9b0233cbbf7ac6bdead206fb.png

 

The code involving the widget(It's at the bottom):

 

PrefabFiles ={"chestsigns",}Assets ={Asset( "IMAGE", "minimap/chestsigns.tex" ),Asset( "ATLAS", "minimap/chestsigns.xml" ),}AddMinimapAtlas("minimap/chestsigns.xml")STRINGS = GLOBAL.STRINGSRECIPETABS = GLOBAL.RECIPETABSRecipe = GLOBAL.RecipeIngredient = GLOBAL.IngredientTECH = GLOBAL.TECH--V1.0GLOBAL.STRINGS.NAMES.FOODCHEST = "Food Chest"GLOBAL.STRINGS.NAMES.JUNKCHEST = "Junk Chest"GLOBAL.STRINGS.NAMES.NATURALCHEST = "Farm Chest"GLOBAL.STRINGS.NAMES.ORECHEST = "Ore Chest"GLOBAL.STRINGS.NAMES.RANDOMCHEST = "Random Chest"GLOBAL.STRINGS.NAMES.WOODCHEST = "Wood Chest"--V1.1GLOBAL.STRINGS.NAMES.CLOTHESCHEST = "Clothes Chest"GLOBAL.STRINGS.NAMES.COMBATCHEST = "Combat Chest"GLOBAL.STRINGS.NAMES.FARMCHEST = "Farm Chest"GLOBAL.STRINGS.NAMES.GEMCHEST = "Gem Chest"GLOBAL.STRINGS.NAMES.MAGICCHEST = "Magic Chest"GLOBAL.STRINGS.NAMES.TOOLCHEST = "Tool Chest"--V1.3(Characters)GLOBAL.STRINGS.NAMES.WAXWELLCHEST = "Maxwell's Chest"GLOBAL.STRINGS.NAMES.WENDYCHEST = "Wendy's Chest"GLOBAL.STRINGS.NAMES.WESCHEST = "Wes's Chest"GLOBAL.STRINGS.NAMES.WICKERBOTTOMCHEST = "Wickerbottom's Chest"GLOBAL.STRINGS.NAMES.WILLOWCHEST = "Willow's Chest"GLOBAL.STRINGS.NAMES.WILSONCHEST = "Wilson's Chest"GLOBAL.STRINGS.NAMES.WOLFGANGCHEST = "Wolfgang's Chest"GLOBAL.STRINGS.NAMES.WOODIECHEST = "Woodie's Chest"GLOBAL.STRINGS.NAMES.WX78CHEST = "WX-78's Chest"--V1.4(RoG Characters)GLOBAL.STRINGS.NAMES.WEBBERCHEST = "Webber's Chest"GLOBAL.STRINGS.NAMES.WIGFRIDCHEST = "Wigfrid's Chest"--V1.0STRINGS.RECIPE_DESC.FOODCHEST = "A Chest with a Food Sign on it."STRINGS.RECIPE_DESC.JUNKCHEST = "A Chest with a Poop Sign on it."STRINGS.RECIPE_DESC.NATURALCHEST = "A Chest with a Grass and Twigs Sign on it."STRINGS.RECIPE_DESC.ORECHEST = "A Chest with a Gold Nugget on it."STRINGS.RECIPE_DESC.RANDOMCHEST = "A Chest with a Backpack on it."STRINGS.RECIPE_DESC.WOODCHEST = "A Chest with a Log on it."STRINGS.RECIPE_DESC.SKULLCHEST = "A Skull Chest for all your spooky needs!"STRINGS.RECIPE_DESC.PANDORASCHEST = "A Ornate Chest for all your fancy needs!"--V1.1STRINGS.RECIPE_DESC.CLOTHESCHEST = "A Chest with a Hat Sign on it."STRINGS.RECIPE_DESC.COMBATCHEST = "A Chest with a Weapons Sign on it."STRINGS.RECIPE_DESC.FARMCHEST = "A Chest with a Farm Sign on it."STRINGS.RECIPE_DESC.GEMCHEST = "A Chest with a Gem Sign on it."STRINGS.RECIPE_DESC.MAGICCHEST = "A Chest with a Magic Skull Sign on it."STRINGS.RECIPE_DESC.TOOLCHEST = "A Chest with a Tools Sign on it."--V1.3(Characters)STRINGS.RECIPE_DESC.WAXWELLCHEST = "A Chest with Maxwell's Head on it."STRINGS.RECIPE_DESC.WENDYCHEST = "A Chest with Wendy's Head on it."STRINGS.RECIPE_DESC.WESCHEST = "A Chest with Wes's Head on it."STRINGS.RECIPE_DESC.WICKERBOTTOMCHEST = "A Chest with Wickerbottom's Head on it."STRINGS.RECIPE_DESC.WILLOWCHEST = "A Chest with Willow's Head on it."STRINGS.RECIPE_DESC.WILSONCHEST = "A Chest with Wilson's Head on it."STRINGS.RECIPE_DESC.WOLFGANGCHEST = "A Chest with Wolfgang's Head on it."STRINGS.RECIPE_DESC.WOODIECHEST = "A Chest with Woodie's Head on it."STRINGS.RECIPE_DESC.WX78CHEST = "A Chest with WX-78's Head on it."--V1.4(RoG Characters)STRINGS.RECIPE_DESC.WEBBERCHEST = "A Chest with Webber's Head on it."STRINGS.RECIPE_DESC.WIGFRIDCHEST = "A Chest with Wigfrid's Head on it."--V1.0GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.FOODCHEST = "Good for Storing Food/Monster Drops.(Doesn't Reduce Spoilage)"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.JUNKCHEST = "Good for Storing Junk."GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.NATURALCHEST = "Good for Storing Naturally Gathered Resources."GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.ORECHEST = "Good for storing Mined Minerals and Gems."GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.RANDOMCHEST = "Good for Storing Loot/Random Items."GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.WOODCHEST = "Good for Storing Wood-related Items."--V1.1GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.CLOTHESCHEST = "Good for Storing Fancy Clothes."GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.COMBATCHEST = "Good for Storing your Weapons and Armour."GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.FARMCHEST = "Good for Storing your Farming-related Items."GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.GEMCHEST = "Good for Storing your truely truely outrageous Gems." --League of Legends Reference(Taric)GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.MAGICCHEST = "Good for Storing your magical Items."GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.TOOLCHEST = "Handy for Storing your Tools."--V1.3(Characters)GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.WAXWELLCHEST = "Good for a Maxwell who wants a Personal Chest.(Still Useable by others)"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.WENDYCHEST = "Good for a Wendy who wants a Personal Chest.(Still Useable by others)"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.WESCHEST = "Good for a Wes who wants a Personal Chest.(Still Useable by others)"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.WICKERBOTTOMCHEST = "Good for a Wickerbottom who wants a Personal Chest.(Still Useable by others)"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.WILLOWCHEST = "Good for a Willow who wants a Personal Chest.(Still Useable by others)"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.WILSONCHEST = "Good for a Wilson who wants a Personal Chest.(Still Useable by others)"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.WOLFGANGCHEST = "Good for a Wolfgang who wants a Personal Chest.(Still Useable by others)"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.WOODIECHEST = "Good for a Woodie who wants a Personal Chest.(Still Useable by others)"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.WX78CHEST = "Good for a WX-78 who wants a Personal Chest.(Still Useable by others)"--V1.4(RoG Characters)GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.WEBBERCHEST = "Good for a Webber who wants a Personal Chest.(Still Useable by others)"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.WIGFRIDCHEST = "Good for a Wigfrid who wants a Personal Chest.(Still Useable by others)"--V1.0 Chestslocal foodchestrecipe = GLOBAL.Recipe("foodchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "foodchest_placer" )    local junkchestrecipe = GLOBAL.Recipe("junkchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "junkchest_placer" )    local naturalchestrecipe = GLOBAL.Recipe("naturalchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "naturalchest_placer" )    local orechestrecipe = GLOBAL.Recipe("orechest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "orechest_placer" )    local randomchestrecipe = GLOBAL.Recipe("randomchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "randomchest_placer" )    local woodchestrecipe = GLOBAL.Recipe("woodchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "woodchest_placer" )    --V1.1 Chestslocal clotheschestrecipe = GLOBAL.Recipe("clotheschest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "clotheschest_placer" )local combatchestrecipe = GLOBAL.Recipe("combatchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "combatchest_placer" )    local farmchestrecipe = GLOBAL.Recipe("farmchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "farmchest_placer" )    local gemchestrecipe = GLOBAL.Recipe("gemchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "gemchest_placer" )    local magicchestrecipe = GLOBAL.Recipe("magicchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "magicchest_placer" )    local toolchestrecipe = GLOBAL.Recipe("toolchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "toolchest_placer" )    --V1.3 Chests(Characters)local waxwellchestrecipe = GLOBAL.Recipe("waxwellchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "waxwellchest_placer" )    local wendychestrecipe = GLOBAL.Recipe("wendychest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "wendychest_placer" )    local weschestrecipe = GLOBAL.Recipe("weschest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "weschest_placer" )    local wickerbottomchestrecipe = GLOBAL.Recipe("wickerbottomchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "wickerbottomchest_placer" )    local willowchestrecipe = GLOBAL.Recipe("willowchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "willowchest_placer" )    local wilsonchestrecipe = GLOBAL.Recipe("wilsonchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "wilsonchest_placer" )    local wolfgangchestrecipe = GLOBAL.Recipe("wolfgangchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "wolfgangchest_placer" )    local woodiechestrecipe = GLOBAL.Recipe("woodiechest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "woodiechest_placer" )    local wx78chestrecipe = GLOBAL.Recipe("wx78chest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "wx78chest_placer" )--V1.4 Chests(RoG Characters)local webberchestrecipe = GLOBAL.Recipe("webberchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "webberchest_placer" )    local wigfridchestrecipe = GLOBAL.Recipe("wigfridchest",    {    Ingredient("boards", 3),    Ingredient("petals", 2)    },                           RECIPETABS.TOWN, TECH.SCIENCE_ONE, "wigfridchest_placer" )    --V1.0 Extra Chests    local skullchestrecipe = GLOBAL.Recipe("skullchest",    {    Ingredient("boards", 3),    Ingredient("ash", 5),    Ingredient("houndstooth", 1)    },                           RECIPETABS.TOWN, TECH.SCIENCE_TWO, "skullchest_placer" )    local pandoraschestrecipe = GLOBAL.Recipe("pandoraschest",    {    Ingredient("boards", 3),    Ingredient("nitre", 5),    Ingredient("goldnugget", 5)    },                           RECIPETABS.ANCIENT, TECH.SCIENCE_TWO, "pandoraschest_placer" )--V1.0     foodchestrecipe.atlas = "minimap/chestsigns.xml"     junkchestrecipe.atlas = "minimap/chestsigns.xml"     naturalchestrecipe.atlas = "minimap/chestsigns.xml"     orechestrecipe.atlas = "minimap/chestsigns.xml"     randomchestrecipe.atlas = "minimap/chestsigns.xml"     woodchestrecipe.atlas = "minimap/chestsigns.xml"     skullchestrecipe.atlas = "minimap/chestsigns.xml"     pandoraschestrecipe.atlas = "minimap/chestsigns.xml"--V1.1    clotheschestrecipe.atlas = "minimap/chestsigns.xml"    combatchestrecipe.atlas = "minimap/chestsigns.xml"    farmchestrecipe.atlas = "minimap/chestsigns.xml"    gemchestrecipe.atlas = "minimap/chestsigns.xml"    magicchestrecipe.atlas = "minimap/chestsigns.xml"    toolchestrecipe.atlas = "minimap/chestsigns.xml"--V1.3(Characters)    waxwellchestrecipe.atlas = "minimap/chestsigns.xml"    wendychestrecipe.atlas = "minimap/chestsigns.xml"    weschestrecipe.atlas = "minimap/chestsigns.xml"    wickerbottomchestrecipe.atlas = "minimap/chestsigns.xml"    willowchestrecipe.atlas = "minimap/chestsigns.xml"    wilsonchestrecipe.atlas = "minimap/chestsigns.xml"    wolfgangchestrecipe.atlas = "minimap/chestsigns.xml"    woodiechestrecipe.atlas = "minimap/chestsigns.xml"    wx78chestrecipe.atlas = "minimap/chestsigns.xml"--V1.4(RoG Characters)    webberchestrecipe.atlas = "minimap/chestsigns.xml"    wigfridchestrecipe.atlas = "minimap/chestsigns.xml"local containers = GLOBAL.require("containers")local oldwidgetsetup = containers.widgetsetupcontainers.widgetsetup = function(container, prefab)oldwidgetsetup(container, prefab)end

This mod was done a long time ago, so I'm not sure if anything changed or if it always had this issue. I'm just trying to fix it so I don't keep getting comments to fix it. :(

Link to comment
Share on other sites

Looking into DST Signed-Chests, my first thought would be it's because core file scripts/containers.lua is being overwritten by the mod and the mod's version is outdated.

 

I updated the mod to remove the big chest that made the overwritting of containers.lua, so that file is no longer is in the mod. What do you mean by the mod's version being outdated?

Link to comment
Share on other sites

I updated the mod to remove the big chest that made the overwritting of containers.lua, so that file is no longer is in the mod. What do you mean by the mod's version being outdated?

My bad, I looked into older version of the mod and didn't check if there was newer version published.

Edit: The function containers.widgetsetup has different number of parameters:

containers.lua:

function containers.widgetsetup(container, prefab, data)
modmain.lua:

containers.widgetsetup = function(container, prefab)
Edited by Muche
Link to comment
Share on other sites

My bad, I looked into older version of the mod and didn't check if there was newer version published.

Edit: The function containers.widgetsetup has different number of parameters:

containers.lua:

function containers.widgetsetup(container, prefab, data)
modmain.lua:

containers.widgetsetup = function(container, prefab)
local containers = GLOBAL.require("containers")local oldwidgetsetup = containers.widgetsetupcontainers.widgetsetup = function(container, prefab, data)oldwidgetsetup(container, prefab, data)end

So I changed the end part to have data in the 3rd and 4th line, but apparently it still gives the same error? :(

I don't get why only clients crash..

Edited by Aquaterion
Link to comment
Share on other sites

This piece of code

local containers = GLOBAL.require("containers")local oldwidgetsetup = containers.widgetsetupcontainers.widgetsetup = function(container, prefab)	oldwidgetsetup(container, prefab)end

is completely redundant.

 

 

Clients construct container widgets doing this

containers.widgetsetup(self)

in container_replica.

 

Therefore, they look for the widget referenced as, for example, foodchest, when opening a foodchest.

foodchest widget doesn't exist, only treasurechest does (which you say you use).

local containers = GLOBAL.require("containers")local oldwidgetsetup = containers.widgetsetuplocal MyChests = {	foodchest = "treasurechest",	junkchest = "treasurechest",	naturalchest = "treasurechest",	orechest = "treasurechest",	randomchest = "treasurechest",	woodchest = "treasurechest",	clotheschest = "treasurechest",}containers.widgetsetup = function(container, prefab, data)	prefab = MyChests[prefab or container.inst.prefab] or prefab	oldwidgetsetup(container, prefab, data)end

This way you make them look up the treasurechest widget.

 

And in the future you can reference widgets like "dragonflychest" too.

Link to comment
Share on other sites

This piece of code

local containers = GLOBAL.require("containers")local oldwidgetsetup = containers.widgetsetupcontainers.widgetsetup = function(container, prefab)	oldwidgetsetup(container, prefab)end

is completely redundant.

 

 

Clients construct container widgets doing this

containers.widgetsetup(self)

in container_replica.

 

Therefore, they look for the widget referenced as, for example, foodchest, when opening a foodchest.

foodchest widget doesn't exist, only treasurechest does (which you say you use).

local containers = GLOBAL.require("containers")local oldwidgetsetup = containers.widgetsetuplocal MyChests = {	foodchest = "treasurechest",	junkchest = "treasurechest",	naturalchest = "treasurechest",	orechest = "treasurechest",	randomchest = "treasurechest",	woodchest = "treasurechest",	clotheschest = "treasurechest",}containers.widgetsetup = function(container, prefab, data)	prefab = MyChests[prefab or container.inst.prefab] or prefab	oldwidgetsetup(container, prefab, data)end

This way you make them look up the treasurechest widget.

 

And in the future you can reference widgets like "dragonflychest" too.

 

Ahh I get it, i'll try it out when I can find someone to test it with me.. So if i'm understanding correctly, if they're all using treasurechest, i could do this yea?

oldwidgetsetup(container, "treasurechest", data)
Link to comment
Share on other sites

i could do this yea?

 

You mean

containers.widgetsetup = function(container, prefab, data)    oldwidgetsetup(container, "treasurechest", data)end

?

 

Try doing it and tell your friend to use a backpack.

 

Even better, YOU do it, and use a backpack.

Edited by DarkXero
Link to comment
Share on other sites

You mean

containers.widgetsetup = function(container, prefab, data)    oldwidgetsetup(container, "treasurechest", data)end

?

 

Try doing it and tell your friend to use a backpack.

 

Even better, YOU do it, and use a backpack.

A backpack? why? o-o. And I don't think I'm gonna change it, it was more for understanding how it worked.

 

Link to comment
Share on other sites

A backpack? why? o-o. And I don't think I'm gonna change it, it was more for understanding how it worked.

 

I just told you that

containers.widgetsetup(self)

gets called client side to establish the widget the item will get and you will see.

 

If you turn it into

containers.widgetsetup = function(container, prefab, data)    oldwidgetsetup(container, "treasurechest", data)end

then ALL CONTAINER WIDGETS will turn into the treasurechest one.

 

You don't want that.

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