Papyrus Compiler is babbling: It states that AddPerk and Add

Post » Tue Jun 19, 2012 9:09 am

I really don't understand what's happening. I guess some kind of bugs, because they do exist and I have imported actor! :(

Scriptname VAoNNecronomiconInteraction extends ObjectReference  import actorMessage[] Property arMessageList  Auto  SPELL[] Property arNecronomiconSpells  Auto  Perk[] Property arNecronomiconPerks  Auto  Event OnInit()    Self.BlockActivation()EndEventEvent OnActivate(ObjectReference akActionRef)    int iMenuSelection    int iKnowledgeSelection    iMenuSelection = arMessageList[0].Show()    if iMenuSelection == 0        akActionRef.AddItem(Self, 1)        elseif iMenuSelection == 1                Self.Activate(akActionRef, true)    elseif iMenuSelection == 2        iKnowledgeSelection = arMessageList[1].Show()        if iKnowledgeSelection == 0            akActionRef.AddPerk(arNecronomiconPerks[0])            arMessageList[2].Show()                            elseif iKnowledgeSelection == 1            akActionRef.AddPerk(arNecronomiconPerks[1])            arMessageList[2].Show()                elseif iKnowledgeSelection == 2            akActionRef.AddSpell(arNecronomiconSpells[0])        elseif iKnowledgeSelection == 3            akActionRef.AddSpell(arNecronomiconSpells[1])        elseif iKnowledgeSelection == 4            akActionRef.AddSpell(arNecronomiconSpells[2])        endif    endifEndEvent

I'd like to understand why this foolish compiler refuses to compile my script...any suggestion? :(

Thanks,
Jashkar
User avatar
Matt Terry
 
Posts: 3453
Joined: Sun May 13, 2007 10:58 am

Post » Tue Jun 19, 2012 7:10 pm

Mmmmh...I've found out!!

It didn't recognize the actor as actor, but as objectreference! :(

Jashkar
User avatar
Mashystar
 
Posts: 3460
Joined: Mon Jul 16, 2007 6:35 am

Post » Tue Jun 19, 2012 8:02 am

Mmmmh...I've found out!!

It didn't recognize the actor as actor, but as objectreference! :(

As it should.

Event OnActivate( ObjectReference akActionRef )
User avatar
stacy hamilton
 
Posts: 3354
Joined: Fri Aug 25, 2006 10:03 am

Post » Tue Jun 19, 2012 3:10 pm

Importing a script just means you can call any global functions it defines without a prefix, so long as there's no ambiguity. The http://www.creationkit.com/Actor_Script doesn't define any global functions, though, so importing it is absolutely useless.

As you've discovered those functions actually don't exist on objects of type http://www.creationkit.com/ObjectReference_Script. You'll need to manually cast your object to type http://www.creationkit.com/Actor_Script if you can only get it in ObjectReference form but need to call Actor functions on it. If the ObjectReference isn't an actor, then the result of the cast will be None, so unless you're entirely confident it won't ever be the case, it's best to check for that.

Cipscis
User avatar
Quick draw II
 
Posts: 3301
Joined: Thu Nov 08, 2007 4:11 pm

Post » Tue Jun 19, 2012 6:12 am

As it should.

Event OnActivate( ObjectReference akActionRef )

Emmmh...right. :|

Importing a script just means you can call any global functions it defines without a prefix, so long as there's no ambiguity. The http://www.creationkit.com/Actor_Script doesn't define any global functions, though, so importing it is absolutely useless.

As you've discovered those functions actually don't exist on objects of type http://www.creationkit.com/ObjectReference_Script. You'll need to manually cast your object to type http://www.creationkit.com/Actor_Script if you can only get it in ObjectReference form but need to call Actor functions on it. If the ObjectReference isn't an actor, then the result of the cast will be None, so unless you're entirely confident it won't ever be the case, it's best to check for that.

Cipscis

Oh...well...no...I already have problems when doing things which are quite simple...I'll not attempt do things I am not confident... :)

However, thanks for the info,
Jashkar
User avatar
Cayal
 
Posts: 3398
Joined: Tue Jan 30, 2007 6:24 pm

Post » Tue Jun 19, 2012 1:45 pm

All you should need to do is something like below

I really don't understand what's happening. I guess some kind of bugs, because they do exist and I have imported actor! :(

Scriptname VAoNNecronomiconInteraction extends ObjectReference  Message[] Property arMessageList  Auto  SPELL[] Property arNecronomiconSpells  Auto  Perk[] Property arNecronomiconPerks  Auto  Event OnInit()	Self.BlockActivation()   ; -> Why block Activation ? all this does is block normal activation(opening containers and such) it does not stop onActivate scripts from running, maybe that is your desired effect.EndEventEvent OnActivate(ObjectReference akActionRef)	Actor akActor = akActionRef As Actor	If akActor != None   ; -> this should always return a None to any ObjectReference that is not a Actor.	int iMenuSelection	int iKnowledgeSelection	iMenuSelection = arMessageList[0].Show()	if iMenuSelection == 0		akActor.AddItem(Self, 1)		elseif iMenuSelection == 1				Self.Activate(akActor, true)	elseif iMenuSelection == 2		iKnowledgeSelection = arMessageList[1].Show()		if iKnowledgeSelection == 0			akActor.AddPerk(arNecronomiconPerks[0])			arMessageList[2].Show()							elseif iKnowledgeSelection == 1			akActor.AddPerk(arNecronomiconPerks[1])			arMessageList[2].Show()				elseif iKnowledgeSelection == 2			akActor.AddSpell(arNecronomiconSpells[0])		elseif iKnowledgeSelection == 3			akActor.AddSpell(arNecronomiconSpells[1])		elseif iKnowledgeSelection == 4			akActor.AddSpell(arNecronomiconSpells[2])		endif	endif	EndifEndEvent
User avatar
OTTO
 
Posts: 3367
Joined: Thu May 17, 2007 6:22 pm


Return to V - Skyrim