Foxrai Posted February 24, 2015 Share Posted February 24, 2015 Here is the error I encountered today. Note that YESTERDAY (!?) everything was working just fine. None of the files or codes have been changed. Just... suddenly an error came. Seems to be about these in the modmain:if not GLOBAL.TheNet:IsDedicated() then local OldIsRecipeValid = GLOBAL.IsRecipeValid local function IsRecipeValid(recipe) return OldIsRecipeValid(recipe) and ((GLOBAL.ThePlayer and GLOBAL.ThePlayer:HasTag(recipe.name.."_builder")) or not recipe.tagneeded) end GLOBAL.IsRecipeValid = IsRecipeValidend Error from the log: [string "../mods/workshop-389385830/modmain.lua"]:75: variable 'IsRecipeValid' is not declaredLUA ERROR stack traceback: In character I have tag of "something_builder". So the purpouse is to not let other people obtain this recipe (unless thet play the same character of course). So... Question is:Why it just stopped working if it was working just fine?How to fix it and how to avoid it in future? Link to comment Share on other sites More sharing options...
Maris Posted February 24, 2015 Share Posted February 24, 2015 (edited) Show line #75 Btw, try to changelocal function IsRecipeValid(recipe)tofunction IsRecipeValid(recipe)(remove "local") Edited February 24, 2015 by Maris Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted February 24, 2015 Share Posted February 24, 2015 Sorry not quite sure, but I am in the same boat. The last DST patch killed a few mods, while others have not been effected. I believe they moved some Global stuff around / cut some out. Atm I am having problems with Item descriptions being stored in my items prefabs T_T. Its like my custom character name is no longer global to the rest of the mod, only valid in the modmain. Link to comment Share on other sites More sharing options...
Foxrai Posted February 24, 2015 Author Share Posted February 24, 2015 Show line #75 line 75 is: local OldIsRecipeValid = GLOBAL.IsRecipeValid Link to comment Share on other sites More sharing options...
Jjmarco Posted February 24, 2015 Share Posted February 24, 2015 @Foxrai, It seems the original IsRecipeValid got moved in the last update. It's now in widgets/widgetutil.lua.Try adding GLOBAL.require("widgets/widgetutil") in your modmain. Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted February 24, 2015 Share Posted February 24, 2015 (edited) I believe that did the trick. Also recipes renamed the .tagneeded to .builder_tag Edit: Hmm.... still getting an Hastag error tho. I think GLOBAL.ThePlayer:HasTag is the issue. Meh no idea Edited February 24, 2015 by JadeKnightblazer Link to comment Share on other sites More sharing options...
Jjmarco Posted February 24, 2015 Share Posted February 24, 2015 (edited) @JadeKnightblazer, Strange... I tested it and it works fine now.What does the error log say? Edited February 24, 2015 by Jjmarco Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted February 24, 2015 Share Posted February 24, 2015 (edited) calling 'HasTag' on bad self (string expected, got boolean) Now i do add this line of code to my recipes...local sortkey = -110000for k,v in pairs(recipes) do sortkey = sortkey - 1 v.sortkey = sortkey v.builder_tag = true v.atlas = "images/inventoryimages/" .. v.name .. ".xml"endBut now with Recipe class... I don't people need theif not GLOBAL.TheNet:IsDedicated() then local OldIsRecipeValid = GLOBAL.IsRecipeValid local function IsRecipeValid(recipe) return OldIsRecipeValid(recipe) and ((GLOBAL.ThePlayer and GLOBAL.ThePlayer:HasTag(recipe.name.."_builder")) or not recipe.builder_tag) end GLOBAL.IsRecipeValid = IsRecipeValidendanymore because of this?Recipe = Class(function(self, name, ingredients, tab, level, placer, min_spacing, nounlock, numtogive, builder_tag) self.name = name self.placer = placer self.ingredients = ingredients self.product = name self.tab = tab self.atlas = resolvefilepath("images/inventoryimages.xml") self.image = name .. ".tex" self.sortkey = num self.level = level or 0 self.level.ANCIENT = self.level.ANCIENT or 0 self.level.MAGIC = self.level.MAGIC or 0 self.level.SCIENCE = self.level.SCIENCE or 0 self.placer = placer self.min_spacing = min_spacing or 3.2 self.nounlock = nounlock or false self.numtogive = numtogive or 1 self.builder_tag = builder_tag or nil num = num + 1 AllRecipes[name] = selfend)Seems Recipes have gained the parameter to check the if the player has the needed tag? Going to test it. Edited February 24, 2015 by JadeKnightblazer Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted February 24, 2015 Share Posted February 24, 2015 Just changed it to v.builder_tag = v.name.."_builder" Now it works correctly. Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted February 24, 2015 Share Posted February 24, 2015 Last Test: I am correct, with the New Recipe Parameter : builder_tag You no longer need this hackif not GLOBAL.TheNet:IsDedicated() then local OldIsRecipeValid = GLOBAL.IsRecipeValid local function IsRecipeValid(recipe) return OldIsRecipeValid(recipe) and ((GLOBAL.ThePlayer and GLOBAL.ThePlayer:HasTag(recipe.name.."_builder")) or not recipe.builder_tag) end GLOBAL.IsRecipeValid = IsRecipeValidendJust have to make sure custom characters are given the same builder_tag in their character prefab. Link to comment Share on other sites More sharing options...
Jjmarco Posted February 24, 2015 Share Posted February 24, 2015 (edited) @JadeKnightblazer, Indeed, you're right! Overriding IsRecipeValid is no longer necessary. They probably added that in anticipation of the RoG characters they might add at some point. Edit: Actually they are already using it for Wickerbottom's books. Edited February 24, 2015 by Jjmarco Link to comment Share on other sites More sharing options...
Foxrai Posted February 24, 2015 Author Share Posted February 24, 2015 (edited) It seems the original IsRecipeValid got moved in the last update. It's now in widgets/widgetutil.lua. Try adding GLOBAL.require("widgets/widgetutil") in your modmain. Um... So I add it for example after this? local require = GLOBAL.requirelocal STRINGS = GLOBAL.STRINGSlocal Recipe = GLOBAL.Recipelocal RECIPETABS = GLOBAL.RECIPETABSlocal TECH = GLOBAL.TECHlocal resolvefilepath = GLOBAL.resolvefilepathand on the end adding line: (?)GLOBAL.require("widgets/widgetutil") and deleting at all this:if not GLOBAL.TheNet:IsDedicated() then local OldIsRecipeValid = GLOBAL.IsRecipeValid local function IsRecipeValid(recipe) return OldIsRecipeValid(recipe) and ((GLOBAL.ThePlayer and GLOBAL.ThePlayer:HasTag(recipe.name.."_builder")) or not recipe.tagneeded) end GLOBAL.IsRecipeValid = IsRecipeValidend Or what else? Sorry guys I'm kinda clueless if it comes to coding :/ Edited February 24, 2015 by Foxrai Link to comment Share on other sites More sharing options...
Jjmarco Posted February 24, 2015 Share Posted February 24, 2015 (edited) @Foxrai, Just delete all the lines that deal with IsRecipeValid. They're not needed anymore.You don't even need to add require("widgets/widgetutil"). Then, assuming you're using the same code as rezecib, replace v.tagneeded = true with v.builder_tag = v.name.."_builder":local sortkey = -9000for k,v in pairs(recipes) do sortkey = sortkey - 1 v.sortkey = sortkey v.builder_tag = v.name.."_builder"endAlternatively, you could directly specify the tag in the Recipe definition:Recipe(<name>, {<ingredients>}, <tab>, <level>, nil, nil, nil, nil, "<name>_builder") Edited February 24, 2015 by Jjmarco Link to comment Share on other sites More sharing options...
rezecib Posted February 24, 2015 Share Posted February 24, 2015 Yup, confirming here, when they made Willow's lighter craftable they added a buildertag parameter to the Recipe(...) constructor. So that basically provides official support for what I was doing with the IsRecipeValid modification, so that's no longer necessary. What I'm doing in DST RoG Characters right now is just this: Recipe("spidereggsack", {Ingredient("silk", 12), Ingredient("spidergland", 6), Ingredient("papyrus", 6)}, RECIPETABS.TOWN, TECH.NONE, nil, nil, nil, nil, "spiderwhisperer"), Recipe("wathgrithrhat", {Ingredient("goldnugget", 2), Ingredient("rocks", 2)}, RECIPETABS.WAR, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0}, nil, nil, nil, nil, "viking"), Recipe("spear_wathgrithr", {Ingredient("twigs", 2), Ingredient("flint", 2), Ingredient("goldnugget", 2)}, RECIPETABS.WAR, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0}, nil, nil, nil, nil, "viking"),With Wigfrid having the "viking" tag and Webber having the "spiderwhisperer" tag. Link to comment Share on other sites More sharing options...
Foxrai Posted February 24, 2015 Author Share Posted February 24, 2015 (edited) @Foxrai, Just delete all the lines that deal with IsRecipeValid. They're not needed anymore.You don't even need to add require("widgets/widgetutil"). Then, assuming you're using the same code as rezecib, replace v.tagneeded = true with v.builder_tag = v.name.."_builder":local sortkey = -9000for k,v in pairs(recipes) do sortkey = sortkey - 1 v.sortkey = sortkey v.builder_tag = v.name.."_builder"endAlternatively, you could directly specify the tag in the Recipe definition:Recipe(<name>, {<ingredients>}, <tab>, <level>, nil, nil, nil, nil, "<name>_builder") I went the shorter way Worked fine! Thank you guys! All FIXED with: Recipe(<name>, {<ingredients>}, <tab>, <level>, nil, nil, nil, nil, "<name>_builder") Edited February 24, 2015 by Foxrai Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted February 24, 2015 Share Posted February 24, 2015 Correct it is shorter and it allows which items you want to be private quite easily. However I would suggest using a .sortkey, for dedicated server support. Link to comment Share on other sites More sharing options...
Foxrai Posted February 26, 2015 Author Share Posted February 26, 2015 Correct it is shorter and it allows which items you want to be private quite easily. However I would suggest using a .sortkey, for dedicated server support. Sortkeys I'm using are similar to -998231 numbers. Because they have to be hmm.. unique, ye? So they don't argue with any other mod-sortkeys? Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted February 26, 2015 Share Posted February 26, 2015 correct , just like old Minecraft Item / Block ids. Hopefully one day we will get a, GetnextId support for DST. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now