Heromaster Posted September 13, 2013 Share Posted September 13, 2013 I borrowed a function from the CK wiki which should help me to find the target I'm talking too. But it seems I don't know how to implement it correctly. TestScript Scriptname TestScript Actor Function GetPlayerDialogueTarget() Debug.MessageBox("Just checking") Actor kPlayerRef = Game.GetPlayer() Actor kTargetRef = None Actor kNthRef = None Cell kCell = kPlayerRef.GetParentCell() Int iType = 43 ; kNPC = 43 Int iIndex = kCell.GetNumRefs( iType ) While iIndex && !kTargetRef iIndex -= 1 kNthRef = kCell.GetNthRef( iIndex, iType ) as Actor If kNthRef != kPlayerRef && kNthRef.IsInDialogueWithPlayer() kTargetRef = kNthRef EndIf EndWhile Return kTargetRef EndFunction Script fragment in a TopicInfo ;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment ;NEXT FRAGMENT INDEX 2 Scriptname _GetDialogueTarget Extends TopicInfo Hidden ;BEGIN FRAGMENT Fragment_1 Function Fragment_1(ObjectReference akSpeakerRef) Actor akSpeaker = akSpeakerRef as Actor ;BEGIN CODE TargetNPC.ForceRefTo(TavernJob.GetPlayerDialogueTarget()) (TargetNPC.GetRef() as Actor).OpenInventory() ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin comment TestScript Property TestScript Auto ReferenceAlias Property TargetNPC Auto I put into the TestScript a MessageBox to see if it is getting called but it never pops up. Both scripts are compiled successfully. The original script had the function extended with a global keyword. But then the second script fails to compile. It say something like cannot call the global function.... And I don't know how to rewrite the call. Link to comment
Heromaster Posted September 13, 2013 Author Share Posted September 13, 2013 Umm, problem solved I guessed. It was more easy than I figured. Just TargetNPC.ForceRefTo(akSpeaker) did the trick. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.