Scripting question about books

Post » Sat Oct 13, 2012 12:34 pm

I'm trying my hand at modding a book (alchemy cheat sheet) for myself that will only open once player has an alchemy skill level of 60 or higher (can look at all four ingredient effects).

I'm using the GBG Morrowind Scripting for Dummies as well as looking at scripts in the CS. My original idea was

Spoiler
Begin AllowReading ;script starts

short JLH_Alch ;declared a variable

if ( JLH_Alch < 0) ;has this script processed before?
if ( player->GetAlchemy > 59 ) ;is the PC's alchemy skill 60 or greater?
Activate book ;if yes, open book for reading
endif
endif

set JLH_Alch to 1 ;change JLH_Alch to 1

End ;script ends here

but then I saw the script for Pilgrims Path and thought I could use it for what I wanted and it looked rather elegant and to the point (my adaptation below)
Spoiler
Begin _JH_bookAlchCheatSheet

if (OnActivate == 1)
if ( player->GetAlchemy > 59 ) ;is the PC's alchemy skill 60 or greater?
Activate
endif
endif

End

That didn't work out too well :(

Then I went back over the MSfD, and it noted that detecting the use of a book is complicated (in spite of how simple the Pilgrims Path script looks). The way Pilrgrims Path works in MW seemed pretty comparable to what I wanted to accomplish - a book that checks the player's alchemy skill level. If it's over 59, then player can read the contents of the book. I expect to use my book in all the ways books usually are - put on the ground or shelf, pick back up, read, carry in my inventory or store in a container.

Did I take a wrong turn thinking that I could adapt the code in the Pilgrims Path book script to my purpose?

I'm jumping the gun here, but later on I'd like to make it so that it can be placed like the way Rotate Books does for books. Would that require additional code on my part or will that mod enable my book to be placed upright, etc. with no further coding on my part? It's one of the mods I always include in my games.

One last question for now - what does "return" do in a script? Some of the example scripts use it; others don't. I didn't find an explanation in MSfD, or not one that stood out for me anyway. Given that it's not used in all scripts, it would therefore be optional but under what circumstances does one use it in a script?

TIA for your help.
User avatar
Jade Payton
 
Posts: 3417
Joined: Mon Sep 11, 2006 1:01 pm

Return to III - Morrowind

cron