Pickysaurus Posted January 28, 2017 Share Posted January 28, 2017 Hi there, I'm having some trouble with excuting a script function in dialogue; I have a main script that is an extension of a script in another mod - and I am calling the function of my new script via a TIF (Topic Info) script. Papyrus gives me the following error. Starting 1 compile threads for 1 files...Compiling "PKY_TIF__060F8AE5"...C:\Games\steamapps\common\skyrim\Data\Scripts\Source\temp\PKY_TIF__060F8AE5.psc(9,23): cannot call the member function MoveDevAveza alone or on a type, must call it on a variableNo output generated for PKY_TIF__060F8AE5, compilation failed.Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on PKY_TIF__060F8AE5 The code for the script is; ;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment ;NEXT FRAGMENT INDEX 1 Scriptname PKY_TIF__060F8AE5 Extends TopicInfo Hidden ;BEGIN FRAGMENT Fragment_0 Function Fragment_0(ObjectReference akSpeakerRef) Actor akSpeaker = akSpeakerRef as Actor ;BEGIN CODE PKY_DevAvezaMoveScript.MoveDevAveza() ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin comment Int Property PKY_MoveDevAveza Auto And it's calling the function from PKY_DevAvezaMoveScript which looks like this; Scriptname PKY_DevAvezaMoveScript extends DBM_AirshipScript Int Property PKY_MoveDevAveza Auto Function MoveDevAveza() DBM_Destination.SetValue(PKY_MoveDevAveza) If DBM_Destination.Value == 1 ShipRefPalePass.Enable() elseif DBM_Destination.Value == 2 ShipRefRavenRock.Enable() elseif DBM_Destination.Value == 3 ShipRefMiraakTemple.Enable() elseif DBM_Destination.Value == 4 ShipRefDawnguard.Enable() elseif DBM_Destination.Value == 5 ShipRefWhiterun.Enable() elseif DBM_Destination.Value == 6 ShipRefMarkarth.Enable() elseif DBM_Destination.Value == 7 ShipRefRiften.Enable() elseif DBM_Destination.Value == 8 ShipRefSolitude.Enable() elseif DBM_Destination.Value == 9 ShipRefTelMithryn.Enable() elseif DBM_Destination.Value == 10 ShipRefWinterhold.Enable() elseif DBM_Destination.Value == 11 ShipRefWindhelm.Enable() elseif DBM_Destination.Value == 12 ShipRefFalkreath.Enable() elseif DBM_Destination.Value == 13 ShipRefHH.Enable() elseif DBM_Destination.Value == 14 ShipRefVolkihar.Enable() elseif DBM_Destination.Value == 15 ShipRefDawnstar.Enable() elseif DBM_Destination.Value == 16 ShipRefRorikstead.Enable() elseif DBM_Destination.Value == 17 ShipRefLabyrinthian.Enable() elseif DBM_Destination.Value == 18 ShipRefDeepholme.Enable() endif ResetShipRefs() EndFunction Can anyone help me understand what I'm doing wrong? Specifically "cannot call the member function MoveDevAveza alone or on a type, must call it on a variable" - the function doesn't need to call a variable AFAIK. I have tried putting PKY_MoveDevAveza between the function brackets but I then get "Too many arguments". Thanks Link to comment Share on other sites More sharing options...
Surilindur Posted January 28, 2017 Share Posted January 28, 2017 (edited) I think the issue is related to you trying to call a function from a script that is not attached to an object - specifically, a script that is of a specific type to require being attached to an object but that is not attached to an object. It is possible to create a "library" script that does not need to be attached to anything, but that library script cannot be, for example, one that extends Form (if I remember correctly). If the script extends Form, the game probably requires it to be attached to a Form. As in, if I remember correctly, you can do this: ScriptName SomeLibraryScript ; does not extend anything Function FancyFunctionForFunnyFantasies(Bool abValue) Debug.MessageBox("The opposite of " + abValue + " is " + !abValue) EndFunction ScriptName SomeObjectScript Extends ObjectReference ; should compile without issues Event OnActivate(ObjectReference akActionRef) SomeLibraryScript.FancyFunctionForFunnyFantasies(True) EndEventBut you cannot do this: ScriptName SomeLibraryScript Extends Form ; this time, extends Form Function FancyFunctionForFunnyFantasies(Bool abValue) Debug.MessageBox("The opposite of " + abValue + " is " + !abValue) EndFunction ScriptName SomeObjectScript Extends ObjectReference ; this time, the function call here should throw the error you described ; when compiling, since SomeLibraryScript now extends Form but has not been ; attached to anything Event OnActivate(ObjectReference akActionRef) SomeLibraryScript.FancyFunctionForFunnyFantasies(True) EndEventConsidering how a large number of scripts are under Form in the "family tree" of sorts on the wiki, it could be that the script you are trying to call the function from (or one of its ancestors) extends something in the Form family tree and therefore cannot be used as a library script, but needs to be attached to an object. More about extending/inheritance on the wiki: Extending Scripts (Papyrus). I really hope I remembered it all correctly. If someone spots a mistake, feel free to correct me. :blush: Edit: For reference, you cannot do any of these, either, and they will also cause the compiler to throw the same error: ObjectReference.Delete() Actor.IsInInterior() Potion.IsHostile() Edited January 28, 2017 by Contrathetix Link to comment Share on other sites More sharing options...
Pickysaurus Posted January 28, 2017 Author Share Posted January 28, 2017 Thanks for the reply, I still can figure this out. Is it something to do with trying to fire this Function from dialogue? I'm looking at the original scripts (my mod is an expansion on another mod) and the functions are setup almost the same, just the fact it's called as Event OnActivate. I think I'm going to have to abandon the function method for now and do it manually. Link to comment Share on other sites More sharing options...
PeterMartyr Posted January 28, 2017 Share Posted January 28, 2017 (edited) Look at... (GetOwningQuest() as WhatEverScript).SomeFunction() ;For when frag & Script are all in one Quest. (SomeQuest as WhatEverScript).SomeFunction() ;When the script & frag are in diff Quests Quest Property SomeQuest Auto ScrtWhatThe.SomeFunction(); When they are in diff Quests again WhatEverScript Property ScrtWhatThe Auto (SomeAlias as WhatEverAliasScript).SomeOtherFunction() ; same or diff it's doesn't matter. Just do it, for when calling Script Attach to Alias ReferenceAlias Property SomeAlias Auto You never used any of these options to call your function. I think what you where trying to write is ScrtDevAve.PKY_MoveDevAveza = InToMove ScrtDevAve.MoveDevAveza() PKY_DevAvezaMoveScript Property ScrtDevAve Auto Int Property InToMove Auto I have no idea what your trying to Achieve, or if it will work, I only posted this to give you some examples, of calling a function in a fragment. Good luck in your scripting. Edited January 28, 2017 by PeterMartyr Link to comment Share on other sites More sharing options...
Pickysaurus Posted January 28, 2017 Author Share Posted January 28, 2017 (edited) So what I am trying to achieve is a variation on a system currently in place for Legacy of the Dragonborn by Icecreamassassin, The mod features an Airship which is a large group of statics, his version has a map and you interact with location pegs (the little red and blue flags on the map) which set DBM_Destination (Global Variable) to the relevant number. Then you interact with the ship's helm and it disables the statics of the airship you are currently on and enables the airship statics in the new location, as well as moving the player to the helm of the new airship. My desire is to be able to ask my follower "Can you move the airship for me?" and when you pick a destination, it disables the static airship currently enabled and enables only the one in the location selected. - Thus giving a way to move the ship without having to be on board it. Does that make sense? Edited January 28, 2017 by Pickysaurus Link to comment Share on other sites More sharing options...
Recommended Posts