Page 1 of 1

Can someone tell me why this script doesn't quite work?

PostPosted: Sun Apr 05, 2009 1:15 pm
by valre
I've now rewritten this script 5 or 6 times in various ways and this one that I'm including is the one that almost works, but not quite as intended
Code: Select all
Begin VRH_test_Lect

; A test scrip to check some funtions I'll need to have a complete handle on when I start
; actually constructing the mod in the CS
; 1. PC needs a book to go further (one is next to the lecturn)
;         if PC does not have book PC'll be told one is needed.
;
; 2. If PC has book when activating the lecturn a choice will be given,
;        either put the book on the lecturn, in which case the book that PC has
;         in inventory is removed, and the disabled book on the lecturn is enabled,
;        or PC can decide not to put the book on the lecturn.
;
; 3. In this test the next thing the PC will be able to do is, if activating the lecturn again,
;        to pick up the book, or not. If PC chooses to pick up the book, then the book on the lecturn
;        is disabled again, and a new copy is put into the PCs inventory


short LecturnState
short Button

if ( MenuMode == 1 )
       return
endif

if ( OnActivate == 1 )
       if ( LecturnState == 0 )

               "vrh_test_book1"->Disable        ; Hide the book until it's needed

               if ( player->GetItemCount "vrh_test_book2" == 1 )
                       MessageBox "Do you want to place your book here?", "Yes", "No"
                       set LecturnState to 1
               else
                       MessageBox "You'll need a book for this test."
               endif

       elseif ( LecturnState == 1 )
               set Button to GetButtonPressed
                       if ( Button == -1 )
                               return
                       elseif ( Button == 0 )
                               player->RemoveItem "vrh_test_book2" 1
                               "vrh_test_book1"->Enable
                               set LecturnState to 2
               else
                       MessageBox "Return when you do"
                       set LecturnState to 0
               endif

       elseif ( LecturnState == 2 )
               MessageBox "Do you want to pick up the book and take it with you?", "Yes", "No"
               set LecturnState to 3
       endif

       elseif ( LecturnState == 3 )
               set Button to GetButtonPressed
                       if ( Button == -1 )
                               return
                       elseif ( Button == 0 )
                               player->AddItem "vrh_test_book3" 1
                               "vrh_test_book1"->Disable
                               set LecturnState to 0
                       else
                               MessageBox "You leave it where it is"
                       endif
endif
                      
End


Everything seems to be a step behind where it's supposed to be .. for lack of a better word. Until I figure this out I can't really move forward with the mod I'm working on. I'll keep trying to figure it out for myself, but so far it's taken me some 5 or so hours to get practically no where. *sigh*

Edit to add: CS does not complain or anything ... it's simply just not doing things in quite the right order ...

Re: Can someone tell me why this script doesn't quite work?

PostPosted: Sun Apr 05, 2009 2:02 pm
by peachykeen
Begin VRH_test_Lect

; A test scrip to check some funtions I'll need to have a complete handle on when I start
; actually constructing the mod in the CS
; 1. PC needs a book to go further (one is next to the lecturn)
;    if PC does not have book PC'll be told one is needed.
;
; 2. If PC has book when activating the lecturn a choice will be given,
;   either put the book on the lecturn, in which case the book that PC has
;    in inventory is removed, and the disabled book on the lecturn is enabled,
;   or PC can decide not to put the book on the lecturn.
;
; 3. In this test the next thing the PC will be able to do is, if activating the lecturn again,
;   to pick up the book, or not. If PC chooses to pick up the book, then the book on the lecturn
;   is disabled again, and a new copy is put into the PCs inventory


short LecturnState
short Button

if ( MenuMode == 1 )
  return
endif

if ( OnActivate == 1 )
  if ( LecturnState == 0 )

     "vrh_test_book1"->Disable   ; Hide the book until it's needed

     if ( player->GetItemCount "vrh_test_book2" == 1 )
        MessageBox "Do you want to place your book here?", "Yes", "No"
        set LecturnState to 1
     else
        MessageBox "You'll need a book for this test."
     endif

  elseif ( LecturnState == 1 )

     set Button to GetButtonPressed

     if ( Button == -1 )
        return
     elseif ( Button == 0 )
        player->RemoveItem "vrh_test_book2" 1
        "vrh_test_book1"->Enable
        set LecturnState to 2
     else
        MessageBox "Return when you do"
        set LecturnState to 0
     endif

  elseif ( LecturnState == 2 )

     MessageBox "Do you want to pick up the book and take it with you?", "Yes", "No"
     set LecturnState to 3

  elseif ( LecturnState == 3 )

     set Button to GetButtonPressed

     if ( Button == -1 )
        return
     elseif ( Button == 0 )
        player->AddItem "vrh_test_book3" 1
        "vrh_test_book1"->Disable
        set LecturnState to 0
     else
        MessageBox "You leave it where it is"
     endif
endif
       
End


Took out an extra endif before the state == 3.

Re: Can someone tell me why this script doesn't quite work?

PostPosted: Sun Apr 05, 2009 2:16 pm
by valre
just tried that .... didn't make any change really ... except maybe a little for the worse ... seems Raflod has figured it out though .. he's sending me an .esp now

~~

edit: okay issue solved for now at least .. so thread locked