Page 1 of 1

GRRRR!!! (script not working)

Posted: Sun Jun 10, 2007 4:22 pm
by Magelord648
I've spent ages making this script. It's not finished but I went to back it up and it's telling me the spell uvirith_enchant_book_sp can't be found. It's definitely there sitting in the spell list, saved at least ten times as well as an updated version of the plugin. I substituted the spell for fire bite as a test and the error moved to line 77 which was the next reference of the spell. This is really annoying me. I'm not that sure whether it's the spell or the script but I've spent a whole half hour tinkering with stuff and nothing has succeeded. Please help.
Thanks
ML

Code: Select all

Begin uvirith_enchanttome

short button
short questionState

if ( OnActivate == 1 )
	Set questionState to 1
	Return
endif

if ( questionState == 0 )
	Return
endif


if ( questionState == 1 )

	if ( Player->GetItemCount Misc_soulgem_petty > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_soulgem_lesser > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_soulgem_common > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_soulgem_greater > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_soulgem_grand > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_SoulGem_Azura > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

endif

if ( questionState == 2 )

	set button to GetButtonPressed

	if ( button == 1 )
		Set questionState to 0
		Return
	endif

	if ( button == 0 )

		if ( Player->GetItemCount Misc_soulgem_petty > 0 )
			Player->equip Misc_soulgem_petty
			MessageBox "The Grace of Pride: Thank you for your pride, Lord Vivec. I shall not doubt myself, or my people, or my gods, and shall insist upon them, and my ancient rights."
			[color="Red"]Cast uvirith_enchant_book_sp Player[/color]
			Set questionState to 0
		endif

		if ( Player->GetItemCount Misc_soulgem_lesser > 0 )
			Player->equip Misc_soulgem_lesser
			MessageBox "The Grace of Pride: Thank you for your pride, Lord Vivec. I shall not doubt myself, or my people, or my gods, and shall insist upon them, and my ancient rights."
		        [color="Red"]Cast uvirith_enchant_book_sp Player[/color]
			Set questionState to 0
		endif

		if ( Player->GetItemCount Misc_soulgem_common > 0 )
			Player->equip Misc_soulgem_common
			MessageBox "The Grace of Pride: Thank you for your pride, Lord Vivec. I shall not doubt myself, or my people, or my gods, and shall insist upon them, and my ancient rights."
			[color="Red"]Cast uvirith_enchant_book_sp Player[/color]
			Set questionState to 0
		endif

		if ( Player->GetItemCount Misc_soulgem_greater > 0 )
			Player->equip Misc_soulgem_greater
			MessageBox "The Grace of Pride: Thank you for your pride, Lord Vivec. I shall not doubt myself, or my people, or my gods, and shall insist upon them, and my ancient rights."
			[color="Red"]Cast uvirith_enchant_book_sp Player[/color]
			Set questionState to 0
		endif

		if ( Player->GetItemCount Misc_soulgem_grand > 0 )
			Player->equip Misc_soulgem_grand
			MessageBox "The Grace of Pride: Thank you for your pride, Lord Vivec. I shall not doubt myself, or my people, or my gods, and shall insist upon them, and my ancient rights."
			[color="Red"]Cast uvirith_enchant_book_sp Player[/color]
			Set questionState to 0
		endif

	endif
	endif


End

Posted: Sun Jun 10, 2007 5:03 pm
by galraen
Unfortunately I'm down in Cornwall at the moment so don't have access to the CS. If you haven't made progress by Friday (when I get back to London) I'll look into it.

The only thing I can suggest off the top of my head is to try putting the name of the spell in double quotes. I.E "uvirith_enchant_book_sp"

Posted: Mon Jun 11, 2007 12:33 am
by Magelord648
I tried that as well. Would restarting the CS work?

Posted: Mon Jun 11, 2007 9:30 am
by Magelord648
I restarted the CS and it worked. I wasted a whole hour of my life trying to get that right. I could of been doing something much better during that time. (11PM-12AM) Like sleeping! Thanks anyway.

Posted: Thu Jun 14, 2007 1:35 pm
by Magelord648
I've got another problem. The spell won't remove at the end. Please help.

Code: Select all

Begin uvirith_enchanttome
;This is version 1.9
;The spell does not currently cast at the same time, this version attempts to fix that seeing that version 1.2 failed
;Version 1.3 failed due to problems with the menu mode and the removing of the spell which has been changed to a curse instead of a spell being cast on a player
;Version 1.4 failed for the same reason as version 1.3, It turns out all I did was move some stuff about pointlessly
;Version 1.5 failed for the same reasons
;Version 1.6 failed due to the spell being removed at the wrong time
;Version 1.7 failed for the same reasons as 1.6 but I've nearly got it
;Version 1.8 failed because, yes you guessed it, the spell was removed at the wrong time
;If this script is being used in a different mod please use different spell IDs and change the name of the script

short button
short questionState

if (menumode == 1)
return
endif

if ( OnActivate == 1 )
player->addspell uvirith_enchant_book_sp
	Set questionState to 1
	Return
endif

if ( questionState == 0 )
	Return
endif


if ( questionState == 1 )

	if ( Player->GetItemCount Misc_soulgem_petty > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_soulgem_lesser > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_soulgem_common > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_soulgem_greater > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_soulgem_grand > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_SoulGem_Azura > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

endif

if ( questionState == 2 )

	set button to GetButtonPressed

	if ( button == 1 )
player->removespell uvirith_enchant_book_sp
		Set questionState to 0
		Return
	endif

	if ( button == 0 )		
               

		if ( Player->GetItemCount Misc_soulgem_petty > 0 )
			Player->equip Misc_soulgem_petty
Set questionState to 0
		endif

		if ( Player->GetItemCount Misc_soulgem_lesser > 0 )
			Player->equip Misc_soulgem_lesser
Set questionState to 0
		endif

		if ( Player->GetItemCount Misc_soulgem_common > 0 )
			Player->equip Misc_soulgem_common
Set questionState to 0
		endif

		if ( Player->GetItemCount Misc_soulgem_greater > 0 )
			Player->equip Misc_soulgem_greater
Set questionState to 0
		endif

		if ( Player->GetItemCount Misc_soulgem_grand > 0 )
			Player->equip Misc_soulgem_grand
Set questionState to 0
		endif

           if ( Player->GetItemCount Misc_SoulGem_Azura > 0 )
			Player->equip Misc_SoulGem_Azura
Set questionState to 0
		endif

MessageBox "You stare into the pages of the book and feel empowered by the knowledge that radiates from the ancient texts."
	
if (menumode == 0 )
return

	endif
	endif
	endif

if (menumode == 1)
elseif (cellchanged == 1)
player->removespell uvirith_enchant_book_sp
	
else
Return
endif

End

Posted: Thu Jun 14, 2007 3:05 pm
by galraen
Having just glanced at it it seems to me that you need to find a way to get past the first <if (menumode == 1)> in order to make the subsequent <if (menumode == 1)>'s to function.

Posted: Thu Jun 14, 2007 3:14 pm
by Magelord648
You mean the one right at the top?

Posted: Thu Jun 14, 2007 4:10 pm
by galraen
Magelord648 wrote:You mean the one right at the top?
Yes, as the script stands at the moment it prevents the script reader from reaching the last one it looks like to me.

Posted: Fri Jun 15, 2007 1:03 am
by Magelord648
It gets past that. It only stops working when you close the enchanting screen. The spell is supposed to be removed but it isn't.

Posted: Fri Jun 15, 2007 5:42 am
by galraen
Could you tell us what exactly you're trying to accomplish?

I get the impression that on reading the book a spell that fortifies Enchant (and maybe Int and Luck) is cast on the PC; the script is then supposed to 'activate' the weakest soul gem in the PC's inventory for enchanting purposes; the PC then selects the item to be enchanted and the powers to be enchanted; on completion the spell is then supposed to be de-activated.

If that is what you're trying to accomplish I salute your ambition, 'cos that's one complex and darn near impossible undertaking. I can only assume that I've mis-interpreted what you're trying to achieve, so please enlighten me. If you don't wnat to 'go public', then just pm me.

That aside, do either of the removespell functions work?

Posted: Fri Jun 15, 2007 9:21 am
by Magelord648
Pretty much.

When the book (with the script attached) is activated the spell is added to the inventory. The PC is then asked if they want to enchant an item and if they click no the script stops and the spell goes. If the PC clicks yes the spell stays. Originally the spell went before you got to the enchant screen due to a command that removed the spell when out of menu mode. This was because when you select whether you want to make or recharge an item the message box doesn't count as menu mode. I fixed this by adding a menu mode checker that returns if not in menu mode. As soon as you get to the enchant screen this is passed. My problem is when you come out of the enchant or recharge screen the spell doesn't remove like it did before. So then I simply changed it so when the pc changes a cell or tries to go into the menu the spell will remove. That doesn't work either.

I hope that sheds a little light on the situation.

Posted: Fri Jun 15, 2007 11:28 am
by galraen
I know we're getting away from your original query, but why are you using addspell and not the
<Cast, "uvirith_enchant_book_sp", Player> function?

Posted: Fri Jun 15, 2007 12:02 pm
by Magelord648
When you cast it the spell doesn't get cast until when the menus stop which is after the enchant ones so all you get is something to equip your soulgems for you. Si to get around it I changed the spell to a curse in Version 1.3. This way is effective and it works but removing the spell is where it doesn't work.

This is version 1.2. It uses the cast command and if you test it you will find that it doesn't get a chance to cast until after the menus go.

Code: Select all

Begin uvirith_enchanttome
;This is version 1.1
;The spell does not currently cast at the same time
;If this script is being used in a different mod please use different spell IDs and change the name of the script

short button
short questionState

if ( OnActivate == 1 )
	Set questionState to 1
	Return
endif

if ( questionState == 0 )
	Return
endif


if ( questionState == 1 )

	if ( Player->GetItemCount Misc_soulgem_petty > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_soulgem_lesser > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_soulgem_common > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_soulgem_greater > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_soulgem_grand > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

	if ( Player->GetItemCount Misc_SoulGem_Azura > 0 )
		MessageBox "Would you like to study the book to Enchant an Item?" "Yes" "No"
		Set questionState to 2
		Return
	endif

endif

if ( questionState == 2 )

	set button to GetButtonPressed

	if ( button == 1 )
		Set questionState to 0
		Return
	endif

	if ( button == 0 )

		if ( Player->GetItemCount Misc_soulgem_petty > 0 )
			Player->equip Misc_soulgem_petty
Cast uvirith_enchant_book_sp Player		

	
			Set questionState to 0
		endif

		if ( Player->GetItemCount Misc_soulgem_lesser > 0 )
			Player->equip Misc_soulgem_lesser
Cast uvirith_enchant_book_sp Player				
			Set questionState to 0
		endif

		if ( Player->GetItemCount Misc_soulgem_common > 0 )
			Player->equip Misc_soulgem_common
Cast uvirith_enchant_book_sp Player			
				Set questionState to 0
		endif

		if ( Player->GetItemCount Misc_soulgem_greater > 0 )
			Player->equip Misc_soulgem_greater
Cast uvirith_enchant_book_sp Player	
			Set questionState to 0
		endif

		if ( Player->GetItemCount Misc_soulgem_grand > 0 )
			Player->equip Misc_soulgem_grand
Cast uvirith_enchant_book_sp Player				
			Set questionState to 0
		endif

           if ( Player->GetItemCount Misc_SoulGem_Azura > 0 )
			Player->equip Misc_SoulGem_Azura
Cast uvirith_enchant_book_sp Player			
			Set questionState to 0
		endif

MessageBox "You stare into the pages of the book and fell empowered by the knowledge that radiates from the ancient texts."
			

	endif
	endif


End

Posted: Tue Jun 26, 2007 11:53 am
by Magelord648
I don't think anyone is checking this any more but I got it working. I added a message box with a button at the end which when pressed removed the spell.

Thanks for the help everyone!
I salute your ambition, 'cos that's one complex and darn near impossible undertaking.
I rule. :laugh: