Add an item via script

Post » Fri May 27, 2011 6:58 am

How would I script a number of items to be automatically added to the players inventory when the game is started or loaded? I've found the script option, I just don't know what to put in there.
User avatar
Heather M
 
Posts: 3487
Joined: Mon Aug 27, 2007 5:40 am

Post » Fri May 27, 2011 2:33 am

How would I script a number of items to be automatically added to the players inventory when the game is started or loaded? I've found the script option, I just don't know what to put in there.
Make a new 'YourQUST' quest and tick its "Start Game Enabled" flag. You'll need to attach a quest script to it...
scn YourSCPTBegin GameMode    Player.AddItem CigaretteCarton 1    StopQuest YourQUSTEnd
...and you'll be given one cigarette carton before the quest stops itself.
User avatar
KU Fint
 
Posts: 3402
Joined: Mon Dec 04, 2006 4:00 pm

Post » Thu May 26, 2011 8:17 pm

I would make a quest, set it to start game enabled, and then make a quest script like this and add it to the quest.

scriptname aaMyScriptshort doonceBegin GameModeif doonce == 0   player.additem "Editor name of the items you want to add" 1   set doonce to 1   stopquest YourQuestsNameendifEnd



Edit: Ninja'd :P
User avatar
Aaron Clark
 
Posts: 3439
Joined: Fri Oct 26, 2007 2:23 pm

Post » Thu May 26, 2011 11:02 pm

I would make a quest, set it to start game enabled, and then make a quest script like this and add it to the quest.

scriptname aaMyScriptshort doonceBegin GameModeif doonce == 0   player.additem "Editor name of the items you want to add" 1   set doonce to 1   stopquest YourQuestsNameendifEnd



Edit: Ninja'd :P


The items I have are armor pieces that I converted from a mod for Fallout 3. I created a new esp and added the 10 or so items in there, and it appears to be ready to go.

When you say "editor name of the items you want to add", do you mean the "ID" of the item? and what is doonce?

Would this be correct?

scriptname mysterious

short doonce

Begin GameMode

if doonce == 0
player.additem "10TKmysterious" 1
player.additem "10TKmysterious2" 1
player.additem "10TKmysteriouscoat" 1 (etc, etc, etc)
set doonce to 1
stopquest mysterious
endif

End


or

scn mysterious

Begin GameMode

Player.AddItem "10TKmysterious" 1 (etc, etc, etc)
StopQuest mysterious

End

User avatar
Amysaurusrex
 
Posts: 3432
Joined: Wed Aug 09, 2006 2:45 pm

Post » Fri May 27, 2011 2:14 am

I just tried creating a script and it wouldn't let me leave even after saving it, or name it, and closing it finally just deleted the script - so it wasn't saved anywhere. I'm not understanding this, please elaborate more. A walkthrough on how to do it correctly would be great.
User avatar
Sasha Brown
 
Posts: 3426
Joined: Sat Jan 20, 2007 4:46 pm

Post » Thu May 26, 2011 8:30 pm

Yes, I meant the ID of the items. I would just use that last script you have, the one that JustinOther wrote is more compact than the one I wrote as the DoOnce check really isn't necessary in this case. So you're good to go.
User avatar
Nancy RIP
 
Posts: 3519
Joined: Mon Jan 29, 2007 5:42 am

Post » Fri May 27, 2011 8:29 am

One thing also, I remember running in to problems when IDs started with numbers, like you have there. It's a much better practice to start them with a letter. Also, remove the quotation marks around the item IDs, I should have noted those shouldn't be there.
User avatar
stevie trent
 
Posts: 3460
Joined: Thu Oct 11, 2007 3:33 pm

Post » Fri May 27, 2011 3:51 am

One thing also, I remember running in to problems when IDs started with numbers, like you have there. It's a much better practice to start them with a letter. Also, remove the quotation marks around the item IDs, I should have noted those shouldn't be there.


Yes, this is important information. :P

I will report back in a sec.

There are some other things though. I'm looking at the particular item and there's a script box in there, and also one on the taskbar. I clicked the one on the taskbar, set it to quest, and did what you guys said here. Also, do I have to put this script on each item or will this run automatically?
User avatar
Judy Lynch
 
Posts: 3504
Joined: Fri Oct 20, 2006 8:31 am

Post » Thu May 26, 2011 8:03 pm

Haha sorry. :P

No, don't attach it to each item. Just make sure the script type is a quest script and then attach it to the quest you made.
User avatar
jessica sonny
 
Posts: 3531
Joined: Thu Nov 02, 2006 6:27 pm

Post » Fri May 27, 2011 8:39 am

Haha sorry. :P

No, don't attach it to each item. Just make sure the script type is a quest script and then attach it to the quest you made.


Ok, this is something new. I haven't made a quest before.

So, quest name, id, start script enabled, and the script I'm going to create is all I need to do for that?

and which one of these will appear in the quest log?
User avatar
Isabel Ruiz
 
Posts: 3447
Joined: Sat Nov 04, 2006 4:39 am

Post » Thu May 26, 2011 9:36 pm

So, quest name, id, start script enabled, and the script I'm going to create is all I need to do for that?

and which one of these will appear in the quest log?


Yup, that should do it! Except you won't need a quest name as I don't think you'll want this showing up as a quest in game. The reason your making a quest is just so you can have the script run in the background and add the items the first time the game loads with this mod active.
User avatar
Brandi Norton
 
Posts: 3334
Joined: Fri Feb 09, 2007 9:24 pm

Post » Thu May 26, 2011 9:57 pm

Yup, that should do it! Except you won't need a quest name as I don't think you'll want this showing up as a quest in game. The reason your making a quest is just so you can have the script run in the background and add the items the first time the game loads with this mod active.


Still having problems with saving it. I click save and close it, and nothing appears in the quest script box and all of that gets deleted.

Nevermind, it worked this time. =/ Guess I'm gonna try it and see what happens.
User avatar
LuBiE LoU
 
Posts: 3391
Joined: Sun Jun 18, 2006 4:43 pm

Post » Fri May 27, 2011 1:26 am

Good to hear, hope it all works for you. :)
User avatar
Calum Campbell
 
Posts: 3574
Joined: Tue Jul 10, 2007 7:55 am

Post » Thu May 26, 2011 7:46 pm

Ugh. Once I get the quest added and then finally get the script to save properly, I save the esp, quit and reload it and all the items are gone but the quest is still there....
User avatar
Kat Ives
 
Posts: 3408
Joined: Tue Aug 28, 2007 2:11 pm

Post » Fri May 27, 2011 5:49 am

Ugh. Once I get the quest added and then finally get the script to save properly, I save the esp, quit and reload it and all the items are gone but the quest is still there....


This isn't working. Everything is fine until I try to add the script that adds these items. Once I do that, save it and then close/reopen it, it deletes all of the items in the esp and only the quest remains - and it still won't have the script attached to it. I just tried running the game with this all added in - despite the fact that the items were deleted - and it didn't do anything.
User avatar
Allison C
 
Posts: 3369
Joined: Mon Dec 18, 2006 11:02 am

Post » Fri May 27, 2011 12:37 am

I finally figured this out - what a pain in the behind.

Thanks everyone for the help.
User avatar
lilmissparty
 
Posts: 3469
Joined: Sun Jul 23, 2006 7:51 pm


Return to Fallout: New Vegas