Jump to content

[LE] Having problems with taking and placing torch in sconce.


Recommended Posts

Hi all. Old modder back from the dead here.. still re-learning.

The good old 'RemovableTorchSconce01'. I've been through the script and as I said I haven't modded for years and am unsure what I need to do. I want the sconce(s) to start empty. Player finds a torch on the ground and can place it in various sconces around the cell to light the area. I don't want the player to always carry the torch (reasons for another post). Also I want a light source, I know how to place them, to be enabled when a torch is in a sconce and disabled when it isn't. As I said I am not sure the script on the base sconce does this or I am setting properties wrong... or something completely different.

Help appreciated, it will come back to me bit by bit but for now I am in noob territory.

Link to comment
Share on other sites

I'm gussing you are using the 'RemovableTorchSconce01' activator, if so, you only need to "Check" in the script's properties the "Start empty", keep in mind that for the torch to be placed in the sconce you need to have torches in your inventory or to be holding one.
The default vanilla script dosen't have the option to enable light upon placing the torch, you need your own script for this.
There are two ways you can do this:
1) In the RemovableTorchSconce01 "Reference" window go to "Scripts" and click "Add", when the script window appears click "New Script", give a name and description & press "Ok", now right click the new created script and choose "Edit Source" and paste in this little script and save for the compile to be executed.

 
ObjectReference Property MainLight Auto
 
Event OnActivate(ObjectReference akActionRef)
   If (MainLight.IsEnabled())
       MainLight.disable()
  Else
      MainLight.enable()
EndIf
EndEvent

Then go to properties and Link Ref your light, for what you want to do the light should be in a "Initially Disable" state (botton left corner in the objects "Reference" window).
* The down side with this approach is that if you activate the torch sconce without having torch the second script will still fire.
* This scripts has the fanction to auto detect the enable/disable state of the object and then do the opposite, i'm meantion this just in case you might need to do something else that might need this kind of function (like enable/disable lights or a wall when you activate a "lever" or a "PullChain")
2) From the RemovableTorchSconce01 "Reference" window select the script and click "Remove" (you should see now a red line just beside it).
Now you "Add" & create a "New Script" as you did before, with the only difference that you will use one script instead of two.
This is a slightly modified version of the default vanilla script with the option to enable light when the torch is placed and disable the light when the torch is remove.

 

import debug
 
Light Property Torch01 Auto
{The Torch01 we look for in the players inventory}
 
ObjectReference Property MyTorchLight Auto
[Light to enable when torch is placed}
 
Activator Property RemovableTorch01 Auto
{Base object for torch activator that gets placed}
 
Bool Property StartsEmpty Auto
{If this is TRUE the sconce will start empty.  Default = FALSE}
 
Bool Property TorchInSconce = TRUE Auto Hidden
{TRUE when there is a torch in the sonce, FALSE when there isn't.  Default = TRUE}
 
ObjectReference Property PlacedTorch Auto Hidden
{A way to refer to the torch after it's been placed at the sconce}
 
Sound Property ITMGenericUp Auto
Sound Property ITMGenericDown Auto
 
EVENT OnCellLoad()
;Trace("DARYL - " + self + "Cell Loaded")
if (StartsEmpty == FALSE && !IsDisabled())
;Trace("DARYL - " + self + "Should start with a torch in it")
; If this sconce is marked to start with a torch then place one in it
if (PlacedTorch)
;Trace("DARYL - " + self + "A torch has been placed here before, lets simply enable it")
PlacedTorch.Enable()
MyTorchLight.enable()
else
PlacedTorch = Self.PlaceAtMe(RemovableTorch01)
;Trace("DARYL - " + self + "A torch has never been placed here, lets place one as " + PlacedTorch)
endif
 
EnableLinkChain()
 
GoToState("HasTorch")
elseif (StartsEmpty == FALSE && IsDisabled())
;STEVE - Special Case - Add a torch when this gets enabled and activated.
;Remove the old torch (if we had one)
PlacedTorch.Disable()
MyTorchLight.Disable()
DisableLinkChain()
;Trace("STEVE - " + self + "Sconce is starting disabled, going to Awaiting Activation.")
goToState("AwaitingActivation")
else
DisableLinkChain()
;Trace("DARYL - " + self + "Sconce is starting empty, going to NoTorch State")
GoToState("NoTorch")
endif
 
EndEVENT
 
Function RemoveTorch()
PlacedTorch.Disable()
MyTorchLight.Disable()
DisableLinkChain()
GoToState("NoTorch")
EndFunction
 
 
STATE HasTorch
 
EVENT onActivate(ObjectReference TriggerRef)
GoToState("Busy")
;;Trace("DARYL - " + self + "Player has activated this sconce in the HasTorch State")
PlacedTorch.Disable()
MyTorchLight.Disable()
DisableLinkChain()
TriggerRef.AddItem(Torch01)
int TorchTaken = ITMGenericUp.Play(self)
;;Trace("DARYL - " + self + "Disabling the torch, giving one to the player, and going into the Busy State")
GoToState("NoTorch")
EndEVENT
EndState
 
 
STATE NoTorch
 
EVENT onActivate(ObjectReference TriggerRef)
 
;;Trace("DARYL - " + self + "Player has activated the sconce in the NoTorch State")
if TriggerRef.GetItemCount(Torch01) > 0
GoToState("Busy")
;;Trace("DARYL - " + self + "The player has " + (Game.GetPlayer()).GetItemCount(Torch01) + " torches, so lets place one")
if (PlacedTorch)
;;Trace("DARYL - " + self + "A torch has been placed here before, lets simply enable it")
PlacedTorch.Enable()
MyTorchLight.Enable()
else
PlacedTorch = Self.PlaceAtMe(RemovableTorch01)
;;Trace("DARYL - " + self + "A torch has never been placed here, lets place one as " + PlacedTorch)
endif
 
TriggerRef.RemoveItem(Torch01)
EnableLinkChain()
int TorchPlaced = ITMGenericDown.Play(self)
;;Trace("DARYL - " + self + "The player now has" + (Game.GetPlayer()).GetItemCount(Torch01) + " torches after removing one")
GoToState("HasTorch")
endif
 
EndEVENT
 
EndState
 
 
STATE Busy
;Do Nothing
EndState
 
STATE AwaitingActivation
Event OnActivate(ObjectReference obj)
Self.Enable()
OnCellLoad()
EndEvent
EndState

 

Here the light should also be in a "Initially Disable" state. Don't forget to Link Ref the light from the script's properties.

 

Have a happy modding....

Edited by maxarturo
Link to comment
Share on other sites

I checked the vanilla script once more before closing CK, and there is an option to enable/disable light.

What you need to do is place your light and then go to the RemovableTorchSconce01 "Reference" window, and in the "Link Ref" tab double click the empty white box and then "select Ref from render window", double click your light. That's all.


* Sorry... too tired...

Edited by maxarturo
Link to comment
Share on other sites

Thanks for your help. Works as you said it would. On a similar note, I have noticed that if the player has a torch equipped for X amount of time it will go out (be removed from inventory). This is interesting for my particular mod as for a portion of the game the player has to realise that without a torch progress will be greatly impeded. Do you know the time limit, scratch that I'll time it, but how to change the time limit?

Link to comment
Share on other sites

In every torch that you will put - place in your cell, go to each torch "Reference" menu and in the tab "Extra" set the "Time left" to your desirable settings.

Link to comment
Share on other sites

I'll have to check this in CK whenever i get home, but from what i can remember it's something like that (but i could be wrong)

 

* For your fire trap you will need to clarify if you will allow players to use TGM (it's scripted differently). The difference is that if not using TGM the player dies and then the game will load the most recent save, but if the player uses TGM the explosion will fire and the player won't die and he'll keep playing.

Edited by maxarturo
Link to comment
Share on other sites

  • Recently Browsing   0 members

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