Making a Script Portion Run Once (or twice)

Post » Fri Oct 18, 2013 10:04 am

I have a script in several parts, attached to a book, but I want the first part to run only once, unless the player does not pick it up the first time and puts it back.

Then, once he has picked it up and it is in inventory, if he reads it or if he drops it and picks it up again, the first part of the script will not run, just the OnRead part.

Any way to do this?

Cheers!

~.~

User avatar
Christina Trayler
 
Posts: 3434
Joined: Tue Nov 07, 2006 3:27 am

Post » Fri Oct 18, 2013 12:35 pm

you can set a bool to true in the OnContainerChanged block,

and make the OnRead run only when that's true.

for any setups like this, you'll have to consider that, if a book is picked up from the world, it will open, so it's OnRead will fire first.

if it's picked up from a container though, it will NOT open, so it's the OnContainerChanged that will run first in this case.

User avatar
Project
 
Posts: 3490
Joined: Fri May 04, 2007 7:58 am

Post » Fri Oct 18, 2013 6:36 am

I was wondering about that as I don't have an OnContainerChanged event in this. But even taking it from the world is a Container Change, yes?

When you click on the book, I have a dialogue box that says that's not yours, so you have to put it back or steal it, click OK and then you can return it with ESC or Steal it with E.

The OnRead does not fire if you put it back, but it does if you steal it. even though you have not actually read it yet (it teaches Alchemy recipes)

But when I drop it on the floor, I get the first dialogue box and I cannot pick it up again, so I want to disable that firing again once it has been in inventory (but not if it is put back and then picked up again without ever being stolen).

I was trying to adapt scripts from another mod as when you steal books without opening them with that mod, it is not flagged as stolen anymore.

I wanted it to be flagged as stolen if it IS stolen, but I want the player to be able to put it in a chest or on their book case and be able to pick it up again. At the moment, I can't pick it up if I drop it, the dialogue box just closes when I click OK.

Preferably, I don't want the OnRead to fire at all until after it has been in inventory and read properly. You cannot study a complex book of Alchemy while in the bedroom of the person you are stealing it from just by opening the first page! :)

~.~

User avatar
Sweet Blighty
 
Posts: 3423
Joined: Wed Jun 21, 2006 6:39 am


Return to V - Skyrim