AkaiNight Posted August 1, 2017 Share Posted August 1, 2017 Well i cut it short. If it's posiible to make custom stats like health or hunger or sanity? And also if it's possible to make them shown up under health bar? (forgive my english it's not my main language.) there is what i want to do first one soulholder for every kill captures 1 soul and the second one for tools when cut a tree or mine a thing or hammer a thing or razor a thing shovel a thing or pick a ground 1 points up and the third one for catch bugs or fish for every catch 1 points up or everytime you use pen of phoenix (my custom item) 1 points up thanks for helping and forgive my english. Link to comment Share on other sites More sharing options...
RedHairedHero Posted August 1, 2017 Share Posted August 1, 2017 6 minutes ago, AkaiNight said: Well i cut it short. If it's posiible to make custom stats like health or hunger or sanity? And also if it's possible to make them shown up under health bar? (forgive my english it's not my main language.) there is what i want to do first one soulholder for every kill captures 1 soul and the second one for tools when cut a tree or mine a thing or hammer a thing or razor a thing shovel a thing or pick a ground 1 points up and the third one for catch bugs or fish for every catch 1 points up or everytime you use pen of phoenix (my custom item) 1 points up thanks for helping and forgive my english. I'm personally going to be working on this myself in the near future for my own character. The thing you're referring too is called a widget. Unfortunately I don't have anymore details then that at the moment since I have to research it. But I should be able to help out with you making a counter for the actions you mentioned above. Link to comment Share on other sites More sharing options...
AkaiNight Posted August 1, 2017 Author Share Posted August 1, 2017 (edited) So another question then. If it's possible to understand that a code is working or not? I mean i have a code for gain sanity when kitykit around and lose sanity when the dog one is around but i can't understand is it working or not. Thanks by the way Edited August 1, 2017 by AkaiNight Link to comment Share on other sites More sharing options...
RedHairedHero Posted August 1, 2017 Share Posted August 1, 2017 5 minutes ago, AkaiNight said: So another question then. If it's possible to understand that a code is working or not? I mean i have a code for gain sanity when kitykit around and lose sanity when the dog one is around but i can't understand is it working or not. Thanks by the way You can use print to print out a message that you can look at while in game to see if your function triggered or not. After you put print into the function you want to check test it in game and to check and see if your message appears press the ` key on your keyboard (it's just below ESC), your message should appear there. If you're unsure feel free to post the code you're using and I can take a look. print("This is my message.") Link to comment Share on other sites More sharing options...
AkaiNight Posted August 1, 2017 Author Share Posted August 1, 2017 (edited) Well i'll try but here is the code --Critters sanity aura local function critter_SanityAura(inst) local x, y, z = inst.Transform:GetWorldPosition() local delta = 0 local ents = TheSim:FindEntities(x, y, z, 20, {"critter_puppy", "player" , "critter_kitten"}) local bonus_sanity = nil local distsq = nil local totalDelta = nil for k, v in pairs(ents) do if v ~= inst then if v.entity == "critter_puppy" then bonus_sanity = -TUNING.SANITYAURA_MEDIUM distsq = math.max(inst:GetDistanceSqToInst(v), 1) delta = delta + bonus_sanity / distsq elseif v.entity == "critter_kitten" then bonus_sanity = TUNING.SANITYAURA_SMALL distsq = math.max(inst:GetDistanceSqToInst(v), 1) delta = delta + bonus_sanity / distsq elseif v.entity == "player" then bonus_sanity = -TUNING.SANITYAURA_SMALL distsq = math.max(inst:GetDistanceSqToInst(v), 1) delta = delta + bonus_sanity / distsq else end end totalDelta = totalDelta + delta end if #ents > 0 then totalDelta = totalDelta / #ents else totalDelta = 0 end return totalDelta end oh i forget here is master postinit inst.components.sanity.custom_rate_fn = critter_SanityAura Edited August 1, 2017 by AkaiNight Link to comment Share on other sites More sharing options...
RedHairedHero Posted August 1, 2017 Share Posted August 1, 2017 (edited) 40 minutes ago, AkaiNight said: Well i'll try but here is the code --Critters sanity aura local function critter_SanityAura(inst) local x, y, z = inst.Transform:GetWorldPosition() local delta = 0 local ents = TheSim:FindEntities(x, y, z, 20, {"critter_puppy", "player" , "critter_kitten"}) local bonus_sanity = nil local distsq = nil local totalDelta = nil for k, v in pairs(ents) do if v ~= inst then if v.entity == "critter_puppy" then bonus_sanity = -TUNING.SANITYAURA_MEDIUM distsq = math.max(inst:GetDistanceSqToInst(v), 1) delta = delta + bonus_sanity / distsq elseif v.entity == "critter_kitten" then bonus_sanity = TUNING.SANITYAURA_SMALL distsq = math.max(inst:GetDistanceSqToInst(v), 1) delta = delta + bonus_sanity / distsq elseif v.entity == "player" then bonus_sanity = -TUNING.SANITYAURA_SMALL distsq = math.max(inst:GetDistanceSqToInst(v), 1) delta = delta + bonus_sanity / distsq else end end totalDelta = totalDelta + delta end if #ents > 0 then totalDelta = totalDelta / #ents else totalDelta = 0 end return totalDelta end oh i forget here is master postinit inst.components.sanity.custom_rate_fn = critter_SanityAura What I would do is add the print("Message") into each of the if v.entity statements to see if they're triggering while you're near the entity. My guess would be the function isn't constantly being called, but I'm not sure on the exact setup for custom_rate_fn. Edit: I think adding this into your master postinit should help, it'll call the function every second to see if nearby entities are around and if so apply your sanity drain/buff. inst:DoPeriodicTask(1, function() critter_SanityAura(inst) end) or inst:DoPeriodicTask(1, critter_SanityAura) Edited August 1, 2017 by RedHairedHero Link to comment Share on other sites More sharing options...
AkaiNight Posted August 1, 2017 Author Share Posted August 1, 2017 22 minutes ago, RedHairedHero said: I think adding this into your master postinit should help, it'll call the function every second to see if nearby entities are around and if so apply your sanity drain/buff. inst:DoPeriodicTask(1, critter_SanityAura end) Should i delete end or is it necessary Link to comment Share on other sites More sharing options...
RedHairedHero Posted August 1, 2017 Share Posted August 1, 2017 4 minutes ago, AkaiNight said: Should i delete end or is it necessary I updated it, I got them mixed up. Link to comment Share on other sites More sharing options...
AkaiNight Posted August 1, 2017 Author Share Posted August 1, 2017 1 minute ago, RedHairedHero said: I updated it, I got them mixed up. thanks a lot Link to comment Share on other sites More sharing options...
DarkXero Posted August 2, 2017 Share Posted August 2, 2017 if v.entity == "critter_puppy" then should be if v.prefab == "critter_puppy" then if "critter_puppy" is the name of the prefab of your critter (the name you use to spawn it). elseif v.entity == "player" then should be elseif v:HasTag("player") then because players can have different prefabs like "wilson", or "willow" (or other mod characters). But they all have the player tag. Link to comment Share on other sites More sharing options...
AkaiNight Posted August 3, 2017 Author Share Posted August 3, 2017 On 02.08.2017 at 4:34 AM, DarkXero said: if v.entity == "critter_puppy" then should be if v.prefab == "critter_puppy" then if "critter_puppy" is the name of the prefab of your critter (the name you use to spawn it). elseif v.entity == "player" then should be elseif v:HasTag("player") then because players can have different prefabs like "wilson", or "willow" (or other mod characters). But they all have the player tag. Thank you. 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