MadamCannibal Posted May 20, 2018 Share Posted May 20, 2018 (Firstly, please excuse my noob-i-ness. I'm not sure how things work on this particular forum and did my best to research the scripts before resorting to posting.) I need help finding the proper scripts to create a realistic fireplace that requires fuel (two firewood) to ignite and does NOT stay lit forever (maybe four in-game hours). If said fireplace could also give the player charcoal in return, that would be magnificent. Bear in mind, I'm new to mod creation. I only just learned how to create working bookshelves, display cases, and toggle-able lights. I might be shooting for the stars with this request. If so, please tell me. So far I have the toggle-able fireplace and various links to scripts for "trigger activators" and timers that I'm not script-savvy enough to tweak or combine for my own purpose. It's an exterior house mod for survival-type characters. There is a bundle of twigs, aka "kindling", sitting beside the stone pit which serves as the activator. That's as far as I've gotten with this endeavor. Any help is appreciated. Link to comment Share on other sites More sharing options...
cdcooley Posted May 22, 2018 Share Posted May 22, 2018 That is fairly easy, but details matter so what's the setup for your toggle-able fireplace? Here's a basic script that I haven't tried to compile so there may be errors, but it should get you pointed in the right direction. Change the ZZZ prefix to something more appropriate for your mod. This script assumes there's a fire object that gets enabled and disabled and it's linked to the activator in the CK. Instead of using GetLinkedRef() you could also use an ObjectReference property for that fire object. If the fire is triggered in some other way like playing an animation then things might need to be rewritten if need states to track the current status of the fire. ScriptName ZZZ_FireplaceActivatorScript extends ObjectReference Event OnActivate(ObjectReference akActionRef) if GetLinkedRef().IsDisabled() if charcoalAvailable ; charcoal was made the last time the fire burned so give it to the player charcoalAvailable = false PlayerRef.AddItem(Charcoal, 1) ; one charcoal stick PlayerRef.AddItem(Coal01, 1) ; and one charcoal block endif if PlayerRef.GetItemCount(Firewood01) > 1 PlayerRef.RemoveItem(Firewood01, 2) GetLinkedRef().Enable() RegisterForSingleUpdateGameTime(4.0) ; 4 game hours elseif ZZZ_FirewoodStorage && ZZZ_FirewoodStorage.GetItemCount() > 1 ZZZ_FirewoodStorage.RemoveItem(Firewood01, 2) GetLinkedRef().Enable() RegisterForSingleUpdateGameTime(4.0) ; 4 game hours else NeedFirewoodMSG.Show() endif endif EndEvent Event OnUpdate() GetLinkedRef().Disable() charcoalAvailable = true EndEvent bool charcoalAvailable Message Property ZZZ_NeedFirewoodMSG Auto {"Two firewood needed to light fire." or something similar.} ObjectReference Property ZZZ_FirewoodStorage Auto {Optional reference to a container near the fireplace that can be used by the player to store firewood. The player can then light the fire even if not carrying firewood (but will need to refill the container periodically).} MiscObject Property Charcoal Auto MiscObject Property Coal01 Auto MiscObject Property Firewood01 Auto Actor Property PlayerRef Auto Link to comment Share on other sites More sharing options...
MadamCannibal Posted May 22, 2018 Author Share Posted May 22, 2018 (edited) Thank you, cdcooley! I can't wait to try that script once I'm off mobile.Since I'm new to creating mods, I've only been able to use the basic manual light switch (https://www.creationkit.com/index.php?title=Light_Switch). The activator is a bundle of twigs sitting at the mouth of the fireplace and it toggles the firelight/embers on and off. I'm definitely gonna have to study these scripts more because a light switch is all I know how to make right now. Add: So I'll probably have to combine these two somehow? Not sure I need the firewood container. There was an error the first time around so I guess it's just a trial and tribulation process from here. Edited May 22, 2018 by KassKass Link to comment Share on other sites More sharing options...
cdcooley Posted May 23, 2018 Share Posted May 23, 2018 I was thinking of another light script switch. I've revised my script to fix the errors and use a property just like that light switch script to make things easier. I also added more comments. This script should do everything without needing to combine it with anything else. I've compiled it to get rid of those errors but I still haven't tried it in-game. You would replace that light switch script on the twigs with this one. Most of the properties will auto-fill but my ZZZ_FireplaceEmbers property takes the place of its EnableMarker property and won't auto-fill unless you've given your embers object an editor id of ZZZ_FireplaceEmbers. The firewood container object and the message are now both optional although you really should use a Message object instead of relying on that Debug.Notification before you release the mod. The best way to use the script is to change the script name (to use your own object prefix instead of ZZZ) and the ZZZ properties to match the names of the objects you've set up in your mod so that all of them (that you are using) will auto-fill. ScriptName ZZZ_FireplaceActivatorScript extends ObjectReference {Attach this script to the activator object (bundle of twigs).} Event OnActivate(ObjectReference akActionRef) if ZZZ_FireplaceEmbers.IsDisabled() ; the fireplace isn't burning if charcoalAvailable ; charcoal was made the last time the fire burned so give it to the player charcoalAvailable = false ; we don't want to give these again unless the fire is lit again PlayerRef.AddItem(Charcoal, 1) ; one charcoal stick PlayerRef.AddItem(Coal01, 1) ; and one charcoal block endif if PlayerRef.GetItemCount(Firewood01) > 1 ; player is carrying enough firewood PlayerRef.RemoveItem(Firewood01, 2) ; remove the firewood ZZZ_FireplaceEmbers.Enable() ; light the fire RegisterForSingleUpdateGameTime(4.0) ; set a timer to go off in 4 game hours elseif ZZZ_FirewoodStorage && ZZZ_FirewoodStorage.GetItemCount(Firewood01) > 1 ; there's a storage container with enough firewood ZZZ_FirewoodStorage.RemoveItem(Firewood01, 2) ; remove some wood ZZZ_FireplaceEmbers.Enable() ; light the fire RegisterForSingleUpdateGameTime(4.0) ; set a timer to go off in 4 game hours elseif ZZZ_NeedFirewoodMSG ; there's a message available so show it ZZZ_NeedFirewoodMSG.Show() else ; no message available so use a debug notification Debug.Notification("Two firewood needed to light fire.") endif endif EndEvent Event OnUpdate() ; This will run 4 game hours after the fire was lit ZZZ_FireplaceEmbers.Disable() ; put the fire out charcoalAvailable = true ; mark that some charcoal was created EndEvent bool charcoalAvailable ObjectReference Property ZZZ_FireplaceEmbers Auto {This must be filled with the object to be enabled and disabled.} Message Property ZZZ_NeedFirewoodMSG Auto {Optional "Two firewood needed to light fire." or something similar.} ObjectReference Property ZZZ_FirewoodStorage Auto {Optional reference to a container near the fireplace that can be used by the player to store firewood. The player can then light the fire even if not carrying firewood (but will need to refill the container periodically since two Firewood are used every time the fire is lit).} MiscObject Property Charcoal Auto MiscObject Property Coal01 Auto MiscObject Property Firewood01 Auto Actor Property PlayerRef Auto Link to comment Share on other sites More sharing options...
MadamCannibal Posted May 24, 2018 Author Share Posted May 24, 2018 (edited) Thank you for all of your help. I'm using the script right now without any initial errors. However, the fire still lights without using firewood and displays no messages in either on or off state. Nothing spawns in the container. I'm still messing around with it to see if it's maybe something I'm doing incorrectly. Everything was re-labeled to auto-fill, so that must not be it. Add: Oookay, the first time around it was CK's fault for reverting back to the old script (for sh*ts and giggles, I guess?). Now everything is set up perfectly and the fire will not activate. No messages displayed. I'm just gonna keep troubleshooting. Edited May 24, 2018 by KassKass Link to comment Share on other sites More sharing options...
cdcooley Posted May 24, 2018 Share Posted May 24, 2018 If you are testing in a game that already had the other script attached it will almost certainly fail because the game will keep both scripts attached. Link to comment Share on other sites More sharing options...
MadamCannibal Posted May 27, 2018 Author Share Posted May 27, 2018 Now we're getting somewhere. The "requires two firewood" message shows, but the fire does not light. Doesn't matter if the player is holding firewood or if it's in the container, the fire will not activate and the "needs firewood" message is repeated. Link to comment Share on other sites More sharing options...
jeyoon Posted October 20, 2019 Share Posted October 20, 2019 This was a good post that helped me out a bunch, but initially I couldn't get it working. However, I have tweaked the script although it doesn't do everything that the initial proposed. This script for your campfire activator simply enables a referenced "lit campfire" with 3 firewood and then burns out (disables it) in 4 in game hours. Tested in game to work just fine. Scriptname Firepitrequireslogs extends ObjectReference MiscObject Property Firewood01 AutoFloat Property abIM_AutoBurnUpLogs autoObjectReference Property ZZZ_FireplaceEmbers Auto{This must be filled with the object to be enabled and disabled.}Message Property ZZZ_NeedFirewoodMSG Auto{Optional "Two firewood needed to light fire." or something similar.} Event OnActivate(ObjectReference akActionRef) if ZZZ_FireplaceEmbers.IsDisabled() ; the fireplace isn't burningIf (Game.GetPlayer().GetItemCount(Firewood01) >= 1) Game.GetPlayer().RemoveItem(Firewood01, 3) ZZZ_FireplaceEmbers.Enable() ; light the fireRegisterForSingleUpdateGameTime(abIM_AutoBurnUpLogs) elseif ZZZ_NeedFirewoodMSG ; there's a message available so show it ZZZ_NeedFirewoodMSG.Show() else ; no message available so use a debug notification Debug.Notification("Two firewood needed to light fire.") endif endifEndEventEvent OnUpdateGameTime()If (ZZZ_FireplaceEmbers.IsEnabled()) ZZZ_FireplaceEmbers.Disable()EndIfEndEvent Link to comment Share on other sites More sharing options...
Recommended Posts