Possible to call AttachPapyrusScript from inside Papyrus?

Post » Mon Jun 18, 2012 4:04 pm

There is a console command "AttachPapyrusScript" documented on the creation kit wiki. It would be incredibly useful to be able to call this from inside a Papyrus script. Does anyone know of a way to call this, or other console commands? I tried the obvious things of just calling it as a function, calling it as a member of Game and Debug, and no dice.

What I'm trying to do is attach scripts to all the book objects, without having to modify all the book objects in the CK. I've actually done this, but it has some major downsides, like turning all the text into English for players with German, French, etc. versions of the game. Anyone have any other ideas on how to accomplish this? I'm wondering if I can do something really really hacky with Quest aliases.
User avatar
Sammykins
 
Posts: 3330
Joined: Fri Jun 23, 2006 10:48 am

Post » Mon Jun 18, 2012 10:33 am

Many console functions simply aren't available in Papyrus, and it looks like this is one of them.

You could try modifying the "Book" script, but this would obviously conflict with anyone else that wants to do the same, and probably have issues with any books that have a script attached that extends Book and overrides whatever functions (including events) you may have defined.

Cipscis
User avatar
Facebook me
 
Posts: 3442
Joined: Wed Nov 08, 2006 8:05 am

Post » Mon Jun 18, 2012 11:11 pm

As a followup, after some wiki reading, I'm using Quest Aliases, and I almost have it working. The main roadblock right now is that I get an OnInit() event when an alias is "attached" to a (Book) ObjectReference, but I don't get any event when the alias is "detached".
User avatar
Taylrea Teodor
 
Posts: 3378
Joined: Sat Nov 18, 2006 12:20 am

Post » Tue Jun 19, 2012 2:58 am

As a followup, after some wiki reading, I'm using Quest Aliases, and I almost have it working. The main roadblock right now is that I get an OnInit() event when an alias is "attached" to a (Book) ObjectReference, but I don't get any event when the alias is "detached".

Well presuming that your own code is doing the "detatching", it should know when it's doing it, right? If you save some information on the connection, you should be able to do the equivalent of making your own "event"

Unfortunately there's no equivalent of a New() constructor for abstract object types in papyrus. You can't just make an object with no model, you need to use a PlaceAtMe() function instead. I ran into that issue trying to implement a linked list in Papyrus...it ain't easy. They mention "linked References" in the documentation, but you can't use a script to SET them (though there are plenty of Get and Count functions), so if you want a fully usable linked list, you have to implement it yourself.
User avatar
Guinevere Wood
 
Posts: 3368
Joined: Mon Dec 04, 2006 3:06 pm

Post » Mon Jun 18, 2012 9:19 pm

The "filling" of Aliases with ObjectReferences is done by the Radiant Story Manager. "Unfilling" happens, I guess, when the quest is stopped and/or reset. My solution was overriding Quest.Stop() in my script with a version that uses GetAlias(index) in a loop to access and cleanup. After the cleanup is done I call parent.Stop(). It works... ok. One issue is that the loop can run slowly if you call latent functions, so it may take a long time (seconds) for the quest to actually stop, which can mess up the timing of other things.
User avatar
Mari martnez Martinez
 
Posts: 3500
Joined: Sat Aug 11, 2007 9:39 am


Return to V - Skyrim