Jump to content

Possible to change Base Object of placed object via script?


FuryoftheStars

Recommended Posts

Self points to whatever the script is attached to. So, if it's a reference alias script, it points to the reference alias it's on. Clear() clears the reference alias so it's set to None, the OnLoad() event won't run anymore because the reference alias isn't holding a reference anymore.

Link to comment
Share on other sites

Ok, thanks both of you. I'll look more into this later. I'm going to take a break from this idea to work on the other mod idea that I had (that was the first mod idea I wanted to work on and allowed myself to be side tracked by this one...), but I will circle back around to it, cause they do tie into each other.

Link to comment
Share on other sites

It's not too complicated. Make a new quest, in the quest, make a new reference alias. Make it a specific reference fill type, choose the cell that the HF bed is in and choose the HF bed as the reference. Make sure the Optional box is checked, or Clear() won't work. Then put a script like this on the reference alias:

 

Scriptname TM_ReferenceAliasScript extends ReferenceAlias 

ObjectReference Property MyBed Auto 

Event OnLoad() 
    MyBed.Enable() 
    Self.Clear() ;remove the ref from this ReferenceAlias. 
EndEvent
Link to comment
Share on other sites

Ok, thanks. I would have never gotten the quest part. I didn't even realize that was going to be needed for this. :/

 

Out of curiosity, I just found something a few minutes ago about using States as a run once switch. (https://forums.nexusmods.com/index.php?/topic/1309985-running-a-script-only-once/ Not sure why I wasn't able to find this sooner.... And actually, someone else in that thread suggested using a boolean, though it was stated that States may have a performance gain over the bool.) Any feedback on that? Do you know what the potential pros vs cons are?

Edited by FuryoftheStars
Link to comment
Share on other sites

Using states or bools are also valid options, but for this case I would still use Clear(). The reason to use a reference alias on a quest is so you don't have to edit the vanilla bed form directly which can cause mod conflicts, otherwise you could put the script directly on the bed object reference. If you are putting a script directly on a reference, using states would be best. If you're only using a quest for this one reference alias, you can also stop the quest after the script runs for better performance.:

 

Scriptname TM_ReferenceAliasScript extends ReferenceAlias 

ObjectReference Property MyBed Auto 

Event OnLoad() 
    MyBed.Enable() 
    Self.Clear() ;remove the ref from this ReferenceAlias. 
    Self.GetOwningQuest().Stop() ;stop the quest this ReferenceAlias is on.
EndEvent
Link to comment
Share on other sites

(I tried making another post, but then the site seemed to time out and was giving gateway errors. So apologies if another post shows up at some point.)

 

Ok. So I haven't dealt much with quests yet. Is there something about the setup of the quest that... for lack of a better word... monitors the target object reference in order to know when to trigger? I'm assuming we're not just putting a trigger condition onto another object, seems I'm assuming this would somehow require altering a vanilla object somewhere. I'm just trying to understand how the pieces work.

 

Thanks!

Link to comment
Share on other sites

For more info on Reference Alias script, you can go here: https://www.creationkit.com/index.php?title=ReferenceAlias_Script. At the bottom it says ReferenceAliases receive events from the ObjectReference they are pointing at. So, all you have to do is fill your reference alias with the objectreference you want to receive events from. In Fallout 4 they added the RegisterForRemoteEvent function, which would have been nice to have in Skyrim, but referencealias's will work just as well.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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