Jump to content

[LE] Can't transfer property between two scripts (following wiki tutorial... failing.)


corrado33

Recommended Posts

Script A, attached to a misc item, to be placed in a chest.

Scriptname kCraftingChestItemScript extends ObjectReference  

objectReference Property linkedChest auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	if (akNewContainer != Game.getplayer())
		linkedChest = akNewContainer
	endif
endevent

Script B, attached to a quest that's launched via spell blah blah (This script works fine if I manually assign the property "linkedChest" to any chest in the game)

 

EDIT: The scripts compile... but I don't receive the objects from the chest.

Scriptname kCraftingAutoRetrieveScript1 extends ReferenceAlias  

kCraftingChestItemScript Property remoteObject Auto

Event OnActivate(ObjectReference akActionRef)
        remoteObject.linkedChest.RemoveAllItems(PlayerRef)
endevent
Edited by corrado33
Link to comment
Share on other sites

You will need to assign the correct object to your RemoteObject property. The Creation Kit should offer you a drop down with all objects holding the listed script. You need to select the correct pre-placed instance. If there will be more than one possible instance at a time, or you will not be pre-placing the object then you may need to flip it around.

 

Example:

 

The object script

Scriptname kCraftingChestItemScript extends ObjectReference  



kCraftingAutoRetrieveScript1 Property myAlias Auto



Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

    if (akNewContainer != Game.getplayer())

        myAlias.linkedChest = akNewContainer

    endif

endevent

The alias script

Scriptname kCraftingAutoRetrieveScript1 extends ReferenceAlias  



objectReference Property linkedChest auto

Actor Property PlayerRef Auto



Event OnActivate(ObjectReference akActionRef)

    If linkedChest ;make sure we have a valid item

        linkedChest.RemoveAllItems(PlayerRef)

    EndIf

endevent

 

 

Link to comment
Share on other sites

I'll wager that if you were to pull up the script log you'd find that it's complaining at you that RemoteObject is a none (i.e. not filled) and it can't get the properties of a none object. This is an error the compiler won't catch, because properties can be manipulated at runtime, so it is legal to compile them when undefined in the CK, but if you attempt to then do stuff with an unfilled property, it'll break.

 

In this case the easiest fix is to fill the RemoteObject property in the CK with whatever your misc object is. There should be a dropdown list with all of the available things with the correct script attached to them. If you want to do something more sophisticated at runtime that's also possible, but try the easy way first. :)

Edited by foamyesque
Link to comment
Share on other sites

How are you filling RemoteObject property, in ck or are you getting a reference to the misc item at runtime?

 

You will need to assign the correct object to your RemoteObject property. The Creation Kit should offer you a drop down with all objects holding the listed script. You need to select the correct pre-placed instance. If there will be more than one possible instance at a time, or you will not be pre-placing the object then you may need to flip it around.

 

Example:

 

The object script

Scriptname kCraftingChestItemScript extends ObjectReference  



kCraftingAutoRetrieveScript1 Property myAlias Auto



Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

    if (akNewContainer != Game.getplayer())

        myAlias.linkedChest = akNewContainer

    endif

endevent

The alias script

Scriptname kCraftingAutoRetrieveScript1 extends ReferenceAlias  



objectReference Property linkedChest auto

Actor Property PlayerRef Auto



Event OnActivate(ObjectReference akActionRef)

    If linkedChest ;make sure we have a valid item

        linkedChest.RemoveAllItems(PlayerRef)

    EndIf

endevent

 

 

 

I figured it out (last night actually.) And it came with a major revelation. The solution is essentially what is above.

 

Quests.... are NOT quests. Quests are global objects used to store variables and other things that should be accessible to other scripts/quests within skyrim.

 

Once I figured THAT out, I simply added an empty quest alias to my quest that runs at startup (called myChest) and used

referencealias property myChest auto

myChest.getref().whatever I want to do

And it works great.

 

That's really weird the way that works. I wish someone had told me a long time ago that quests weren't quests, but rather ways of storing data. I was wondering about that ever since I started. Kept saying to myself "Why does everyone want to create a damn quest to do this thing that has nothing to do with quests?"

Link to comment
Share on other sites

  • Recently Browsing   0 members

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