ThaumicParrot Posted July 25, 2015 Share Posted July 25, 2015 Hello! I've been tinkering with my mod so that my character can turn into a wolf. However, I get a crash when starting a new game with Bigby that involves how he transforms, which is by lowering his health to 75.I have no clue as to what went wrong. I've attached the log and my character's prefab. Thanks!bigby.lualog.txt Link to comment Share on other sites More sharing options...
Mobbstar Posted July 26, 2015 Share Posted July 26, 2015 lol that's a simple one: inst.components.health.currenthealth you used the wrong name Link to comment Share on other sites More sharing options...
ThaumicParrot Posted July 26, 2015 Author Share Posted July 26, 2015 @Mobbstar, Wow, What a great coder I am. Thanks for the help! Link to comment Share on other sites More sharing options...
Mobbstar Posted July 26, 2015 Share Posted July 26, 2015 @Mobbstar, Wow, What a great coder I am. Thanks for the help! Link to comment Share on other sites More sharing options...
ThaumicParrot Posted July 27, 2015 Author Share Posted July 27, 2015 @Mobbstar, Hey, I was wondering about another thing: How can I make a character break tools faster? I looked around the forums and found no similar power that I could replicate,and I couldn't find anything about it in the prefabs/components. Link to comment Share on other sites More sharing options...
Mobbstar Posted July 27, 2015 Share Posted July 27, 2015 inst:ListenForEvent("working",BreakTool) with the corresponding function "BreakTool" somewhere above: local BreakTool = function(inst, data)--use data to access the tool--alternatively use the inventory component to access the active itemend Link to comment Share on other sites More sharing options...
ThaumicParrot Posted July 28, 2015 Author Share Posted July 28, 2015 @Mobbstar, I probably did this really stupidly, but why doesn't this work? local BreakTool = function(inst, data) if inst.components.tool and data.percent and data.percent <= 20 and inst.components.inventoryitem and inst.components.inventoryitem.owner then inst.components.inventoryitem.owner:PushEvent("toolbroke", {tool = inst}) end end Link to comment Share on other sites More sharing options...
Mobbstar Posted July 28, 2015 Share Posted July 28, 2015 if inst.components.tool --use data to access the tool--alternatively use the inventory component to access the active item local tool = inst and inst.components.inventory:GetActiveItem() --inst is wilson, we grab the tool using inventory ("inst and" is a hacky way to say "we've got that and... (or else...)" if not tool then return end --we need a tool local per = tool.components.finiteuses and tool.components.finiteuses:GetPercent() if per <= 0.2 then --percent are usually written like that, because 100% is one whole, so 20% is .2 tool.components.finiteuses:SetUses(0)end Link to comment Share on other sites More sharing options...
ThaumicParrot Posted July 28, 2015 Author Share Posted July 28, 2015 @Mobbstar, So I did it like this: local BreakTool = function(inst, data) local tool = inst and inst.components.inventory:GetActiveItem() if not tool then return end local per = tool.components.finiteuses and tool.components.finiteuses:GetPercent() if per <= 0.2 then tool.components.finiteuses:SetUses(0)end end And I can still use tools past 20%. Which part did I do wrong? Link to comment Share on other sites More sharing options...
Mobbstar Posted July 28, 2015 Share Posted July 28, 2015 You did wrong in that you didn't place debug prints print("If the console or log shows this text, that means this code block fired. I can also print variables like so ", inst, tool) Try that, it's always helpful at narrowing the possible problems down. Link to comment Share on other sites More sharing options...
ThaumicParrot Posted July 28, 2015 Author Share Posted July 28, 2015 @Mobbstar, I put in the print in the lua file, and the code did indeed block fire. What does this mean? Link to comment Share on other sites More sharing options...
Mobbstar Posted July 28, 2015 Share Posted July 28, 2015 @Mobbstar, I put in the print in the lua file, and the code did indeed block fire. What does this mean? That means that wherever you put that code, the game went there successfully under those circumstances. For you that means that you can test whether the if-block triggers. When it does, the only fault could be in the line that is meant to break the tool, when it doesn't, the fault is in the test. The fault can even be in the stars, you just oughta study them to fix it. Link to comment Share on other sites More sharing options...
ThaumicParrot Posted July 29, 2015 Author Share Posted July 29, 2015 @Mobbstar, So how would I go about testing the if-block? Link to comment Share on other sites More sharing options...
Mobbstar Posted July 29, 2015 Share Posted July 29, 2015 @Mobbstar, So how would I go about testing the if-block? You... I... Take the thing and put it in the thing and see if it things when you thing. That's an if-block: if [...] then[...]end How would you go about testing it using the print function as shown above? What would you even test it for? (hint: I told you already, try to understaaaaannd! ooohhooooohh!) EDIT Link to comment Share on other sites More sharing options...
ThaumicParrot Posted July 29, 2015 Author Share Posted July 29, 2015 @Mobbstar, I was able to figure the rest out. Thanks for the help! But I have one more problem: When I try to update my mod through DS mod tools it says the api version in the modinfo must be different then the current version, however I have the latest api version in there. What do I do? Link to comment Share on other sites More sharing options...
Mobbstar Posted July 30, 2015 Share Posted July 30, 2015 @Mobbstar, I was able to figure the rest out. Thanks for the help! But I have one more problem: When I try to update my mod through DS mod tools it says the api version in the modinfo must be different then the current version, however I have the latest api version in there. What do I do? The mod's version ( 1.0 -> 1.1 ) is described here. Link to comment Share on other sites More sharing options...
ThaumicParrot Posted July 30, 2015 Author Share Posted July 30, 2015 @Mobbstar, Oh wow, I should've seen that. Thanks for all your help! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.