Jump to content

Initially Disabling Items With Scripts


Zylice

Recommended Posts

I have a 'build your own home' type of mod and I want to be able to have a fireplace initially disabled that has a script on it. When I have initially disabled it and have it being enabled when crafted, the script no longer works. Why is this? Is there a way around it? It also happens with other items that I have scripts on.

Any help will be appreciated. :)

Link to comment
Share on other sites

What is the script attached to the disabled object meant to do? My guess is that the oninit event would not fire until the objectreference is enabled, meaning the script may technically be working fine, but it's not actually doing anything until the object has been enabled because it hasn't received any events yet. Just a guess, I've never tested when exactly oninit() runs for an object reference that is initially disabled. It normally runs the first time the user loads a cell with the object reference present.

Link to comment
Share on other sites

What is the script attached to the disabled object meant to do? My guess is that the oninit event would not fire until the objectreference is enabled, meaning the script may technically be working fine, but it's not actually doing anything until the object has been enabled because it hasn't received any events yet. Just a guess, I've never tested when exactly oninit() runs for an object reference that is initially disabled. It normally runs the first time the user loads a cell with the object reference present.

It isn't on oninit script, it's an OnActivate script. Here

 

 

Scriptname WSCampfireScript extends ObjectReference  
{Allows you to turn the campfire on & off}
 
ObjectReference Property Campfire_On Auto
ObjectReference Property Campfire_Off Auto
 
Event OnActivate(ObjectReference akActionRef)
If Campfire_Off == Self
Self.disable()
Campfire_On.enable()
Else
Campfire_On.disable()
Campfire_Off.enable()
EndIf
EndEvent
Link to comment
Share on other sites

I did it a little different.

I created 2 activator using the campfire on and campfire off models.

Attached this script to both campfire activators.

(No properties needed to be filled in CK).

Scriptname WSCampfireScript extends ObjectReference
{Allows you to turn the campfire on & off}

Event OnActivate(ObjectReference akActionRef)
    ObjectReference LR = Self.GetLinkedRef()
    If LR
        LR.Enable()
    Else
        Self.Disable()
    EndIf
EndEvent

Then I dropped the 2 activator campfires into the render window.

Right click and edit the Campfire_On reference and set the Campfire_Off reference as Enable Parent and checked the box "Set Enable state Opposite of Parent".

I also added a LinkedRef to the Campfire_Off reference and closed the edit window.

 

Here's the test esp, you can find the campfire out front of Whiterun Stables opposite the carriage driver.

 

Link to comment
Share on other sites

I did it a little different.

I created 2 activator using the campfire on and campfire off models.

Attached this script to both campfire activators.

(No properties needed to be filled in CK).

Scriptname WSCampfireScript extends ObjectReference
{Allows you to turn the campfire on & off}

Event OnActivate(ObjectReference akActionRef)
    ObjectReference LR = Self.GetLinkedRef()
    If LR
        LR.Enable()
    Else
        Self.Disable()
    EndIf
EndEvent

Then I dropped the 2 activator campfires into the render window.

Right click and edit the Campfire_On reference and set the Campfire_Off reference as Enable Parent and checked the box "Set Enable state Opposite of Parent".

I also added a LinkedRef to the Campfire_Off reference and closed the edit window.

 

Here's the test esp, you can find the campfire out front of Whiterun Stables opposite the carriage driver.

http://forums.nexusmods.com/public/style_images/underground/attachicon.gifCampfiretest.zip

I'll try this. It makes sense. Thanks very much! :)

Link to comment
Share on other sites

When I applied the script on both campfires & made the off campfire the parent, the campfire turns on but it won't turn off again.

Link to comment
Share on other sites

 

 

Then I dropped the 2 activator campfires into the render window.

Right click and edit the Campfire_On reference and set the Campfire_Off reference as Enable Parent and checked the box "Set Enable state Opposite of Parent".
I also added a LinkedRef to the Campfire_Off reference and closed the edit window

 

Linked Ref:http://nsa38.casimages.com/img/2015/05/19/150519070924283418.jpg

 

Parent:http://nsa38.casimages.com/img/2015/05/19/150519070638677668.jpg

Link to comment
Share on other sites

 

Then I dropped the 2 activator campfires into the render window.

 

Right click and edit the Campfire_On reference and set the Campfire_Off reference as Enable Parent and checked the box "Set Enable state Opposite of Parent".

I also added a LinkedRef to the Campfire_Off reference and closed the edit window.

 

Okay. I got it working before I linked it to an xmarker. The xmarker is initially disabled and enables certain items when you have crafted them. For some reason, scripts like this seem to lose functionality when the item that the're attached to is being initially disabled via an xmarker. I haven't found any way of getting around it. However; thanks for your help! :)

Edited by Zylice
Link to comment
Share on other sites

If your using an xMarker then it's a different story.

the script is simpler.

 

What's firing the xmarker to disable and enable, eg an activator or a dialogue or whatever?

 

Are you trying to start with both campfires disabled, then when the user purchases the campfire, then it appears.

After that the user can turn off and on the camfire as they please?

 

If so that should be easy enough to do.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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