Mantriel's thread

Post » Sat May 28, 2011 9:34 pm

I'm working on a quest mod, its actually quite simple, but I always get into some kind of scripting trouble.

My newest problem is a scripting one, I messed the code up somewhere.

----

My current one is:

How do you "create" an item at an exact place, with specific x, y angles/rotations, and a specific scale? I tried placeItem but it places the item always at 0,0,0 and anyway I cant rotate it on the x axle and on the y axle. :-/

I would like to create an infinte loop, where the pc takes an item, gives it to the npc, and then can start again.
Problem solved by Cyrano

User avatar
Sxc-Mary
 
Posts: 3536
Joined: Wed Aug 23, 2006 12:53 pm

Post » Sat May 28, 2011 12:37 pm

Create a new instance of an item with placeAtPC. Where you put it doesn't matter, since you'll be changing the position anyways. Then, put a script on that item that will set it's X, Y, and Z coordinates with setPos X/Y/Z. You can also use setAngle X/Y/Z to change the angle of the item you're placing. Combine those with a setScale function and wrap 'em all in a doOnce condition for the item's script and ba-da-boom, you've got what you need.
User avatar
Hope Greenhaw
 
Posts: 3368
Joined: Fri Aug 17, 2007 8:44 pm

Post » Sat May 28, 2011 5:19 pm

Create a new instance of an item with placeAtPC. Where you put it doesn't matter, since you'll be changing the position anyways. Then, put a script on that item that will set it's X, Y, and Z coordinates with setPos X/Y/Z. You can also use setAngle X/Y/Z to change the angle of the item you're placing. Combine those with a setScale function and wrap 'em all in a doOnce condition for the item's script and ba-da-boom, you've got what you need.

Your a genius, wouldn't have tought of that.
User avatar
Neko Jenny
 
Posts: 3409
Joined: Thu Jun 22, 2006 4:29 am

Post » Sat May 28, 2011 12:13 pm

Be sure, however, to place the setPos, setAngle, and setScale on a script that is attached to the item you're moving. The reason for doing so is that those functions all have a "fix", meaning that you have to specify a target to perform the action on (fix = the part before -> in a function). If you leave the fix off, the functions will perform the action on whatever the script they are in is attached to.

But the problem with having to specify the target in a global script, is that when you type My_Object->setPos X 1329, it doesn't know which copy you are talking about. The game defaults to trying to perform the action on the first reference of that item in the game. So considering this is a repeatable thing that you're scripting, the item that you placeAtPC is a new reference every time.. and the game can't perform functions on just some random reference. The way around that is either to a) only ever have one reference of the item in the game, and just enable/disable it when needed or B) attach a script to each reference so that you can have multiple references and still have it work.
User avatar
flora
 
Posts: 3479
Joined: Fri Jun 23, 2006 1:48 am

Post » Sat May 28, 2011 3:32 pm

I tried it, but I get the error msg: "Couldnt find object in game". The book is disabled at first, so that must be the problem.
I tried to put the script on other items, in global etc. the same error msg. pops up.

Any ideas for a workaround?

I tought of placing another copy of the book into the cell, but that one would be disabled also... :facepalm:
User avatar
Baby K(:
 
Posts: 3395
Joined: Thu Nov 09, 2006 9:07 pm

Post » Sat May 28, 2011 8:32 pm

Make sure you check the "references persist" box. That way the game can reference the object from any where.
User avatar
Conor Byrne
 
Posts: 3411
Joined: Wed Jul 11, 2007 3:37 pm

Post » Sat May 28, 2011 10:51 am

Well, that did the trick, but I still haven't figured it out. :facepalm:

I get a CTD when I take the book, and as you said, it wont work if I put the script on another object.

I have another object in the room which takes away the book from the player, I gues does two scripts bug each other, or something.
If ( player->GetItemCount, "MH_bk_antecedantsdwemerlaw" >= 1 )
player->removeitem "MH_bk_antecedantsdwemerlaw" 1
endif

The NPC has:
set MH_var_bk_antecedantsdwemerlaw to 4
player->removeitem "bk_AntecedantsDwemerLaw" 1

and here is the main script:
begin MH_bk_antecedantsdwemerlaw_sshort OnPCAddshort MH_var_bk_antecedantsdwemerlawshort doonceif ("MH_Mantriel".MH_var_bk_antecedantsdwemerlaw != 4)	Disableendifif ("MH_Mantriel".MH_var_bk_antecedantsdwemerlaw == 4)	Enable	set doonce to 0endifif ("MH_Mantriel".MH_var_bk_antecedantsdwemerlaw == 4)	if ( OnPCAdd == 1 )		player->additem "bk_antecedantsdwemerlaw" 1		set "MH_Mantriel".MH_var_bk_antecedantsdwemerlaw to 3	endifendifif ("MH_Mantriel".MH_var_bk_antecedantsdwemerlaw == 3)	if (doonce ==0)		placeatpc "MH_bk_AntecedantsDwemerLaw" 1 1 1		MH_bk_antecedantsdwemerlaw->setpos X, 67		MH_bk_antecedantsdwemerlaw->setpos Y, -129		MH_bk_antecedantsdwemerlaw->setpos Z, 114		MH_bk_antecedantsdwemerlaw->setangle, X, 90		MH_bk_antecedantsdwemerlaw->setangle, Y, 90		MH_bk_antecedantsdwemerlaw->setscale 0.82		Set doonce to 1	endifendifend MH_bk_antecedantsdwemerlaw_s

User avatar
Sunny Under
 
Posts: 3368
Joined: Wed Apr 11, 2007 5:31 pm

Post » Sat May 28, 2011 11:09 pm

Declare the MH_var_bk_antecedantsdwemerlaw variable as a global instead of two locals since both the book and the NPC have to interact with it. I *think* what's happening is that because you're declaring it in two places, the engine is getting confused as to which version to use. Making it a global should fix that.
User avatar
Robert
 
Posts: 3394
Joined: Sun Sep 02, 2007 5:58 am

Post » Sat May 28, 2011 9:04 pm

Declare the MH_var_bk_antecedantsdwemerlaw variable as a global instead of two locals since both the book and the NPC have to interact with it. I *think* what's happening is that because you're declaring it in two places, the engine is getting confused as to which version to use. Making it a global should fix that.

I tried it, but didn't work. :-/

Edit:
I tinkerd with it, but I couldn't figure it out. I created a little .esp, nothing else is in it, just the questgiver, a book (you have to hand in) and the book with which I try to create the infinite loop.
here is the link:
http://www.streamupload.com/download/38C90319-3087-486C-ADAE-0B88604D9671/MH.esp.aspx
cell name is: Mantriel's Home
it requires mw, tr, bm and I accidently clicked on tr_data too (fom tamriel rebuilt).... sorry
User avatar
saharen beauty
 
Posts: 3456
Joined: Wed Nov 22, 2006 12:54 am

Post » Sat May 28, 2011 7:24 pm

Tell us what exactly you are doing right now.. don't get specific with names or scripts or anything. Just tell us the general idea of what you're doing (find a book, bring it to NPC...). Then I can give you an overview of how to do it.
User avatar
Melis Hristina
 
Posts: 3509
Joined: Sat Jun 17, 2006 10:36 pm

Post » Sat May 28, 2011 10:32 pm

Tell us what exactly you are doing right now.. don't get specific with names or scripts or anything. Just tell us the general idea of what you're doing (find a book, bring it to NPC...). Then I can give you an overview of how to do it.

Step 1: Player brings a book to an npc, ->removeitem, enable "dummy" book on shelf
step 2: Player takes the dummy book from the shelf, a script takes the "dummy" book from him, gives him the real book
step 3: a script creates a new disabled "dummy" book on the shelf, on the exactly same place, where the original "dummy" book was
step 4: the player can hand in the real book again to the npc, the npc enables the dummy book on the shelf again and the whole process can start again, in an infinite loop.

I have problems with step 3. everything else works like a charm. I can create the book with placeatpc and then it works perfectly.
but when I add the setpos, setangle, setscale scripts the game freezes, or I get an error msg

My plan is to create this script with a LOT of items -> kinda a booksorter script, but includes the quest npc, and the quests/journals. I try to minimize the quantity of local/global scripts that are constantly running.
User avatar
Jay Baby
 
Posts: 3369
Joined: Sat Sep 15, 2007 12:43 pm

Post » Sun May 29, 2011 2:50 am

Place the book in the bookcase in construction set. It begins there and never leaves. The ID of the book in the bookcase must be different than that of official books (you are placing a script on it). Rather than move the book, it is alternately enabled and disabled.

Script on book in bookcase:

Begin BookScriptshort stateif ( menumode == 1 )   returnendifif ( state == 1 ); book disabled   while ( ( "NPC_ID"->GetItemCount "Book_ID" ) >= 0 )	  "NPC_ID"->RemoveItem "Book_ID" 1   endwhile   set state to 2   Enableendifif ( state == 2 ); book enabled   if ( OnActivate == 1 )	  set state to 1	  player->AddItem "Book_ID" 1	  PlaySound "Item Misc Up"	  Disable   endifendifif ( state == 0 )   set state to 1   DisableendifEnd BookScript

This code has not been tested.

This script will not allow the player to read the book while it is on the shelf. That feature can be introduced if desired.
User avatar
Heather beauchamp
 
Posts: 3456
Joined: Mon Aug 13, 2007 6:05 pm

Post » Sat May 28, 2011 6:28 pm

Hi Cyran0!

I studied your http://home.earthlink.net/~cyran0/MWPage.htm extensively. I love the "read only-nopickup" code that you and manauser created.
I'm trying to create something very-similar, only difference is the a questgiver and this infinite loop thing. :)
I'll go and give it a try.
User avatar
Silvia Gil
 
Posts: 3433
Joined: Mon Nov 20, 2006 9:31 pm

Post » Sat May 28, 2011 10:49 pm

I checked it, I'm trying to create a "library" where the player can read the books, I can't figure out a way to bypass/workaround the if ( OnActivate == 1 ), if I use your code it should work, but the player wouldn't be able to read the books, Thats why I tried Trunksbomb's idea with the placeatpc-setpos-setangle etc.

This script will not allow the player to read the book while it is on the shelf. That feature can be introduced if desired.

I would like to.
User avatar
dean Cutler
 
Posts: 3411
Joined: Wed Jul 18, 2007 7:29 am

Post » Sat May 28, 2011 7:52 pm

I was thinking, why would anyone want to read the book "on the shelf", if there is a feature, that a "librarian" places it back anyway, its not a big-deal to take off the book, "equip" it in your inventory and read it that way. When done give it to the NPC, and its back on the shelf. :)

I really appreciate your help, if you know a way to code "reading on the shelf" & "placing it back", I would love to use it, but for now I can start to script my books this way.
User avatar
kat no x
 
Posts: 3247
Joined: Mon Apr 16, 2007 5:39 pm

Post » Sat May 28, 2011 3:30 pm

I apologize for the delay in responding. I posted before I left for work this morning and I usually do not return until at least ten hours later (like today).

There are a few things I would change about the script that I did not think out in my haste this morning. I made an error in the state == 1 block: it will enable the book regardless of the librarian having a copy in inventory.

As it is, it will not store multiple volumes of the same book. That means that the player will lose any copies of the book beyond the first given to the librarian. A variable can keep track of the number of copies of the book and only disable the book when the last copy has been removed by the player. Is this feature important?

I think a message box asking if the player wants to remove the volume when it is activated would be better than automatically removing it. This can be coupled with the option of reading the book without removing it from the shelf.

A script with all these features might look like this:

Begin BookScriptshort stateshort numberCopiesshort messageOnshort buttonif ( menumode == 1 )   returnendifif ( state == 1 ); book disabled   while ( ( "NPC_ID"->GetItemCount "Book_ID" ) >= 0 )	  "NPC_ID"->RemoveItem "Book_ID" 1	  set numberCopies to ( numberCopies + 1 ); keeps track of copies   endwhile   if ( numberCopies >= 1 )	  set state to 2	  Enable   endifendifif ( OnActivate == 1 ); state must be 2 for this to be possible   set messageOn to 1   Messagebox "What do you wish to do? "Read book" "Take book" "Nevermind"endifif ( messageOn == 1 )   set button to GetButtonPressed   if ( button == -1 ); no button pressed	  return   elseif ( button == 0 ); read book	  Activate   elseif ( button == 1 ); take book	  player->AddItem "Book_ID" 1	  set numberCopies to ( numberCopies - 1 )	  PlaySound "Item Misc Up"	  if ( numberCopies <= 0 ); last copy removed by player		 set numberCopies to 0; just in case		 set state to 1		 Disable	  endif   else; cancel action   endif   set messageOn to 0; reset for next timeendifif ( state == 0 )   set state to 1   DisableendifEnd BookScript

This code has not been tested.

The player should not be able to activate the book when the menu is open. Perhaps a message informing the player would quiet any alarm he/she may experience. Offering the player a choice of action through the messagebox choice delays activation in a way that could cause a 'hang' - the mouse may freeze until the right button is clicked. I am not certain of that since I have not tested this particular script, but that was the reason for adopting ManaUser's structure in my code.
User avatar
Ben sutton
 
Posts: 3427
Joined: Sun Jun 10, 2007 4:01 am

Post » Sat May 28, 2011 4:22 pm

..."I think a message box asking if the player wants to remove the volume when it is activated would be better than automatically removing it. This can be coupled with the option of reading the book without removing it from the shelf."...

I tested your code (well a slightly modified version), and its brilliant, its classy, its stylish, its player friendly (I never tought of playing sounds, or giving options for the player).
The only issue that came up is that while reading the book, the "take" option is still available (like when you activate the book under usual circumstances). If I use this method I would like to be sure the player can't ever take the "dummy" book from the shelf, and the "take" option just ruins this.

The concept is that the npc places the book back when you hand it to him, the player takes it down again, hands it in again, npc puts it back again... in an infinte loop.

edit: Well the player can take down the dummy book, but then we get back to my original problem, and I would have to create a "copy" of the dummy book on his original location, which is a problem I'm baffled with.
User avatar
Jose ordaz
 
Posts: 3552
Joined: Mon Aug 27, 2007 10:14 pm

Post » Sat May 28, 2011 2:36 pm

Yep, that 'take' feature of books can be a real problem sometimes. I seem to remember while adjusting my book script I had the happy accident stumbling upon code that would not respond to the player's choice of 'take' while reading a book on the stacks. I don't think I could have planned it - I am not certain I understand why it works the way it does.

I decided that I had to test the script myself if I was going to find a workaround. I have confirmed your results (while discovering two typos in my code that you must have fixed already). I have tried a couple alternatives. I did not have much hope of their working and they did not. I may play around with this a little more tomorrow, but I am not optimistic. Making it work will likely result in the loss of other functionality.

There is a workaround that I used in Purchasable Alchemy Laboratory. It involves replacing the book with an activator or miscellaneous item. When the player chooses to read it, instead of opening like a standard book it places a copy of the book in question (Alchemists Formulary in my case) and equips it to open the text. The beauty of this approach is that since it is already in the player's inventory 'take' is not offered as an option. After the player finishes reading, the script on the fake book removes it from the player's inventory. The player has no knowledge of the trick.

The down side is how cumbersome it is for more than a few books. Every book will require the activator/miscellaneous item (that is no hardship since you require a unique 'book' for each official title). The code runs in several stages. You could examine the script cyr_al_AlchemistFormularyScript from that mod, but is has multiple functions and may be difficult to isolate the pertinent code. Here is the part that manages the reading of the book:

short readBookshort frameCountif ( readBook == 1 )   set readBook to 2   player->AddItem "bk_AlchemistsFormulary" 1   returnelseif ( readBook == 2 )   set readBook to 3   player->Equip "bk_AlchemistsFormulary"   returnelseif ( readBook == 3 )   set frameCount to ( frameCount + 1 )   if ( frameCount < 5 ); wait	  return   endif   set frameCount to 0; reset for next time   set readBook to 4   returnelseif ( readBook == 4 )   if ( menumode == 1 )	  return   endif   set readBook to 0   player->RemoveItem "bk_AlchemistsFormulary" 1endif

The short variable readBook is set to 1 by the messagebox choice of reading the book.


By the way, here are the two errors in the code in my previous post:

while ( ( "NPC_ID"->GetItemCount "Book_ID" ) >= 0 )

should be...

while ( ( "NPC_ID"->GetItemCount "Book_ID" ) >= 1 )

and

Messagebox "What do you wish to do? "Read book" "Take book" "Nevermind"

should be...

Messagebox "What do you wish to do?" "Read book" "Take book" "Nevermind"
(missing quotes after the question mark)
User avatar
Je suis
 
Posts: 3350
Joined: Sat Mar 17, 2007 7:44 pm

Post » Sat May 28, 2011 1:46 pm

I noticed the missing " i tought I deleted it by accident (I changed the text slightly), and I used my own variable instead of getitemcount on the NPC... so I never noticed there were any errors :P

This framecount thing is new to me, dont frames works differently on slower and on faster PCs?

Well anyway this looks to be a whole new approach to me. I was experimenting with 2 dummy books, one adding the other one (making it a three-way cycle), but the "placeatpc+setpos+setangle+setscale" does not want to work for me. :-/ I'm still just a beginner with scripts, I haven't read the whole MSfD and didnt read the original scripts yet.

Here is my version of your code I tried:
begin MH_bk_antecedantsdwemerlaw_sshort buttonshort messageOnif (MH_var_bk_antecedantsdwemerlaw != 4)	Disableendifif ( menumode == 1 )   returnendifif (MH_var_bk_antecedantsdwemerlaw == 4)	Enableendifif ( OnActivate == 1 )	set messageOn to 1	Messagebox "Would you like to...?" "Read the book?" "Take the book?" "Leave it"endifif ( messageOn == 1 )	set button to GetButtonPressed	if ( button == -1 ); no button pressed		return		elseif ( button == 0 ); read book			Activate		elseif ( button == 1 ); take book			player->AddItem "bk_antecedantsdwemerlaw" 1			set MH_var_bk_antecedantsdwemerlaw to 3			PlaySound "Item Misc Up"		endif	else; cancel action	endif	set messageOn to 0; reset for next timeendifend MH_bk_antecedantsdwemerlaw_s


I tried changing the menumode part, trying to implement manauser's code, but no luck with that either.
User avatar
Joanne Crump
 
Posts: 3457
Joined: Sat Jul 22, 2006 9:44 am

Post » Sat May 28, 2011 6:51 pm

I haven't checked your code with TESCS yet, but I think thats the one. :)
If I create a msg question for: 1. taking the book, 2. reading it, 3 leaving it, and then adding this code it should work seamlessly.
I must admit, I haven't figured it out yet why the frame check is added (to avoid menumode?), but when I'm a little more awake, I'll give it a go.

I hope the misc items won't be a major issue, I was planning to use the book rotate books for the "open" books anyway (otherwise you can't put the "open" books on shelves very efficiently).
I'm happy now that I did not start yet, to place the "dummy" books one-by-one on the shelf. :woot:

Thank you. :)
User avatar
Lance Vannortwick
 
Posts: 3479
Joined: Thu Sep 27, 2007 5:30 pm

Post » Sat May 28, 2011 9:31 pm

You are correct: a frame count will have a different duration on different system (it will depend on framerate). Where a specific delay is wanted, using a timer is much more precise. However, in this case, I only need a short delay of a few script cycles to assure that the engine detects that the book (menu) is open. Otherwise there is a danger that readBook == 4 ) will remove the book before it can be read.

I gather that MH_var_bk_antecedantsdwemerlaw is a global variable. I prefer to use local variables wherever possible, but without seeing the full scope of your project I have to assume it is necessary to use a global. Perhaps this is your workaround for not having to use GetItemCount. An alternative to using that function is welcome since it has a tendency to slow down processing.

If you pre-place the 'books' in the construction set and enable/disable them as appropriate those objects will not require the Book Rotate script (but it should work with any object you create that wears the book mesh).

If you decide to go with my 'dummy book' workaround, that block of code needs to be placed near the topic of the script above an if ( menumode == 1 ) check.

And yes, you are wise to test your scripts with a couple objects before duplicating them for a couple hundred books.
User avatar
Dean
 
Posts: 3438
Joined: Fri Jul 27, 2007 4:58 pm

Post » Sat May 28, 2011 8:17 pm

I gather that MH_var_bk_antecedantsdwemerlaw is a global variable. I prefer to use local variables wherever possible, but without seeing the full scope of your project I have to assume it is necessary to use a global. Perhaps this is your workaround for not having to use GetItemCount. An alternative to using that function is welcome since it has a tendency to slow down processing.

I'm not sure. I added the short MH_var_bk_antecedantsdwemerlaw to the quest npc, and I tought this makes it local. If it doesn't I need to study this, because I really don't want to create a couple hundred globals to slow down the game.
If you pre-place the 'books' in the construction set and enable/disable them as appropriate those objects will not require the Book Rotate script (but it should work with any object you create that wears the book mesh).

I don't intend to use the book rotate script at all (that would be heavy stealing), I just want to use the .nifs for the closed books. I believe (I haven't checked it yet), that book rotate gave every "open" book a new mesh, which is a closed version.

Edit: I'm an idiot: I mean book jackets, not book rotate. :facepalm:
User avatar
Taylor Tifany
 
Posts: 3555
Joined: Sun Jun 25, 2006 7:22 am

Post » Sat May 28, 2011 11:32 pm

Cyran0:

I tried it, but it seems I messed it up somewhere. I downloaded your alchemy mod to take a look at the working code and its beautiful, thats exactly what I'm aiming for.

I created a new testing cell (new dialogue, journal etc), because one of my scripts just did not want to be deleted with tesame. Everything works fine except the "Read the book option".

here is the script on the activator
begin MH_bk_antecedantsdwemerlaw_sshort buttonshort messageOnshort readBookshort frameCountif ( "MH_Mantriel".MH_var_bk_antecedantsdwemerlaw != 4 )disableendifif ( "MH_Mantriel".MH_var_bk_antecedantsdwemerlaw == 4 )enableendifif ( OnActivate == 1 )	set messageOn to 1	Messagebox "Would you like to...?" "Read the book?" "Take the book?" "Leave it"endifif ( messageOn == 1 )	set button to GetButtonPressed	if ( button == -1 ); no button pressed		return	elseif ( button == 0 ); read book		if ( readBook == 1 )			set readBook to 2			player->AddItem "bk_antecedantsdwemerlaw" 1			return		elseif ( readBook == 2 )			set readBook to 3			player->Equip "bk_antecedantsdwemerlaw"			return		elseif ( readBook == 3 )			set frameCount to ( frameCount + 1 )			if ( frameCount < 5 ); wait				return			endif				set frameCount to 0; reset for next time				set readBook to 4				return		elseif ( readBook == 4 )			set readBook to 0			player->RemoveItem "bk_antecedantsdwemerlaw" 1	endif	elseif ( button == 1 ); take book		player->AddItem "bk_antecedantsdwemerlaw" 1		set "MH_Mantriel".MH_var_bk_antecedantsdwemerlaw to 3		PlaySound "Item Misc Up"	endif	else; cancel action	endif	set messageOn to 0; reset for next timeendifend MH_bk_antecedantsdwemerlaw_s


here is the http://www.streamupload.com/?id=a447ca58-affc-4ca3-af20-f5679d778bda

I tried to figure out, how my "local"-"global" scripts were able to work with my previous tries, and I have no clue, the .esp I posted a few days earlier has these mysterious local scripts that behave like globals.
User avatar
Luna Lovegood
 
Posts: 3325
Joined: Thu Sep 14, 2006 6:45 pm

Post » Sun May 29, 2011 12:55 am

This may be my last time to post before I leave town on holiday so I hope my answers to your questions make sense.

The code I posted for the read book option is apart from the process when the player makes the choice. It has to be so since button == 0 will only be true for the one frame that the player clicks on that choice. readBook is set to 1 by that choice, but the code triggered by that value runs outside of the messageOn block. It might look like this:

Note that I make your Enable and Disable doOnce, constantly enabling or disabling will interfere with some script functions so it is better to not take chances with it.

Begin MH_bk_antecedantsdwemerlaw_sshort buttonshort messageOnshort readBookshort frameCountif ( GetDisabled == 0 ); make this doOnce   if ( "MH_Mantriel".MH_var_bk_antecedantsdwemerlaw != 4 )	  Disable   endifelse; currently disabled    if ( "MH_Mantriel".MH_var_bk_antecedantsdwemerlaw == 4 )	  Enable   endif   return; for efficiency - no need to process further if disabledendifif ( readBook == 1 )   set readBook to 2   player->AddItem "bk_antecedantsdwemerlaw" 1   returnelseif ( readBook == 2 )   set readBook to 3   player->Equip "bk_antecedantsdwemerlaw"   returnelseif ( readBook == 3 )   set frameCount to ( frameCount + 1 )   if ( frameCount < 5 ); wait	  return   endif   set frameCount to 0; reset for next time   set readBook to 4   returnelseif ( readBook == 4 )   set readBook to 0   player->RemoveItem "bk_antecedantsdwemerlaw" 1endifif ( OnActivate == 1 )   set messageOn to 1   Messagebox "Would you like to...?" "Read the book?" "Take the book?" "Leave it"endifif ( messageOn == 1 )   set button to GetButtonPressed   if ( button == -1 ); no button pressed	  return   elseif ( button == 0 ); read book	  set readBook to 1   elseif ( button == 1 ); take book	  player->AddItem "bk_antecedantsdwemerlaw" 1	  set "MH_Mantriel".MH_var_bk_antecedantsdwemerlaw to 3	  PlaySound "Item Misc Up"   else; cancel action   endif   set messageOn to 0; reset for next timeendifEnd MH_bk_antecedantsdwemerlaw_s

I neglected to mention before, but the workaround with the fake book adding and equipping a book for the player to read causes a 'menu hang' ( no mouse movement) after the book is closed. A right mouse click will resolve the matter. You will want to warn users of your mod about this known issue.

As for your previous post to this, I see now that MH_var_bk_antecedantsdwemerlaw is a local variable. You had not specified the object yesterday so it was unclear to me how it is set. You present syntax is correct. Since the NPC and the books are in the same cell, there should be no difficulty reading and writing to that local variable in the script attached to MB_Mantriel (so now you are a reference librarian? ;) ). However, you need to appreciate there are some limitations. For instance I do not believe you can set the value of the local to a variable remotely.

It has been demonstrated that a few hundred globals (or even tens of thousands) will not slow the game, but it does glut the saved game file with additional information. Back in the early days of Morrowind modding we were reluctant to introduce new globals in a way that no longer seems necessary, but I like to err on the conservative side. In Purchasable Alchemy Lab I use seven globals to place and control the interaction of over one hundred objects and their scripts without requiring persistent references. It seemed an economical solution to the problem.

If you require closed book meshes for some of the volumes, you can create the new object using a closed book nif provided by Bethesda.

I understand how easy it would be to have a momentary confusion between Book Rotate and Book Jackets. For the record, if you needed the book rotate code you would be able to use it since the creators of that mod offer permission to modders of new books to make their books 'rotatable'. The credits are actually included in the script's code. As for Book Jackets, I am confident that you can get permission from the author to use his/her textures with your project, but you do need to seek and obtain that permission before you release your project publicly.
User avatar
Alexander Lee
 
Posts: 3481
Joined: Sun Nov 04, 2007 9:30 pm

Post » Sat May 28, 2011 3:42 pm

Thank you. It works perfectly.

Happy Thankgsgiving to everyone.
User avatar
Mark Hepworth
 
Posts: 3490
Joined: Wed Jul 11, 2007 1:51 pm

Next

Return to III - Morrowind