BlueSteelRanger Posted April 22, 2023 Author Share Posted April 22, 2023 @RomanR: I will definitely take a listen to that. Would you mind if I tried it/tweaked it for my Player Home/Worldspace mod? (Which is ultimately, what I'm creating). You shall of course, get proper credit. All of you all here on the Forums will. @OblivionAddicted: So if it's a book on a shelf or table --> "OnAdd", as in "Pick it up and get it into player inventory"? Thank you all again. You guys are an absolute godsend. NEXUS RULES AGAIN! I will update this Sunday when I continue working on it. Link to comment Share on other sites More sharing options...
Oblivionaddicted Posted April 22, 2023 Share Posted April 22, 2023 OnAdd works when an objects is added in your inventory. Link to comment Share on other sites More sharing options...
qwertyasdfgh Posted April 22, 2023 Share Posted April 22, 2023 OnEquip works perfectly fine with books. Link to comment Share on other sites More sharing options...
RomanR Posted April 22, 2023 Share Posted April 22, 2023 (edited) @qwertyasdfgh: Yes, you're right, it didn't work because I tried to use GetActionRef command in this event too and got non-working results. At least I can present improved version, the message box will show after reading a book now, as I find it incovenient to choices pop-up when you even didn't read it. To save some space I used filters, so I hope it will be alright.Now the script: scn RomRBookTeachsSpell2 ;Any book with this script attached will teach you spell after read short choice short wantteach short showbox short readed short taken begin OnAdd player ;to show alternative message box set taken to 1 end begin OnActivate if GetActionRef == player ;print "Activated by player." if player.HasSpell RomRPushSpell == 0 set wantteach to 1 set showbox to 1 set readed to 0 set choice to -1 endif Activate else Activate endif end begin OnEquip player if player.HasSpell RomRPushSpell == 0 set wantteach to 1 set showbox to 1 set readed to 0 set choice to -1 ;print "Player opened this book." endif end begin MenuMode if MenuMode 1026 ;book was opened for reading set readed to 1 set taken to 0 elseif MenuMode 1002 if wantteach != 0 && readed != 0 ;player closed a book if showbox != 0 MessageBox "As you closed this book, you feel as it wants to give you something. Will you accept?","Yes","No" set showbox to 0 endif set choice to GetButtonPressed if choice == 0 ;yes player.AddSpell RomRPushSpell endif if choice != -1 set wantteach to 0 set readed to 0 endif endif endif end begin GameMode if wantteach != 0 && readed != 0 ;player closed a book if showbox != 0 if taken != 0 MessageBox "As you closed this book to take it, you feel as it wants to give you something. Will you accept?","Yes","No" else MessageBox "As you closed this book, you feel as it wants to give you something. Will you accept?","Yes","No" endif set showbox to 0 endif set choice to GetButtonPressed if choice == 0 ;yes player.AddSpell RomRPushSpell endif if choice != -1 set wantteach to 0 set readed to 0 endif endif end @BlueSteelRanger: Yes, of course you can alter my scripts as you like. Edited April 22, 2023 by RomanR Link to comment Share on other sites More sharing options...
BlueSteelRanger Posted April 22, 2023 Author Share Posted April 22, 2023 @RomanR: Thanks so much. All of you are seriously teaching me a lot here, and progress is going even better in my mod sessions. Like I said, I'll update on Sunday when I get working on it again. (Mobility days, uggggggghhhhh). Link to comment Share on other sites More sharing options...
Oblivionaddicted Posted April 22, 2023 Share Posted April 22, 2023 OnEquip works perfectly fine with books.I confirm. Link to comment Share on other sites More sharing options...
BlueSteelRanger Posted April 24, 2023 Author Share Posted April 24, 2023 Hey, y'all! I'm giving that script of yours a try, @RomanR, and I'm getting an odd error with it. "unknown variable or function, 'HasSpell'", Line 16. I'm assuming this is a new function? I am trying your shorter script. I have tweaked the Spell ID name a bit and matched it to the corresponding script. No errors with this one. Let's see how this goes. Link to comment Share on other sites More sharing options...
RomanR Posted April 24, 2023 Share Posted April 24, 2023 (edited) I'm sorry but I completely forgot that HasSpell is an OBSE function too. But as it's present even in my ancient version 21.4, this shouldn't pose much problem. You can substitute it for some sort of doOnce flag, so the book will not offer to teach spell over and over again. Still, using HasSpell function is more convenient, because in case you somewhat lost this spell, the book will not give you this spell again until this substitute flag is reseted. To reset in easier way I would recommend to make this flag as quest or global variable, if this spell is important. Script itself could look like this: scn RomRBookTeachsSpell2 ;Any book with this script attached will teach you spell after read short choice short wantteach short showbox short readed short taken begin OnAdd player ;to show alternative message box set taken to 1 end begin OnActivate if GetActionRef == player ;print "Activated by player." if spellgiven == 0 ;or {your_quest}.spellgiven - so global or quest variable set wantteach to 1 set showbox to 1 set readed to 0 set choice to -1 endif Activate else Activate endif end begin OnEquip player if spellgiven == 0 set wantteach to 1 set showbox to 1 set readed to 0 set choice to -1 ;print "Player opened this book." endif end begin MenuMode if MenuMode 1026 ;book was opened for reading set readed to 1 set taken to 0 elseif MenuMode 1002 if wantteach != 0 && readed != 0 ;player closed a book if showbox != 0 MessageBox "As you closed this book, you feel as it wants to give you something. Will you accept?","Yes","No" set showbox to 0 endif set choice to GetButtonPressed if choice == 0 ;yes player.AddSpell RomRPushSpell set spellgiven to 1 ;or set {your_quest}.spellgiven endif if choice != -1 set wantteach to 0 set readed to 0 endif endif endif end begin GameMode if wantteach != 0 && readed != 0 ;player closed a book if showbox != 0 if taken != 0 MessageBox "As you closed this book to take it, you feel as it wants to give you something. Will you accept?","Yes","No" else MessageBox "As you closed this book, you feel as it wants to give you something. Will you accept?","Yes","No" endif set showbox to 0 endif set choice to GetButtonPressed if choice == 0 ;yes player.AddSpell RomRPushSpell set spellgiven to 1 endif if choice != -1 set wantteach to 0 set readed to 0 endif endif end Edited April 24, 2023 by RomanR Link to comment Share on other sites More sharing options...
BlueSteelRanger Posted April 24, 2023 Author Share Posted April 24, 2023 No worries. :) You all are a whole helluva lot more experienced than I am on this, and I wouldn't doubt at all that the book not firing is from some tiny-azz little thing my newbie self missed somewhere. Okay. Going to give this a try in the morn. ::cracks knuckles and downs the coffee:: Link to comment Share on other sites More sharing options...
BlueSteelRanger Posted April 25, 2023 Author Share Posted April 25, 2023 Update: Trying this one out. "Syntax error: Unknown command 'spellgiven', Line 16". I'm going to do some reading on console stuff re: spells and the like. I think that line may need "addspell" or something like it? Link to comment Share on other sites More sharing options...
Recommended Posts