eniotna308 Posted October 7, 2013 Share Posted October 7, 2013 Hi! I began to work on my own mod. I've figured out a lot by myself but I'll need help to continue. The first thing I wanted to do was to modify the sanity rate under certain circumstances. I looked in Willow's file and took this code and used it to make my character become happy during the winter.local function sanityfn() local i=0 if(GetSeasonManager():GetSeasonString()=="winter") then i=0.2 end i=i+wod:CountFollowers(false)*0.1 return iendlocal fn = function(inst) -- choose which sounds this character will play inst.soundsname = "wolfgang" -- a minimap icon must be specified inst.MiniMapEntity:SetIcon( "wilson.png" ) -- todo: Add an example special power here. inst.components.health:SetMaxHealth(800) --inst.components.leader:CountFollowers(false) inst.components.sanity.custom_rate_fn = sanityfn endThe next thing I want to do is to make him happier if he have more followers.inst.components.leader:CountFollowers(false) This line is giving me my number of followers but I am not able to send it to the function above.I think that my code is executed in the sanity.lua file. So it won't get any parameter and I can't call this line in the function.I hope that you understand what I wanted to do. Is-there any way to get this number from the sanity file? My thanks to anybody who could help me! Link to comment Share on other sites More sharing options...
squeek Posted October 7, 2013 Share Posted October 7, 2013 custom_rate_fn is called with the prefab as the parameter, you just need to catch it in your sanityfn.local function sanityfn( inst ) -- inst is the prefab that the sanity component is added to (in this case, your character) local numfollowers = inst.components.leader:CountFollowers()endBy the way, you don't have to specifically do CountFollowers(false); if you call CountFollowers without a parameter, then the parameter will be "nil" and "not nil" evaluates to true, so it'll work the same way. Link to comment Share on other sites More sharing options...
eniotna308 Posted October 7, 2013 Author Share Posted October 7, 2013 Oh yes! I remember! I did that but I had an error wich is actually corrected and I didn't try again! and the false was in the processus of "omg, the game crash, something is wrong, I'll try to change that or that see if it help" Link to comment Share on other sites More sharing options...
eniotna308 Posted October 7, 2013 Author Share Posted October 7, 2013 Perfect! Thank-you! I just have to test now! 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.