Mint Candy Posted June 11, 2024 Share Posted June 11, 2024 (edited) It's my first mod for DST, I making character that use flutes to make /something/. Now I try to make flute that restore sanity in area, but it doesn't work(( Code: What should I do? Edited June 11, 2024 by Mint Candy Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/ Share on other sites More sharing options...
_zwb Posted June 12, 2024 Share Posted June 12, 2024 You didn't call the function sanity_heal... Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/#findComment-1723697 Share on other sites More sharing options...
Mint Candy Posted June 12, 2024 Author Share Posted June 12, 2024 (edited) 11 hours ago, _zwb said: You didn't call the function sanity_heal... Uhm, but I call function(inst), that is sanity_heal, aren't it? edit: ig I understand but it's doesn't work anyway Edited June 12, 2024 by Mint Candy Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/#findComment-1723870 Share on other sites More sharing options...
_zwb Posted June 12, 2024 Share Posted June 12, 2024 It's "inst:DoPeriodicTask(...)" with a colon after "inst", in lua that's equivalent to "inst.DoPeriodicTask(inst, ...)", you need inst as the first parameter. Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/#findComment-1724261 Share on other sites More sharing options...
Mint Candy Posted June 13, 2024 Author Share Posted June 13, 2024 17 hours ago, _zwb said: It's "inst:DoPeriodicTask(...)" with a colon after "inst", in lua that's equivalent to "inst.DoPeriodicTask(inst, ...)", you need inst as the first parameter. I don't really understand why it's work like this, I'm using guide for auras as example, and there no info about what are you saying. local myFunction = function(inst) -- Do something end inst:DoPeriodicTask(1.0, myFunction) Why in DPT should be inst?.. In the whole guide no info about it...( Just now, Mint Candy said: I don't really understand why it's work like this, I'm using guide for auras as example, and there no info about what are you saying. local myFunction = function(inst) -- Do something end inst:DoPeriodicTask(1.0, myFunction) Why in DPT should be inst?.. In the whole guide no info about it...( Mostly I'm using this part, it's closer to thing that I trying to do. local mustHaveTags = { "player" } local cantHaveTags = { "playerghost", "INLIMBO" } local mustHaveOneOfTheseTags = nil inst:DoPeriodicTask(1.0, function(inst) -- Do nothing if the entity has a health component and is dead, or it is a playerghost. if inst.components.health and inst.components.health:IsDead() or inst:HasTag("playerghost") then return end local x,y,z = inst.Transform:GetWorldPosition() local players = TheSim:FindEntities(x, y, z, 10, mustHaveTags, cantHaveTags, mustHaveOneOfTheseTags) -- Run through all the players within range... for _,v in ipairs(players) do -- ...and if they have a health component, add 1 to their health. if v.components.health then v.components.health:DoDelta(1) end end end) Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/#findComment-1724533 Share on other sites More sharing options...
Mint Candy Posted June 13, 2024 Author Share Posted June 13, 2024 2 hours ago, Mint Candy said: I don't really understand why it's work like this, I'm using guide for auras as example, and there no info about what are you saying. local myFunction = function(inst) -- Do something end inst:DoPeriodicTask(1.0, myFunction) Why in DPT should be inst?.. In the whole guide no info about it...( Mostly I'm using this part, it's closer to thing that I trying to do. local mustHaveTags = { "player" } local cantHaveTags = { "playerghost", "INLIMBO" } local mustHaveOneOfTheseTags = nil inst:DoPeriodicTask(1.0, function(inst) -- Do nothing if the entity has a health component and is dead, or it is a playerghost. if inst.components.health and inst.components.health:IsDead() or inst:HasTag("playerghost") then return end local x,y,z = inst.Transform:GetWorldPosition() local players = TheSim:FindEntities(x, y, z, 10, mustHaveTags, cantHaveTags, mustHaveOneOfTheseTags) -- Run through all the players within range... for _,v in ipairs(players) do -- ...and if they have a health component, add 1 to their health. if v.components.health then v.components.health:DoDelta(1) end end end) P.S. It START to work somehow, but now I have troubles to stop sanity heal after while... Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/#findComment-1724616 Share on other sites More sharing options...
_zwb Posted June 14, 2024 Share Posted June 14, 2024 (edited) 10 hours ago, Mint Candy said: I don't really understand why it's work like this, In lua there are no classes, so it is usually implemented using tables. Such as: MyClass = {} function MyClass:MyMethod() end Here, calling MyClass:MyMethod() is the same as MyClass.MyMethod(MyClass) If you still don't understand, you should go learn the basics of Object Orientated Programming(OOP) and OOP in lua. Edited June 14, 2024 by _zwb 1 Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/#findComment-1724776 Share on other sites More sharing options...
Mint Candy Posted June 14, 2024 Author Share Posted June 14, 2024 8 hours ago, _zwb said: In lua there are no classes, so it is usually implemented using tables. Such as: MyClass = {} function MyClass:MyMethod() end Here, calling MyClass:MyMethod() is the same as MyClass.MyMethod(MyClass) If you still don't understand, you should go learn the basics of Object Orientated Programming(OOP) and OOP in lua. Oh, I see. Okay. For now, my code looking like this. It's working, but sanity healing works without stop. It's not canceling for some reason, and I don't understand why... Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/#findComment-1724881 Share on other sites More sharing options...
_zwb Posted June 14, 2024 Share Posted June 14, 2024 3 hours ago, Mint Candy said: It's not canceling for some reason, and I don't understand why... because you cancelled the task you use to cancel sanity_heal_end task, you didn't cancel the healing task Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/#findComment-1724924 Share on other sites More sharing options...
Mint Candy Posted June 14, 2024 Author Share Posted June 14, 2024 1 hour ago, _zwb said: because you cancelled the task you use to cancel sanity_heal_end task, you didn't cancel the healing task Hmm, I thought they equal (in those guide it's working like this...). I will test it, thanks. Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/#findComment-1724944 Share on other sites More sharing options...
Mint Candy Posted June 14, 2024 Author Share Posted June 14, 2024 (edited) 7 hours ago, _zwb said: because you cancelled the task you use to cancel sanity_heal_end task, you didn't cancel the healing task Well I'm really don't know what to do, it's just don't work)) I need it to heal sanity for /time/, and after it stop until I reuse this item. Maybe I'm doing everything wrong and should use DoTaskInTime?.. Edited June 14, 2024 by Mint Candy Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/#findComment-1725121 Share on other sites More sharing options...
Baguettes Posted June 24, 2024 Share Posted June 24, 2024 I think you could probably make this into a buff instead of having to do this all by yourself. Buffs have on attach, detach, and extend, so it's probably more flexible to work on those and make the instrument apply the buff to you and others around you. Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/#findComment-1728703 Share on other sites More sharing options...
Mint Candy Posted August 1, 2024 Author Share Posted August 1, 2024 On 6/24/2024 at 11:32 AM, Baguettes said: I think you could probably make this into a buff instead of having to do this all by yourself. Buffs have on attach, detach, and extend, so it's probably more flexible to work on those and make the instrument apply the buff to you and others around you. Hmm Okie-dokie, I'll try, but maybe you have some examples? Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/#findComment-1738571 Share on other sites More sharing options...
Haruhi Kawaii Posted August 2, 2024 Share Posted August 2, 2024 7 hours ago, Mint Candy said: Hmm Okie-dokie, I'll try, but maybe you have some examples? In forgetmelots.lua file, it has a similar buff Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/#findComment-1738673 Share on other sites More sharing options...
Mint Candy Posted August 6, 2024 Author Share Posted August 6, 2024 On 8/2/2024 at 5:28 AM, Haruhi Kawaii said: In forgetmelots.lua file, it has a similar buff Thanks, but I made it work for now with _my_ method somehow Now I want to understand another thing... Link to comment https://forums.kleientertainment.com/forums/topic/156919-how-to-make-item-restore-sanity-in-aoe-includes-user/#findComment-1739499 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