Folthan Posted December 30, 2014 Share Posted December 30, 2014 Hello everyone, happy to announce I am almost done with my first don't starve character! Took quite some days, tips and research to get this far but I am happy with the result. To finish my character I need 3 more lines of code. Sadly I made this character because I love drawing and designing and not because I am good at coding. I know it's in general rude to ask but could someone enlighten me with 3 lines of components to let me finish my project? Because everyone knows code makes the world more interesting. To be clear, I am looking for lines like this:"inst.components.sanity.night_drain_mult = 0.8" I am looking for:- Increasing sanity loss when it rains- Getting sanity points for clicking koalefant tracks- Getting sanity points (or removing loss of them) for digging up a grave Thanks so much for the trouble. If you know only one of the lines, please reply as well because every bit makes the mod better . Link to comment Share on other sites More sharing options...
Mobbstar Posted December 31, 2014 Share Posted December 31, 2014 well here's the koalefant "line": in modmain.lua (we need to know when a track is found) local function OnInvestigatedNew(inst, doer) local pt = Vector3(inst.Transform:GetWorldPosition()) trace("dirtpile - OnInvestigated", pt) if GetWorld().components.hunter then GetWorld().components.hunter:OnDirtInvestigated(pt) end GetPlayer():PushEvent("tracking") --why didn't they do anything like that in the first place u_u local fx = SpawnPrefab("small_puff") local pos = inst:GetPosition() fx.Transform:SetPosition(pos.x, pos.y, pos.z) --PlayFX(Vector3(inst.Transform:GetWorldPosition()), "small_puff", "smoke_puff_small", "puff", "dontstarve/common/deathpoof", nil, Vector3(216/255, 154/255, 132/255)) inst:Remove()end local function OverrideDirt(inst) inst.components.activatable.OnActivate = OnInvestigatedNewend AddPrefabPostInit("dirtpile",OverrideDirt) in your character file, add this function local function MakeHappy(inst) inst.components.sanity:DoDelta(20) --valueend the line in your character file inst:ListenForEvent("tracking",MakeHappy) Edit: I should say that this is not tested and merely theoretic Link to comment Share on other sites More sharing options...
Folthan Posted January 1, 2015 Author Share Posted January 1, 2015 Wow Mobbstar, I could have never imagined something like that to be that much code! Thanks a lot for taking the time to give me the answer. I put everything in my files and am trying to find a koalefant track now to test it. Link to comment Share on other sites More sharing options...
Folthan Posted January 1, 2015 Author Share Posted January 1, 2015 Made the game crash http://oi61.tinypic.com/mtxz81.jpg Link to comment Share on other sites More sharing options...
Kzisor Posted January 1, 2015 Share Posted January 1, 2015 Made the game crash http://oi61.tinypic.com/mtxz81.jpg @Mobbstar, code was just theoretical, however, it definitely is on the right track. You need to make all the nil variables which are global into global variables by either adding 'GLOBAL.' in front of them or by importing them as global. Example Adding GLOBAL in front:GLOBAL.Vector3 Example importing them as global:Vector3 = GLOBAL.Vector3 Link to comment Share on other sites More sharing options...
Mobbstar Posted January 1, 2015 Share Posted January 1, 2015 Mobbstar's code was just theoretical, however, it definitely is on the right track. You need to make all the nil variables which are global into global variables by either adding 'GLOBAL.' in front of them or by importing them as global. Example Adding GLOBAL in front:GLOBAL.Vector3Example importing them as global:Vector3 = GLOBAL.Vector3 Yes, I forgot about that. The former method must be applied to all functions, the latter just once above the code. Link to comment Share on other sites More sharing options...
Folthan Posted January 2, 2015 Author Share Posted January 2, 2015 Thanks both Mobbstar and Kzisor for the help! However I cannot seem to figure out where to put global in my code. Would you mind being a little more specific for a code noob like me? Now I have: (modmain.lua)-- Tracking skilllocal function OnInvestigatedNew(inst, doer) local pt = Vector3(inst.Transform:GetWorldPosition()) trace("dirtpile - OnInvestigated", pt) if GetWorld().components.hunter then GetWorld().components.hunter:OnDirtInvestigated(pt) end GetPlayer():PushEvent("tracking") local fx = SpawnPrefab("small_puff") local pos = inst:GetPosition() fx.Transform:SetPosition(pos.x, pos.y, pos.z) --PlayFX(Vector3(inst.Transform:GetWorldPosition()), "small_puff", "smoke_puff_small", "puff", "dontstarve/common/deathpoof", nil, Vector3(216/255, 154/255, 132/255)) inst:Remove()endlocal function OverrideDirt(inst) inst.components.activatable.OnActivate = OnInvestigatedNewendAddPrefabPostInit("dirtpile",OverrideDirt) (wolf.lua)local fn = function(inst) -- Tracking skill local function MakeHappy(inst) inst.components.sanity:DoDelta(10) end -- Stats inst:ListenForEvent("tracking",MakeHappy) Link to comment Share on other sites More sharing options...
Kzisor Posted January 2, 2015 Share Posted January 2, 2015 Thanks both Mobbstar and Kzisor for the help! However I cannot seem to figure out where to put global in my code. Would you mind being a little more specific for a code noob like me? Look back at your error log, and notice this specific line. ...pps/common/dont_starve/../mods/Wolf/modmain.lua:30: attempt to call global 'Vector3' (a nil value) This gives you the line number which is 30 and the function which is Vector3. Adding Vector3 = GLOBAL.Vector3 at the very top of your modmain.lua file will fix that error. Rerun your mod to get the next function which needs to be global. The next error you should get will be 2 lines directly below the previous error. ...pps/common/dont_starve/../mods/Wolf/modmain.lua:32: attempt to call global 'GetWorld' (a nil value) Once again at the top of your modmain.lua simply add GetWorld = GLOBAL.GetWorld() I hope this helps you read and understand the error log a little better. Link to comment Share on other sites More sharing options...
Jneiman96 Posted January 2, 2015 Share Posted January 2, 2015 Did you put that where the character traits belong to? (near the end of the character file) Also, med is a lot for a singular chop.yea it did not work i have no idea what to do 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.