polaroskii Posted September 11, 2016 Share Posted September 11, 2016 Hello there. Just like how the title sounds, I want to be able to do the following: Allow a simple sanity gain from the catching of bugs using the bug net that is character specific. Increase the amount of sanity gained from picking flowers. I only have a small gist of how things are to work, but I don't really know where to start. The closest to an idea of how to do so is to do an eventlisten or cause a pushevent. I feel like it is much harder than it should be. Link to comment https://forums.kleientertainment.com/forums/topic/70083-help-bugnet-sanity-gain-and-pickable-flower-sanity-boost/ Share on other sites More sharing options...
CarlZalph Posted September 11, 2016 Share Posted September 11, 2016 (edited) @polaroskii This is just one way to go about it, but it is the easiest as far as I can see. AddPrefabPostInit( "wilson", function(inst) inst:ListenForEvent( "finishedwork", function(inst, data) if(data and data.target and data.target.prefab=="butterfly") then if(data.action and data.action.id=="NET") then if(inst and inst.components and inst.components.sanity) then inst.components.sanity:DoDelta(20) end end end end ) inst:ListenForEvent( "picksomething", function(inst, data) if(data and data.object and data.object.prefab=="flower") then if(inst and inst.components and inst.components.sanity) then inst.components.sanity:DoDelta(20) end end end ) end ) Of course you can remove the check for butterfly to make it work for any net-catchable bug. The flower one is an additional delta in that it will add whatever the original delta is from the flower prefab. Edited September 11, 2016 by CarlZalph Link to comment https://forums.kleientertainment.com/forums/topic/70083-help-bugnet-sanity-gain-and-pickable-flower-sanity-boost/#findComment-812730 Share on other sites More sharing options...
polaroskii Posted September 12, 2016 Author Share Posted September 12, 2016 (edited) @CarlZalph Thank you very much! Your little bit of PostInit() has really given me insight on how to apply other ideas. I guess I was just wasn't thinking outside of the box. Edited September 12, 2016 by polaroskii Problem resolved Link to comment https://forums.kleientertainment.com/forums/topic/70083-help-bugnet-sanity-gain-and-pickable-flower-sanity-boost/#findComment-812774 Share on other sites More sharing options...
CarlZalph Posted September 12, 2016 Share Posted September 12, 2016 (edited) 1 hour ago, polaroskii said: @CarlZalph Thank you very much! Your little bit of PostInit() has really given me insight on how to apply other ideas. I guess I was just wasn't thinking outside of the box. And if you were making a custom character then the postinit stuff would go in the master post init since it deals with the components, and only the server should touch components (They don't exist on the client, for more information see: replica). The code there will work on both clients and servers due to my over checking of everything in the if conditionals. (inst.components would exist if this were only done on the server, it's pretty much a guarantee if the inst is an entity to have the components table) Edited September 12, 2016 by CarlZalph Link to comment https://forums.kleientertainment.com/forums/topic/70083-help-bugnet-sanity-gain-and-pickable-flower-sanity-boost/#findComment-812805 Share on other sites More sharing options...
leprucio Posted September 13, 2016 Share Posted September 13, 2016 (edited) Then... its posible to make the same Spoiler AddPrefabPostInit( "wilson", function(inst) inst:ListenForEvent( "finishedwork", function(inst, data) if(data and data.target and data.target.prefab=="butterfly") then if(data.action and data.action.id=="NET") then if(inst and inst.components and inst.components.sanity) then inst.components.sanity:DoDelta(20) end end end end ) But just for pick the product of one farm? changing for example the term in target for "fast_farmplot" and the action for pickup ? and in DoDelta put maybe 5? (for gain only 5 of sanity) --------------------------------------------------- @CarlZalph I trying but i having a little issues whit that Spoiler AddPrefabPostInit ( "wilson", function(inst) inst:ListenForEvent( "finishedwork", function(inst, data) if(data and data.target and data.target.prefab=="fast_farmplot" or data.target.prefab=="slow_farmplot") then if(data.action and data.action.id=="plant" or data.action.id=="harvest" ) then if(inst and inst.components and inst.components.sanity) then inst.components.sanity:DoDelta(10) end end end end ) inst:ListenForEvent( "picksomething", function(inst, data) if(data and data.object and data.object.prefab=="flower") then if(inst and inst.components and inst.components.sanity) then inst.components.sanity:DoDelta(1) end end end ) end ) The main idea is a little gain of 5 from plant and harvest farmplots and a gain of 1 when pikc a berry from bushes, but first for all i dont sure if bush its pickup or harvest xD second if put it in modmain don't work if i put in character lua then its not declarated(out or in master_postinit) and cuase a strange crash if i try to load one of my test servers (i go in the server and show character selection freeze and close lol) srry for thath amount of questions i learning how to make things and its my first-time whit the addprefabpostinit. thx for ur times. Edited September 14, 2016 by leprucio Link to comment https://forums.kleientertainment.com/forums/topic/70083-help-bugnet-sanity-gain-and-pickable-flower-sanity-boost/#findComment-813165 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