Jump to content

Fireplace elseif script help


TyburnKetch

Recommended Posts

I have this script for a conditional fireplace. It all works fine, needs a tweak or two, but I am stuck on getting my first elseif to fire (pun intended).

 

I have the properties set up properly. The container has 6 firewood01 placed in it, but the script just bypasses the first elseif and the 2nd (I have not filled the custom message property actually), and just moves on to the "2 firewood needed to light fire" debug message.

 

Any ideas on what I have missed?

 

Thanks.

 

Edit: Just added a custom messege for the 2nd elseif and now NO message plays ...

 

 

Scriptname TN_FirePlace_ON extends ObjectReference

MiscObject Property Firewood01 Auto
Float Property abIM_AutoBurnUpLogs auto
ObjectReference Property FireOn Auto
ObjectReference Property FirewoodStorage Auto
Message Property NeedFirewoodMSG Auto
Message Property FirewoodBasketMSG Auto
ObjectReference Property TriggerBoxOFF auto
ObjectReference Property FireLight Auto


Event OnActivate(ObjectReference akActionRef)

if FireOn.IsDisabled()

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

FireOn.Enable(5.0)
FireLight.Enable(5.0)
RegisterForSingleUpdateGameTime(abIM_AutoBurnUpLogs)
TriggerBoxOFF.Enable()
Self.Disable()

elseif FireWoodStorage && FirewoodStorage.GetItemCount(Firewood01) >1
FirewoodStorage.RemoveItem(Firewood01, 2)
FirewoodBasketMSG.Show()
FireOn.Enable(5.0)
FireLight.Enable(5.0)
RegisterForSingleUpdateGameTime(abIM_AutoBurnUpLogs)
TriggerBoxOFF.Enable()
Self.Disable()

elseif NeedFirewoodMSG
NeedFirewoodMSG.Show()
else
Debug.Notification("Two firewood needed to light fire.")
endif

EndIf
EndEvent

Event OnUpdateGameTime()
If (FireOn.IsEnabled())
FireOn.Disable(3.0)
FireLight.Disable(3.0)
TriggerBoxOFF.Disable()
Self.Enable()

EndIf
EndEvent

 

Edited by TyburnKetch
Link to comment
Share on other sites

Unfortunately, unless the player accesses a container to have its contents put into memory, scripts cannot determine what items might be pre-placed in said container. Thus your GetItemCount on the firewood storage will always return false until the player accesses the container. On the other hand, if items are added via script they will still be discoverable by other scripts even if the player does not interact with the container.

 

That explains why it was skipping down to the need wood message to show. But why it would not show any message after adding another message for debugging purposes, I cannot fathom.

 

Is the posted script the one used in the first attempt or the second attempt?

 

I'm going guess that you used my Campfire Stages resource as a guide in your attempt. I recognized my "abim" prefix on the one property variable.

Link to comment
Share on other sites

Hi Ishara. Thank you for responding.

 

I got the basis for the script off the web, the author obviously took parts from your scripts!

 

Thank you for clarifing about the container needing to be accessed first by the player. This explains my subsequent "wonky" testing ... or what I imagined to be "wonky".

 

Will try and add some firewood to the basket via script.

 

The posted script was used in both attempts, just with the MSG property filled in the 2nd attempt.

 

Will do some more testing. Thanks again for your help.

 

EDIT: Yep. Got it working. Just added a line at the start of the script to additem, then removeitem straight away. Not massively elegant but it registers the container at least.

 

My messages not showing was very simple. I had the message on the title instead of the body. Doh!

 

EDIT2: BTW Ishara, thank you for posting your resource up. I had not seen it before but it looks really good, and very useful!

Edited by TyburnKetch
Link to comment
Share on other sites

  • Recently Browsing   0 members

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