Foxrai Posted April 13, 2015 Share Posted April 13, 2015 Hello,I'll try to be short here. There is part of the code: character.lua--Foodlocal eater = inst.components.eatereater:SetCarnivore(true)eater.ignoresspoilage = true changed into:--Foodlocal eater = inst.components.eatereater:SetDiet({ FOODGROUP.OMNI }, { FOODTYPE.MEAT })eater.ignoresspoilage = true and the error it gave me is:71: attempt to call method 'SetDiet' (a nil value) Additional questions: 1. Do I need ROG-enabled checking code or not at all? 2. Are those parts of code in correct lua now? Or that should be changed as well? sorry if that's stupid... And yea, I've read forums about food types, but guess I'm just blind if there was an answer Link to comment Share on other sites More sharing options...
Maris Posted April 13, 2015 Share Posted April 13, 2015 if TUNING.LIGHTNING_GOAT_DAMAGE then--RoG codeelse--non-RoG codeend Link to comment Share on other sites More sharing options...
Foxrai Posted April 14, 2015 Author Share Posted April 14, 2015 if TUNING.LIGHTNING_GOAT_DAMAGE then--RoG codeelse--non-RoG codeend so something like this?--Foodif local eater = inst.components.eater theneater:SetDiet({ FOODGROUP.OMNI }, { FOODTYPE.MEAT })elseeater:SetCarnivore(true)eater.ignoresspoilage = true what about ignoressspoilage? Rewrite under "SetDiet" as well? I guess the 2nd line of the code is wrong -.- ... Link to comment Share on other sites More sharing options...
Maris Posted April 14, 2015 Share Posted April 14, 2015 (edited) local eater = inst.components.eaterif TUNING.LIGHTNING_GOAT_DAMAGE then --RoG code eater:SetDiet({ FOODGROUP.OMNI }, { FOODTYPE.MEAT })else --non-RoG code eater:SetCarnivore(true)endeater.ignoresspoilage = true Edited April 14, 2015 by Maris Link to comment Share on other sites More sharing options...
Foxrai Posted April 15, 2015 Author Share Posted April 15, 2015 if TUNING.LIGHTNING_GOAT_DAMAGE then --RoG code eater:SetDiet({ FOODGROUP.OMNI }, { FOODTYPE.MEAT } Oh.. ok... I'm stupid still.. what does Lightning goat has to do with it? Just an info... O.o Link to comment Share on other sites More sharing options...
DarkXero Posted April 15, 2015 Share Posted April 15, 2015 what does Lightning goat has to do with it? There aren't goats in DST without the RoG branch, so TUNING.LIGHTNING_GOAT_DAMAGE returns nil, which makes the if (nil gets evaluated like false) go to the non-RoG code. With the RoG branch, goats exist, the tuning value exists, a number gets returned, which makes the if (a number gets evaluated to true) go to the RoG code. Link to comment Share on other sites More sharing options...
Foxrai Posted April 15, 2015 Author Share Posted April 15, 2015 There aren't goats in DST without the RoG branch, so TUNING.LIGHTNING_GOAT_DAMAGE returns nil, which makes the if (nil gets evaluated like false) go to the non-RoG code. With the RoG branch, goats exist, the tuning value exists, a number gets returned, which makes the if (a number gets evaluated to true) go to the RoG code Ooo I get it now. Thank you Link to comment Share on other sites More sharing options...
Foxrai Posted April 16, 2015 Author Share Posted April 16, 2015 local eater = inst.components.eater if TUNING.LIGHTNING_GOAT_DAMAGE then --RoG code eater:SetDiet({ FOODGROUP.OMNI }, { FOODTYPE.MEAT }) else --non-RoG code eater:SetCarnivore(true) end eater.ignoresspoilage = true Now error is related to this: 74: function arguments expected near '<'LUA ERROR stack traceback: =[C] in function 'assert' scripts/mainfunctions.lua(92,1) =(tail call) ? where line 74 is:eater:Set<span class="searchlite">Carnivore</span>(true) Link to comment Share on other sites More sharing options...
Corrosive Posted April 16, 2015 Share Posted April 16, 2015 (edited) where line 74 is:eater:Set<span class="searchlite">Carnivore</span>(true)That searchlite <span> element is an artifact introduced by the forums' search feature. You'll need to remove all of that. It should just be SetCarnivore (true). edit: typos, eww Edited April 17, 2015 by Corrosive Link to comment Share on other sites More sharing options...
Maris Posted April 16, 2015 Share Posted April 16, 2015 You should learn at least basics of lua, to understand what are you doing in general. Link to comment Share on other sites More sharing options...
Foxrai Posted April 17, 2015 Author Share Posted April 17, 2015 You should learn at least basics of lua, to understand what are you doing in general. I must say I read tutorials, lua-wikis, guides etc. Still it's NOT my world. maybe you guys won't understand but I'm not the type of person who loves sitting by informatic-rubbish. That's why I'm asking.. And - back to the beginning - element is an artefact introduced by the forums' search feature. You'll need to remove all of that. It should just be SetCarnivore (true). I STARTED from carnivore. But carnivore doesn't work anymore. Link to comment Share on other sites More sharing options...
Maris Posted April 17, 2015 Share Posted April 17, 2015 So you need a partner, co-author, who can code well. Link to comment Share on other sites More sharing options...
Corrosive Posted April 17, 2015 Share Posted April 17, 2015 @Foxrai, I think you completely missed the point of what I was saying =o You said that line 74 of your code was: eater:Set<span class="searchlite">Carnivore</span>(true) That implies that you copy/pasted that code from the forums. There is a bug in the forums in which if you search for a term, the word highlighter tries to highlight words INSIDE of code blocks by inserting an HTML element around the search term. Outside of code blocks, those search term highlighter elements are normally invisible, but since code blocks are inside of a <pre> (pre-formatted text) HTML tag, the <span> HTML element is not treated as HTML, but rather as part of the code. As such, when you copied the code, you also inadvertently copied some HTML that was injected by the search highlighter, which will wreak havoc when it pops up in the middle of actual Lua code. Link to comment Share on other sites More sharing options...
Maris Posted April 17, 2015 Share Posted April 17, 2015 (edited) That's why I said about a partner Edited April 17, 2015 by Maris Link to comment Share on other sites More sharing options...
Foxrai Posted April 18, 2015 Author Share Posted April 18, 2015 (edited) Indeed ._. ow well... non-DST versions kinda went well and working fine... DST is just eww D: too many changes!! and Corrosive - - nothing more to say than: oooooOOO! got it! triple checking next time -.- Edited April 18, 2015 by Foxrai Link to comment Share on other sites More sharing options...
Katzujari Posted April 18, 2015 Share Posted April 18, 2015 Just by suggest.Use a program like notepad ++ when you are cheking code. This program detects what kind of code are you writting and uses colors for mark parts of the same code, as well, it uses color for highlight errors in those codes xD...And if you are the kind of person whoi dont get nothing from programing tutorial, I suggest you to continuing reading codes you are writting, so you will learn what are you writting (like a lenguage )Good luck 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