Scriptname SpecialTypeint istring sfunction SetInt(int myInt)i = myIntendFunctionfunction SetString(string myString)s = myStringendFunctionint function GetInt()return iendFunctionstring function GetString()return sendFunction
...that defines the "member methods" of SpecialType.
I then have this script attached to a quest:
scriptname _TEST_TypeTest extends Questimport debugSpecialType appleSpecialType bananaEvent OnInit()RegisterForSingleUpdate(3)endEventEvent OnUpdate()apple.SetInt(5)banana.SetString("bob");Display the values storednotification("apple = " + apple.GetInt())notification("banana = " + banana.GetString())RegisterForSingleUpdate(3)endEvent
In-game, I receive this feedback via notification:
apple = 0
banana =
banana =
Papyrus logs report the following:
[07/17/2012 - 07:55:47PM] error: Cannot call SetInt() on a None object, aborting function callstack:[_TestQuest (02000D62)]._TEST_TypeTest.OnUpdate() - "_TEST_TypeTest.psc" Line 13[07/17/2012 - 07:55:47PM] error: Cannot call SetString() on a None object, aborting function callstack:[_TestQuest (02000D62)]._TEST_TypeTest.OnUpdate() - "_TEST_TypeTest.psc" Line 14[07/17/2012 - 07:55:47PM] error: Cannot call GetInt() on a None object, aborting function callstack:[_TestQuest (02000D62)]._TEST_TypeTest.OnUpdate() - "_TEST_TypeTest.psc" Line 17[07/17/2012 - 07:55:47PM] warning: Assigning None to a non-object variable named "::temp1"stack:[_TestQuest (02000D62)]._TEST_TypeTest.OnUpdate() - "_TEST_TypeTest.psc" Line 17[07/17/2012 - 07:55:47PM] error: Cannot call GetString() on a None object, aborting function callstack:[_TestQuest (02000D62)]._TEST_TypeTest.OnUpdate() - "_TEST_TypeTest.psc" Line 18
What I'm essentially trying to do is instantiate a new object with their own member variables. Apple's GetInt() call should return a different result than Banana's GetInt(), and so on.
Is there a way of implementing this in Papyrus?