Jump to content

Custom event WorkshopAddActor


SKKmods

Recommended Posts

If anyone has a script that is currently working with the WorkshopParent custom event WorkshopAddActor that should fire when AddPermanentActorToWorkshopPUBLIC is called (assign a companion & etc) pls let me know.

 

Several mods that have been working fine in the past are no longer receiving the event, and in testing I cant get it to generate:

WorkshopParentScript Property pWorkshopParent Auto Const Mandatory 

Self.RegisterForCustomEvent((pWorkshopParent as WorkshopParentScript), "WorkshopAddActor") 

Event WorkshopParentScript.WorkshopAddActor(WorkshopParentScript akSender, Var[] akArgs)
  ;do stuff
EndEvent
Link to comment
Share on other sites

  • 5 years later...

Sorry to necro a topic, but did you find anything further with this SKK? I found this thread after a looooong trawl through many results trying to find a solution to my issue.

I'm trying to use a similar function to add an NPC to a workshop at a certain quest stage. My NPC and my Workshop are both set up as aliases (called MyNPC and Workshop respectively), and I'm trying to use the script fragment from the Out of the Fire quest (where Jake is added to the workshop) fairly wholesale:

WorkshopScript workshopRef = Alias_Workshop.GetRef() as WorkshopScript
WorkshopParent.AddPermanentActorToWorkshopPUBLIC(Alias_MyNPC.GetActorRef(), workshopRef.GetWorkshopID())

This particular fragment doesn't have anything in kmyQuest on the original, and obviously works fine in game. However regardless of whether I try to make a full script that will trigger at the quest stage, or just a fragment on that quest stage, I can't get it to compile. I'll get the error " no viable alternative at input '.'". I've searched several topics on this and they all lead back to the same line of papyrus; WorkshopParent.AddPermanentActorToWorkshopPUBLIC etc etc, so I can't tell where mine is going wrong when it is seemingly an identical set-up to how the game handles Jake Finch.

This is my first time working with scripts, and I'm not a programmer, so maybe I'm missing something extremely obvious. But your post also makes me wonder if something about this has to be done differently now?

Link to comment
Share on other sites

Probably because you have not defined the WorkshopParent property correctly. Follow this sequence through and compile:

Quest Property WorkshopParent Auto

ReferenceAlias Property Alias_MyNPC Auto

ReferenceAlias Property Alias_Workshop Auto

Function thisFunction()

Actor thisActor = Alias_MyNPC.GetActorRef()

ObjectReference thisWorkshop = Alias_Workshop.GetReference()

Int iWorkshopID  = (thisWorkshop as WorkshopScript).GetWorkshopID()

(pWorkshopParent as WorkshopParentScript).AddPermanentActorToWorkshopPUBLIC(ThisActor, as Actor, iWorkshopID , bAutoAssign = true)

EndFunction

Link to comment
Share on other sites

Posted (edited)

Thanks as ever!

I think I vaguely understand. I had actually already set up WorkshopParent as a property in my original attempts, as well as my other aliases, but I couldn't get it working via following your sequence, regardless of whether in a fragment or a full script - I think because I don't understand enough about syntax and that kind of thing perhaps. I kept getting no viable alternative compile errors, so I definitely don't understand the process well enough to be doing it properly.

Instead I went back to the original fragment I stole from Out of the Fire and changed "pWorkshopParent" to "(pWorkshopParent as WorkshopParentScript)". Everything else remains like the original fragment. It appears to now work like a charm in testing! I still don't fully understand, because I'm exceptionally poor at understanding even fundamental programming (guess why I don't do it normally), but I think I vaguely understand how having that change seems to make it work. Which I wouldn't have known to hone in on without you pointing it out specifically, so thank you!

I imagine what I've done is a less efficient solution that is more prone to issues or something like that? I have checks earlier in the quest that ensures it cannot progress without the presence of both the actor and the player in the workshop cell so hopefully my cobbled solution ripped from a vanilla quest manages to hold up.

Thanks again. I'm just glad that the functionality does work, and the issue was my user error! At least that is fixable.

Edited by Lemecc
Link to comment
Share on other sites

  • 3 months later...

Perhaps you lot can help me. I'm trying to add some of my NPC's to the Red Rocket workstation. I dont have a clue how to do it, except that the NPC's have to carry a workshop script ( choice of 2 ). Some one passed me this in annother forum

Actor Property DocHoffSharedRef Auto            ;;; THIS DOES FILL

WorkshopParentScript Property WorkshopParent Auto Const   ;;;; THIS DOES NOT FILL

function PlayerFunction()

    int workshopID = 10     ;    RedRocketWorkshopREF

    WorkshopParent.AddPermanentActorToWorkshopPUBLIC(DocHoffSharedRef , workshopID )

endfunction

Where do I get the workshopID from ??????????????. There is no info available about workshops except from a user level, and nothing about the settlement side.

Edited by AndyTheSaurus
Link to comment
Share on other sites

  • Recently Browsing   0 members

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