Jump to content

Skyrim CK Script for a Realistic Fireplace?


Recommended Posts

(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

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

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 by KassKass
Link to comment
Share on other sites

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

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 by KassKass
Link to comment
Share on other sites

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

  • 1 year later...

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 Auto
Float Property abIM_AutoBurnUpLogs auto
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.}

 

 

Event OnActivate(ObjectReference akActionRef)

if ZZZ_FireplaceEmbers.IsDisabled() ; the fireplace isn't burning

If (Game.GetPlayer().GetItemCount(Firewood01) >= 1)
Game.GetPlayer().RemoveItem(Firewood01, 3)

ZZZ_FireplaceEmbers.Enable() ; light the fire
RegisterForSingleUpdateGameTime(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

endif
EndEvent

Event OnUpdateGameTime()
If (ZZZ_FireplaceEmbers.IsEnabled())


ZZZ_FireplaceEmbers.Disable()

EndIf

EndEvent

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...