Jump to content

How to pass variables (especially strings) from "actionscript" to a papyrus script?


Recommended Posts

Good morning everybody!

 

I know that you can do some cool stuff with actionscript.

And I know that you can do some cool stuff with papyrus scripts.

 

But how can I "send" a variable from a actionscript-script to a papyrus script?

 

For example, I want to set up a custom terminal where the user can enter some text. (can easily be done in actionscript).

And I want to have a script attached to taht terminal that will control some "in-game" stuff (enable and disable things, ...) based on what text was entered into the actionscript-thing.

 

So, how would this be done?

 

I have found some mods that have "user entered text", like the "journal of the sole survivor" mod, but that does everything (except giving the player the holotape) in actionscript and doesn't actually "interface" with the "papyrus scripting system" ...

 

 

Any help would be appreciated ...

Link to comment
Share on other sites

I asked time ago to Scrivener07 about this same question, didn't tried it myself so I don't have experience implementing it, but he points out the key for this end (SendExternalEvent), that's how the conversation went:

 

Scrivener07:
We can send events with all custom parameters from AS3 to Papyrus.
its called ExternalEvent
DieFeM:
Hmmm, interesting... I'm intrigued, how does it work?
Is there any example in one of your other projects?
Scrivener07:
Yea, I use the XSE.as API.
After a hud overlay gets loaded on the UI I send an event to papyrus.
DieFeM:
So, I've been looking at this, but there's something I don't quite understand, where is defined the "callback" function, the one that receives the event, because I see the as3 sends an event with:
XSE.SendExternalEvent(AssetLoadedEvent, true, client);
And that this variable contains a script path
private const AssetLoadedEvent:String = "System_UI_VisorMenu_AssetLoadedEvent";
But then I check the script in papyrus and there's a function
bool Function Send(ScriptObject sender, AssetLoadedEventArgs e)
How do I define the name of the function that receives the event, or is it always called Send??
Scrivener07:
Its not a script path or anything special. Its more of an event ID which is a const string. Papyrus will listen for an event of that name.
DieFeM:
So, where can I see an example of the papyrus side of this event?
Scrivener07:
DieFeM:
Ok, I see, now it makes sense:
string AssetLoadedEvent = "System_UI_VisorMenu_AssetLoadedEvent" const
 ... 
RegisterForExternalEvent(AssetLoadedEvent, "OnAssetLoaded")
... 
Event OnAssetLoaded(bool success, string instance)
thank you btw

 

 

Link to comment
Share on other sites

 

I asked time ago to Scrivener07 about this same question, didn't tried it myself so I don't have experience implementing it, but he points out the key for this end (SendExternalEvent), that's how the conversation went:

 

Scrivener07:
We can send events with all custom parameters from AS3 to Papyrus.
its called ExternalEvent
DieFeM:
Hmmm, interesting... I'm intrigued, how does it work?
Is there any example in one of your other projects?
Scrivener07:
Yea, I use the XSE.as API.
After a hud overlay gets loaded on the UI I send an event to papyrus.
DieFeM:
So, I've been looking at this, but there's something I don't quite understand, where is defined the "callback" function, the one that receives the event, because I see the as3 sends an event with:
XSE.SendExternalEvent(AssetLoadedEvent, true, client);
And that this variable contains a script path
private const AssetLoadedEvent:String = "System_UI_VisorMenu_AssetLoadedEvent";
But then I check the script in papyrus and there's a function
bool Function Send(ScriptObject sender, AssetLoadedEventArgs e)
How do I define the name of the function that receives the event, or is it always called Send??
Scrivener07:
Its not a script path or anything special. Its more of an event ID which is a const string. Papyrus will listen for an event of that name.
DieFeM:
So, where can I see an example of the papyrus side of this event?
Scrivener07:
DieFeM:
Ok, I see, now it makes sense:
string AssetLoadedEvent = "System_UI_VisorMenu_AssetLoadedEvent" const
 ... 
RegisterForExternalEvent(AssetLoadedEvent, "OnAssetLoaded")
... 
Event OnAssetLoaded(bool success, string instance)
thank you btw

 

 

 

Thanks for that!

I will check those examples out!

Edited by YouDoNotKnowMyName
Link to comment
Share on other sites

  • Recently Browsing   0 members

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