Adding A Script To A Book

Post » Sun Aug 23, 2009 3:47 pm

Hi. I need a script to run just once, the first time the player reads a book/scroll that is in their inventory by default when the game starts. Iv looked at other scripts, but while there is OnAdd to tell when the item is added to the players inventory, there does not seem to be anything that points to an OnRead type function.

Can this be done, and if so, what is the command/function that I need to use?

Cheers

MVK
User avatar
Pete Schmitzer
 
Posts: 3387
Joined: Fri Sep 14, 2007 8:20 am

Post » Mon Aug 24, 2009 12:36 am

It's either OnEquip or OnActivate that runs.

EDIT: where did the capitalization of OnActivate go...
User avatar
Horse gal smithe
 
Posts: 3302
Joined: Wed Jul 05, 2006 9:23 pm

Post » Sun Aug 23, 2009 6:41 pm

Cheers Qazaaq. Now that you've said it, Id think it to be OnEquip, since OnActivate implies that it may have been disabled at some point, and equip suggests using it with the hands etc.

[EDIT] Eep! You're right, On Activate did get de-capitlaized! How odd!

Thanks, Ill give that a go

MVK
User avatar
koumba
 
Posts: 3394
Joined: Thu Mar 22, 2007 8:39 pm

Post » Sun Aug 23, 2009 8:25 pm

Hi. I need a script to run just once, the first time the player reads a book/scroll that is in their inventory by default when the game starts. Iv looked at other scripts, but while there is OnAdd to tell when the item is added to the players inventory, there does not seem to be anything that points to an OnRead type function.

Can this be done, and if so, what is the command/function that I need to use?

Cheers

MVK

Scriptname MS11JournalScriptbegin OnActivate	if IsActionRef player == 1		activate		setstage MS11 70	endifend


That is straight from the construction set the Book it references is MS11GelebourneJournal. I hope that answers your question. Good luck.
User avatar
Kaley X
 
Posts: 3372
Joined: Wed Jul 05, 2006 5:46 pm

Post » Sun Aug 23, 2009 10:32 am

Scriptname MS11JournalScriptbegin OnActivate	if IsActionRef player == 1		activate		setstage MS11 70	endifend


That is straight from the construction set the Book it references is MS11GelebourneJournal. I hope that answers your question. Good luck.

Thanks Zornac, I hadn't even tried it yet! One thing though, how do I make this script run the first time the book/scroll is read, and ONLY the first time?

Cheers

MVK
User avatar
CYCO JO-NATE
 
Posts: 3431
Joined: Fri Sep 21, 2007 12:41 pm

Post » Sun Aug 23, 2009 11:24 am

Thanks Zornac, I hadn't even tried it yet! One thing though, how do I make this script run the first time the book/scroll is read, and ONLY the first time?

Cheers

MVK


You'll need a so-called "do-once" variable. You can compare it to a switch. It works like this:
Scriptname MS11JournalScriptshort dooncebegin onactivate    if doonce == 0    ;; make sure the switch isnt flipped yet        if IsActionRef player == 1            activate            set doonce to 1  ;; flip the switch            ;; do something special        endif     endifend

User avatar
Sammie LM
 
Posts: 3424
Joined: Thu Nov 30, 2006 1:59 pm

Post » Sun Aug 23, 2009 8:27 pm

Thats excelelnt Qazaaq, thanks. I'm off to give things a go!

Cheers

MVK
User avatar
Nicholas C
 
Posts: 3489
Joined: Tue Aug 07, 2007 8:20 am

Post » Sun Aug 23, 2009 10:04 am

Upon testing it appears that it is OnEquip that is needed. On_Activate does not seem to do anything, because I imagine, the book itself started as active and has not been deactivated.

In fact the script was a lot simpler than I imagined in the end:
ScriptName MVKQ01Marker01         short doonce           Begin OnEquip    if doonce == 0        set doonce to 1         setstage MVKPointerQ01 10    endif                  End


What I ended up doing is making a quest that would display the usual pointer on the map, directing you to the right place. That quest is then stopped as soon as you talk to the correct person in the building.

The aim had been to get the NPC's around town to give directions to the next person required. However, it seems that its a lot easier (not to mention less dialog intensive) to create small quests that are activated at the correct time, and thus give pointers on the map between quests, something that is not exactly required, but nice anyway, since the player character is the Magistrate of the city, and should know where everyone lives.

Anyway, things are working, so thanks for your input :)

MVK
User avatar
James Baldwin
 
Posts: 3366
Joined: Tue Jun 05, 2007 11:11 am

Post » Sun Aug 23, 2009 10:58 am

Upon testing it appears that it is OnEquip that is needed. On_Activate does not seem to do anything, because I imagine, the book itself started as active and has not been deactivated.


Actually, On_Activate (I wonder why that won't stay capitalized) will work for books, but only if they are not in your inventory. The have to be on a shelf, table or other surface when you interact with them. So yes, OnEquip is what you want if it's to be used from your inventory.?
User avatar
Stay-C
 
Posts: 3514
Joined: Sun Jul 16, 2006 2:04 am


Return to IV - Oblivion