Jump to content

Recommended Posts

Posted

When a cell resets does an item with a script that has two separate states go back to it's original state? I want an item with 2 states repaired and unrepaired and once repaired to stay that way. I know I could use enabling and disabling of identical looking items but would states work instead?

Posted (edited)
When a cell 'Resets' all scripts living in that cell will also reset to their original state.

* (scripts that are living inside of an object that is placed in that cell, not scripts that are pointing / targeting that cell or an object that is in that cell and they are not living in that cell).


In order to have a cell that can 'Reset' and also have some scripts (that live on that cell) not to reset, you need to go (from your CK's render window) into the object's property (double klick it) and 'Uncheck' the "RESOPND" flag, this way when the cell resets, all objects that have the 'Respond' flag unchecked will not reset with the cell.


* The other way around does not work.

Edited by maxarturo
Posted (edited)

Maybe next two scripts may help to understand.. The first is attached to an object which force a manual cell reset by his activation. The scond is a demo for your state script.

 

TestCellResetScript

 

Scriptname TestCellResetScript extends ObjectReference
; https://forums.nexusmods.com/index.php?/topic/9256073-question-about-states/

  Cell PROPERTY myCell auto            ; put in the cell you want to reset by activating the object

; -- EVENTs -- 2

EVENT OnInit()
    Debug.Trace(" OnInit() - has been called for " +self)        ; for info only
ENDEVENT


EVENT OnActivate(ObjectReference akActionRef)
IF (akActionRef == Game.GetPlayer() as ObjectReference)
    gotoState("Busy")                    ; ### STATE ###

    myCell.Reset()
    Debug.Notification("Activation.. cell reset")                ; notify on screen
    Utility.Wait(2.0)

    gotoState("")                        ; ### STATE ###    back to empty state, you can reset "myCell" once more
ENDIF
ENDEVENT


;=========================
state Busy  ; busy with reset action
;=========
    EVENT OnActivate(ObjectReference akActionRef)
    ENDEVENT
;=======
endState

 

 

 

TestItemTwoStatesScript

 

Scriptname TestItemTwoStatesScript extends ObjectReference
; https://forums.nexusmods.com/index.php?/topic/9256073-question-about-states/


; -- EVENTs --

EVENT OnInit()
    Debug.Trace(" OnInit() - has been called for " +self)                        ; for info only
ENDEVENT


EVENT OnCellAttach()
    gotoState("Waiting")            ; ### STATE ###
ENDEVENT

EVENT OnCellLoad()
    gotoState("Running")            ; ### STATE ###
ENDEVENT

EVENT OnLoad()
ENDEVENT


EVENT OnReset()  ; empty state
    Debug.Trace(" OnReset() - has been called for " +self)                        ; for info only
    Debug.Trace(" State is " + self.GetState())
ENDEVENT


;=================================
state Waiting
;============
    EVENT OnReset()  ; empty state
        Debug.Trace(" OnReset() - ['Waiting'] has been called for " +self)        ; for info only
        gotoState("")                ; ### STATE ###
    ENDEVENT
;=======
endState


;=================================
state Running
;============
    EVENT OnReset()  ; empty state
        Debug.Trace(" OnReset() - ['Running'] has been called for " +self)        ; for info only
        gotoState("")                ; ### STATE ###
    ENDEVENT
;=======
endState

 

 

 

 

What I know about about script reset is: The properties go back to his default values made by CK or preset by script. Variables of type "Int", "Float", "String" should not been affected from reset.

Edited by ReDragon2013
  • Recently Browsing   0 members

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