can you help me with my script please?

Post » Fri May 04, 2012 2:38 am

hi,

iam currently working on my first mod, a nirnroot quest made from scratch, and could use some help with the script for my nirnroot.

to show that i dont want to waste your time:
http://img600.imageshack.us/img600/7645/mgescreenshot005.jpg
http://img213.imageshack.us/img213/8817/mgescreenshot004.jpg
the models are almost done (need some finetuning for the textures) and even the questline is already done.

only the nirnroot script is causing me headache as i dont know anything about scripting.


i want the script to do:
- play a soundloop, deactivate it when plant got removed
- delete the container (the plant) on activation and add ingredient to inventory
- add the quest to the journal

this is what i have:
Spoiler
Begin plant_nirnroot

if ( CellChanged == 0 )
if ( GetSoundPlaying "NirnrootSound" == 0 )
PlayLoopSound3DVP "NirnrootSound", 1.0, 1.0
endif
endif

if ( menumode == 1 )
return
endif

if ( OnActivate == 1 )
PlaySound "Item Ingredient Up"
Disable
Player->additem "NR_item", 1
endif
endif

if ( getjournalindex NR_Quest > 5 )
return
endif

if ( OnActivate == 1 )
journal NR_Quest 5
addtopic "strange plant"
activate
endif

End

this is not working:
- the soundloop is not stopping (iam thinking of moving the container somewhere, rather than deaktivating it)
- the quest is not added (when i remove "if ( getjournalindex NR_Quest > 5 )" i get the quest entry every time)


i dont know very much about scripting, i can understand what i read but i cant write something myself, so i stole the parts i needed from Syc_Herbalism and some MW scripts.

thanks!
User avatar
Natasha Biss
 
Posts: 3491
Joined: Mon Jul 10, 2006 8:47 am

Post » Thu May 03, 2012 11:08 pm

Two mistakes:
a ) The sound doesn't stop once the activator is disabled, it has to be stopped manually.
b ) There can't be more than one OnActivate per script. The second one will never be triggered.

Begin plant_nirnrootif ( menumode == 1 )returnendifif ( CellChanged == 0 )if ( GetSoundPlaying "NirnrootSound" == 0 )if ( GetDisabled == 0 )PlayLoopSound3DVP "NirnrootSound", 1.0, 1.0endifendifendifif ( OnActivate == 1 )PlaySound "Item Ingredient Up"DisablePlayer->additem "NR_item", 1StopSound "NirnrootSound"if ( getjournalindex NR_Quest < 5 )journal NR_Quest 5addtopic "strange plant"endifendifEnd
User avatar
Ells
 
Posts: 3430
Joined: Thu Aug 10, 2006 9:03 pm

Post » Fri May 04, 2012 10:29 am

thank you so much for the super fast reply and the perfectly working script :thanks:

i was trying to make the script myself for hours and didnt make it, you do it in 5 minutes!

i will make sure to mention in the readme that the script is made by you.
User avatar
Charles Weber
 
Posts: 3447
Joined: Wed Aug 08, 2007 5:14 pm

Post » Fri May 04, 2012 11:38 am

i have one more question:

is it possible to make organic containers carryable?
my idea is to make the potted nirnroot produce the ingredients root&leaves and still be able to be carryed around.

this can only be achieved via MWSE right? maybe like the armor mannequin mods or the inventory helpers mod.

this is maybe a little bit to much to ask for, but its no problem if you can not help as i can still use it as misc item.
User avatar
Jake Easom
 
Posts: 3424
Joined: Sun Jul 29, 2007 4:33 am

Post » Fri May 04, 2012 12:13 am

Portable containers are some crooked voodoo (I remember seeing some mods with them, but never bothered to learn mechanics behind it). Then again, you don't actually need the potted plant to be a container. You can make it a simple Misc item with a script that monitors time passing and gives you some Nirnroot when it's ready.

i doubt that the item has to produce ingredients while stuffed in your backpack, for that matter. It would be more logical to only make it fruit when standing somewhere (and for real roleplaying geeks - watered regularly) and if it's in your inventory, wither and die after some period of time unless planted in the outside world.
User avatar
gary lee
 
Posts: 3436
Joined: Tue Jul 03, 2007 7:49 pm

Post » Fri May 04, 2012 6:51 am

its a good idea to do it with the misc item and not a container, i will see if i can get it done.
if not i will just keep it as a decorative item.

thank you again for the help!
User avatar
Wayne W
 
Posts: 3482
Joined: Sun Jun 17, 2007 5:49 am

Post » Fri May 04, 2012 12:47 pm

Two mistakes:
a ) The sound doesn't stop once the activator is disabled, it has to be stopped manually.
b ) There can't be more than one OnActivate per script. The second one will never be triggered.

Since it's very possible Peterbitt would be dealing with dozens of references, would setDelete also help here, and if so would that stop the sound as well?
User avatar
Andres Lechuga
 
Posts: 3406
Joined: Sun Aug 12, 2007 8:47 pm

Post » Fri May 04, 2012 10:33 am

SetDelete is a tricky bastard - it doesn't delete the item immediately if it was placed by an .esp; it can't be *issued* immediately after disabling, etc. It's true that its usage is advisable for cleaning purposes, still the sound stopping is better to do by its own means.
User avatar
StunnaLiike FiiFii
 
Posts: 3373
Joined: Tue Oct 31, 2006 2:30 am

Post » Fri May 04, 2012 7:59 am

SetDelete is a tricky bastard - it doesn't delete the item immediately if it was placed by an .esp;

A good observation, Kir. Thanks.
User avatar
Ryan Lutz
 
Posts: 3465
Joined: Sun Sep 09, 2007 12:39 pm

Post » Fri May 04, 2012 7:05 am

Kir (or someone else), may you be so kind and have a short look at the following scripts please?
iam not sure if i end them properly and dont want the scripts to run endlessly, maybe there are even more errors wich iam not aware of:

ErlandilEscort (to check if npc arrived at destination)
Spoiler

begin ErlandilEscort

if ( GetAIPackageDone == 1 )
Journal "NR_Escort" 25
ForceGreeting
endif

End

ErlandilRemove (maybe this script can be merged to the above script? but somehow it must make sure that the npc only gets disabled on cellchange after the above script is finished)
Spoiler

begin ErlandilRemove

if ( CellChanged == 1 )
disable
endif

End

SoundNirnroot (just a soundloop for a misc item)
Spoiler

begin Sound_Nirnroot

if ( CellChanged == 0 )
if ( GetSoundPlaying "NirnrootSound" == 0 )
PlayLoopSound3DVP "NirnrootSound", 0.5, 1.0
endif
endif

end
User avatar
Add Meeh
 
Posts: 3326
Joined: Sat Jan 06, 2007 8:09 am

Post » Thu May 03, 2012 8:32 pm

The last script is fine, but the first two can be both combined and fixed. GetAIPackageDone is dependent on AI Commands in the same script (travel, follow), and checked/conditional by another variable, usually a short. So is this the entire script you have posted, or are you only posting a snippet?

Also, a return variable will need to be set to stop the forceGreet from looping, and a distance check from the player. It would look something like this;

Begin ErlandilStopAndTalkShort Done  Short Move  ;tracks AI packageFloat TimeIf ( Done != 0 )     returnendif;I think we're missing something here...If ( Move == 50 )     If ( GetAIPackageDone == 1 )          If ( GetDistance, Player < 512 )                ForceGreeting                Journal NR_Escort 25                Set Done to 1                Set Move to 60          Endif      EndifEndifIf ( Move == 60 )      Set Done to 0      If ( CellChanged == 1 )            disable            Set Time to ( Time + GetSecondsPassed )             If ( Time > 10 )                   SetDelete 1                  Set Time to 0            Endif      EndifEndifEnd 

[edit] I made a few changes. Without the complete idea of what AI is happening this script of course will not work. Someone will have to also test my logic, as I'm a bit rusty on scripting. :P

User avatar
TOYA toys
 
Posts: 3455
Joined: Sat Jan 13, 2007 4:22 am

Post » Thu May 03, 2012 9:10 pm

thank you Miles_Acraeus, i thought that the first two scripts could be merged.
unfortunately the script as it is now is not working, nothing triggers when we reached the destination.

the above scripts are complete and do what they are supposed to do:

- ErlandilEscort triggers when npc arrived at destination
- journal gets updated
- conversation starts

- ErlandilRemove gets triggered when the conversation is done
- npc gets disabled when player changes cell

hopefully your script can be modified to do that too.
or are my scripts ok too?

thanks!
User avatar
Chris Jones
 
Posts: 3435
Joined: Wed May 09, 2007 3:11 am

Post » Fri May 04, 2012 10:18 am

Unfortunately, you and us have different view at what to mean by "complete" and "doing what it's supposed to do". Just telling what the script is supposed to do doesn't mean it does; it doesn't mean *anything* until you get it to work in game.

First, you must realize that a Morrowind script isn't something that happens once, does some sequence of steps and then stops, like it was with simple programs before inventing event-driven programming and other scary words :smile:. The script runs from the beginning to the end at each and every frame that its owner object is present in the same cell as you, and it handles all the behavior the object might manifest. Hence, your collection of small scripts doesn't do anything really useful - they can't be all attached to the same NPC.

As for MIles' script, he obviously could only script based on partial information you gave, expecting you to be proficient enough to fill necessary gaps.

*If* I'm to assume that except talking to your character once, following him to a certain place, talking once again and disappearing, the Erlandir NPC doesn't have to do anything else, *and* also that you already managed to make him escort you by including a necessary AIEscort or AIFollow command in the dialogue, the script is basically ready to run. All you have to do is add "Set Move to 60" to the same dialogue line you use to send him walking.
Begin ErlandilStopAndTalkShort Move  ;tracks AI packageFloat TimeIf ( Move >= 70 )	 returnendifIf ( Move == 50 )	 If ( GetAIPackageDone == 1 )		  If ( GetDistance, Player < 512 )				ForceGreeting				Journal NR_Escort 25				Set Move to 60		  Endif	  EndifEndifIf ( Move == 60 )	  If ( CellChanged == 1 )			disable			Set Time to ( Time + GetSecondsPassed )			If ( Time > 10 )				  SetDelete 1				  Set Move to 70			Endif	  EndifEndifEnd 
User avatar
Chad Holloway
 
Posts: 3388
Joined: Wed Nov 21, 2007 5:21 am

Post » Fri May 04, 2012 6:25 am

Unfortunately, you and us have different view at what to mean by "complete" and "doing what it's supposed to do". Just telling what the script is supposed to do doesn't mean it does; it doesn't mean *anything* until you get it to work in game.
yeah im sorry for being so stupid, but strangely my "scripts" really work as intended ingame :blink:
i tested it often and everything from start (NPC follows via dialogue entry) to the end is just working and doesnt cause any bugs that iam (noob) able to see.

First, you must realize that a Morrowind script isn't something that happens once, does some sequence of steps and then stops, like it was with simple programs before inventing event-driven programming and other scary words :smile:. The script runs from the beginning to the end at each and every frame that its owner object is present in the same cell as you, and it handles all the behavior the object might manifest. Hence, your collection of small scripts doesn't do anything really useful - they can't be all attached to the same NPC.
thats what i was afraid of, that the script continues to run endlessly.
so i added "StopScript XXX" to the dialogue that triggers when the NPC arrives - does this do anything useful?
i would really like to understand MW scripting but i have not very much time atm, learning the dialogue system was pretty time consuming too.

As for MIles' script, he obviously could only script based on partial information you gave, expecting you to be proficient enough to fill necessary gaps.
unfortunately iam not :blush:

*If* I'm to assume that except talking to your character once, following him to a certain place, talking once again and disappearing, the Erlandir NPC doesn't have to do anything else, *and* also that you already managed to make him escort you by including a necessary AIEscort or AIFollow command in the dialogue, the script is basically ready to run. All you have to do is add "Set Move to 60" to the same dialogue line you use to send him walking.
thank you again for being so kind to help me out, i will try the script in a hour or two and make sure to try to understand it and dont cry for help when anything isnt working.
User avatar
adame
 
Posts: 3454
Joined: Wed Aug 29, 2007 2:57 am

Post » Fri May 04, 2012 1:46 am

i tested it often and everything from start (NPC follows via dialogue entry) to the end is just working and doesnt cause any bugs that iam (noob) able to see.
The trouble starts when you try to gather pieces together... :devil:

so i added "StopScript XXX" to the dialogue that triggers when the NPC arrives - does this do anything useful?
Not really. In short, there are global (and targeted) scripts that have to be started and stopped at will, and attached scripts handling particular objects' behavior that are, well, attached. Those run endlessly. In the script above, the "If ( Move >= 70 )" block does cut the rest of the script from happening when it's no longer necessary, but technically, the script is still in the running queue.

Oh, and I forgot: did you actually attach the script to the NPC? In the NPC editing form, it has to be selected in the third field from above.
User avatar
Heather Stewart
 
Posts: 3525
Joined: Thu Aug 10, 2006 11:04 pm

Post » Thu May 03, 2012 8:37 pm

its working :banana:

thank both of you so much!

its great to know that my scripts are now ok and i definitely learned alot!
i had to merge another script that was attached to my NPC into your new escort script, dont tell me i messed anything up :biggrin:

Begin ErlandilEscortShort Move  ;tracks AI packageFloat Timeshort currentDayshort localdaysPassedShort NoLoreIf ( Move >= 70 )		 returnEndifIf ( currentDay != Day )set currentDay to Dayset localdaysPassed to localdaysPassed + 1EndifIf ( Move == 50 )		 If ( GetAIPackageDone == 1 )				  If ( GetDistance, Player < 512 )								Journal NR_Escort 25								ForceGreeting								Set Move to 60				  Endif		  EndifEndifIf ( Move == 60 )		  If ( CellChanged == 1 )						disable						Set Time to ( Time + GetSecondsPassed )						If ( Time > 10 )								  SetDelete 1								  Set Move to 70						Endif		  EndifEndifEnd

i just added that little day counter thing at the top and put it below the "If ( Move >= 70 )" to avoid it to repeat endlessly. (dont know why the code has so many spaces, its not like that in the CS)

thanks again and i hope you′ll like the mod.
User avatar
LuBiE LoU
 
Posts: 3391
Joined: Sun Jun 18, 2006 4:43 pm


Return to III - Morrowind