A beginner's question on scripting

Post » Mon Nov 23, 2009 11:22 pm

Greetings to all !
I have been working on a mod for some time, and now came to the phase, after loads of interior and some exterior cell editing, npc and faction creation, etc, where I need to get knowledgeable on the scripting topic, to be able to carry on with my Mod.
I have read a lot on the matter (at least a lot for a noob, probably hardly even the basics for a competent modder), and got stuck at my first script already.
In this script, I am trying to accomplish the following:
After the PC talked with an NPC(dermea) and got the information required (setting the journal to 20) , he has to reach level 5, and when that happens, the NPC returns for a visit while he is at sleep, wakes him up and provides another chance for a conversation, setting the journal to 30. Unfortunately, nothing of my script seem to be working, the PC does not even wake up.
Here is the result of my humble effort so far:

Begin dermeaScript

if ( Getjournalindex Gre_Initiation >= 30 )
return
endif

if ( GetPCSleep == 0 )
return
endif

if ( Getjournalindex Gre_Initiation == 20 )
if ( GetPCSleep == 1 )
if ( player->GetLevel >= 5 )
WakeUpPC
MessageBox "blablabla." "Ok"
PlaceAtPC, "dermea" 1, 128, 1
Journal Gre_Initiation 30
return
endif
endif
endif

end

I would be most grateful if you could enlighten me what I am doing wrong. Be careful, though, if you help me to solve this problem, I will be quite probably coming back troubling you with more questions "-"
User avatar
Kelly Upshall
 
Posts: 3475
Joined: Sat Oct 28, 2006 6:26 pm

Post » Tue Nov 24, 2009 2:36 am

Is this a global script that is activated after speaking to the NPC the first time? If so, you may wish to have it StopScript itself after journal stage 30 is reached.

Lines like "if ( player->GetLevel >= 5 )" sometimes give trouble, it can be worked around using something like this:


set pLevel to ( player -> GetLevel )
if ( pLevel >= 5 )
....
endif


Other than that, it looks like all of your syntax is fine. So long as the script is actually set to run when you talk to the NPC initially, I don't see why it wouldn't execute, but you may find it helpful to include extra MessageBox lines for debugging purposes. It can help you see what parts of your script you are at, and then gives you an idea of where to look for the problem.

Good luck!
User avatar
SamanthaLove
 
Posts: 3565
Joined: Mon Dec 11, 2006 3:54 am

Post » Mon Nov 23, 2009 2:41 pm

Is this a global script that is activated after speaking to the NPC the first time? If so, you may wish to have it StopScript itself after journal stage 30 is reached.

More to the point, has the global script been started? I assumed this was a global script because it is the only reliable way for it to work when checking for the player sleeping. Dialog results is the logical place to start it, but since Maotun is an inexperienced modder it is possible that he/she did not recognize the script had to be started deliberately.

@Maotun: If you do not already have some way of starting this script, add the following line to the results section of the dialog entry that updates the journal index to 20:

StartScript "dermeaScript"
User avatar
Adam Porter
 
Posts: 3532
Joined: Sat Jun 02, 2007 10:47 am

Post » Mon Nov 23, 2009 8:26 pm

It seems that I could not have been farther from solving the problem. I had neither StartScript, nor StopScript initiated in any way, believing that a script like that runs automatically when the conditions are met.

Now, "it lives"! :D

I thank you both for your kind help, it has been absolutely essential.
User avatar
Steeeph
 
Posts: 3443
Joined: Wed Apr 04, 2007 8:28 am


Return to III - Morrowind