Struct PapyrusCall
- Namespace
- SkyrimForge.Papyrus
- Assembly
- SkyrimForge.Game.dll
Arguments passed to a native Papyrus function and the variable for its return value.
public readonly ref struct PapyrusCall
- Inherited Members
Remarks
Valid only for the duration of the call, so a value needed afterwards must be copied out.
It is a ref struct, so code that would retain it past the call, in a lambda, an async method, or a field, does not compile.
In a latent function every Return throws, since that function's value is returned through PapyrusLatentCall.
Properties
Self
The receiver, read as whichever type is requested: call.Self.As<ObjectReference>().
A function registered through RegisterStatic(string, PapyrusType, string, IReadOnlyCollection<PapyrusType>, Action<PapyrusCall>) is static and reads None here.
public PapyrusValue Self { get; }
Property Value
Remarks
It occupies no argument index, the Papyrus virtual machine passing it beside the arguments, so it counts against neither the indices nor the eleven-parameter limit.
Exceptions
- InvalidOperationException
The call has no receiver, the dispatch disagreeing with itself rather than anything a script can cause.
Methods
GetArgument(int)
Reads the argument at index as whichever type is requested of it: call.GetArgument(0).Int.
public PapyrusValue GetArgument(int index)
Parameters
indexint
Returns
Exceptions
- ArgumentOutOfRangeException
The function declares no argument at that index, which can only be this implementation disagreeing with the signature it registered. The Papyrus virtual machine checks a caller against the declared parameters, so a script cannot cause it.
Return(Array)
Sets the return value to an array, entries and order as supplied.
public void Return(Array values)
Parameters
valuesArray
Remarks
Every entry must be of the array type the function was registered as returning: int, float, bool, string, or form.
A null entry reads in the script as the value a newly allocated array contains: 0, 0.0, false, the empty string, or None.
Exceptions
- ArgumentNullException
valuesisnull.- InvalidOperationException
An entry is not of the type the function was registered as returning, the function was registered as latent, or the Papyrus VM would not allocate the array or allocated one of another length. A Papyrus array stores at most 128 entries.
- NotSupportedException
An entry is of a type with no Papyrus equivalent.
Return(bool)
Sets the return value to a bool.
public void Return(bool value)
Parameters
valuebool
Exceptions
- InvalidOperationException
The function was registered as latent, whose value goes through PapyrusLatentCall.
Return(int)
Sets the return value to an int.
public void Return(int value)
Parameters
valueint
Exceptions
- InvalidOperationException
The function was registered as latent, whose value goes through PapyrusLatentCall.
Return(float)
Sets the return value to a float.
public void Return(float value)
Parameters
valuefloat
Exceptions
- InvalidOperationException
The function was registered as latent, whose value goes through PapyrusLatentCall.
Return(string)
Sets the return value to a string.
public void Return(string value)
Parameters
valuestring
Exceptions
- ArgumentNullException
valueisnull.- InvalidOperationException
The function was registered as latent, whose value goes through PapyrusLatentCall.
Return<TForm>(TForm?)
Sets the return value to a form, bound to the class the function was registered as returning, or to None where form is null.
public void Return<TForm>(TForm? form) where TForm : struct, IForm
Parameters
formTForm?
Type Parameters
TForm
Exceptions
- InvalidOperationException
The function was registered as latent, whose value goes through PapyrusLatentCall.
Return<TForm>(TForm)
Sets the return value to a form, bound to the class the function was registered as returning rather than to the class the form itself is.
public void Return<TForm>(TForm form) where TForm : IForm
Parameters
formTForm
Type Parameters
TForm
Exceptions
- ArgumentNullException
formisnull.- InvalidOperationException
The function was registered as latent, whose value goes through PapyrusLatentCall.