Message won't show OnSpellCast

Post » Tue Jun 19, 2012 12:57 pm

Hello fellow scripters, it seems as I've run into some trouble.

It's a fairly short script, all I need it to do is show a messagebox containing some buttons to the player.
It is supposed to run when you use a certain spell.

The code:
Spoiler
Scriptname VampireMenu extends activemagiceffect{This script handles the vampire menu showing.}Message Property Vampire  AutoSPELL Property VampireMenuSpell  AutoEvent OnSpellCast(Form akSpell)if (akSpell == VampireMenuSpell)  Debug.MessageBox("Hello world")  Vampire.Show()endifEndEvent

The debug message isn't really needed, but I just added it for well... debug purposes.

The spell is a fire and forget voice equipped lesser power with a effect that does nothing, but is just there for debug purposes.

I've tried adding the script to the magic effect with no luck. I've tried adding it to a quest which handles the vampire related things. That did not work either. So I tried adding another effect to the spell to see if the spell itself was broken, but no, the spell fired. The script did not.

I tried changing the script to OnActivate and placed it on a book (altered the script to function for a book by removing the if statement) but that did not work either.
So now I'm turning to you guys to help me.

//BadDevilGrind
User avatar
Angus Poole
 
Posts: 3594
Joined: Fri Aug 03, 2007 9:04 pm

Post » Tue Jun 19, 2012 10:52 am

Have you assigned the "VampireMenuSpell" variable to a spell within the editor, through the script properties section? (if you look at the wiki tutorials, they show you how to do this with the multiple message boxes, but the UI looks slightly different when accessing it from a spell script).
User avatar
Danielle Brown
 
Posts: 3380
Joined: Wed Sep 27, 2006 6:03 am

Post » Tue Jun 19, 2012 8:28 am

Yes, I have assigned it to the spell which I call Vamp_VampireMenuin the editor
User avatar
Gill Mackin
 
Posts: 3384
Joined: Sat Dec 16, 2006 9:58 pm

Post » Tue Jun 19, 2012 4:40 am

You're using the wrong event i think. OnSpellCast is the event that fires when the object casts a spell. For example if this script was on an npc, the event would fire when the npc cast any spell. If you want your code to be run when someone uses your spell I believe you would want to use the OnEffectStart or the OnInit events.
User avatar
Emilie Joseph
 
Posts: 3387
Joined: Thu Mar 15, 2007 6:28 am

Post » Tue Jun 19, 2012 2:03 am

You're using the wrong event i think. OnSpellCast is the event that fires when the object casts a spell. For example if this script was on an npc, the event would fire when the npc cast any spell. If you want your code to be run when someone uses your spell I believe you would want to use the OnEffectStart or the OnInit events.
Thanks for the tip, that seemed to do it :)

I used the OnEffectStart event and it worked like a charm :)
User avatar
Marcin Tomkow
 
Posts: 3399
Joined: Sun Aug 05, 2007 12:31 pm

Post » Tue Jun 19, 2012 1:04 am

:]
User avatar
Claire Mclaughlin
 
Posts: 3361
Joined: Mon Jul 31, 2006 6:55 am


Return to V - Skyrim