player.additem in quest stage scripting?

Post » Fri Nov 16, 2012 3:43 pm

What is the right way to add an item to the player's inventory from the quest stage scripting (or anywhere else for that matter)?

I'm not seeing any easy way to declare the player
User avatar
CSar L
 
Posts: 3404
Joined: Fri Nov 09, 2007 9:36 pm

Post » Sat Nov 17, 2012 2:29 am

you can either use a property and fill it with the player actor

or you can run a game function Game.GetPlayer()

both have their advantages and disadvantages
User avatar
Shelby Huffman
 
Posts: 3454
Joined: Wed Aug 08, 2007 11:06 am

Post » Fri Nov 16, 2012 7:19 pm

Or since it's a quest you can make a Alias that's the player.
User avatar
Zach Hunter
 
Posts: 3444
Joined: Wed Aug 08, 2007 3:26 pm

Post » Fri Nov 16, 2012 10:01 pm

both have their advantages and disadvantages

such as?
User avatar
Emily Rose
 
Posts: 3482
Joined: Sat Feb 17, 2007 5:56 pm

Post » Sat Nov 17, 2012 12:54 am

using a property is faster and cheaper than a function call get.Player(), but being a property, it is stored into the save game data and can become tedious to remove if ever changed after the mod is published.

you can reduce the cost of get.Player() by casting it as an actor variable inside of a function if you need to use it multiple times. this is my preferred method

example

Function SomeFunction()

Actor Player = Game.GetPlayer()

Player.Additem.(something)
Player.Removeitem(SomethingElse)
Player.AddToFaction(TheSomeDudes)

EndFunction


but if you only need to use a single action for player, you only need GetPlayer() once and doesnt need to be cast as a variable
User avatar
laila hassan
 
Posts: 3476
Joined: Mon Oct 09, 2006 2:53 pm

Post » Fri Nov 16, 2012 10:34 pm

That seems pretty straightforward, thanks. So for the property declarations would I just leave Player as blank then? I'm assuming that doesn't matter since it is being defined right away, but I also know it is better to give initial values for some things.
User avatar
Victoria Vasileva
 
Posts: 3340
Joined: Sat Jul 29, 2006 5:42 pm

Post » Fri Nov 16, 2012 1:02 pm

for a player property you would declare as

Actor Property Player Auto


call as Player.DoSomething()


to fill the property. go to the properties section and use (any) for the cell and Player for the specific actor
User avatar
FLYBOYLEAK
 
Posts: 3440
Joined: Tue Oct 30, 2007 6:41 am

Post » Fri Nov 16, 2012 1:57 pm

didn't realize you could just use "any" lol, thanks Amethyst
User avatar
Portions
 
Posts: 3499
Joined: Thu Jun 14, 2007 1:47 am

Post » Fri Nov 16, 2012 9:27 pm

if i remember correctly i think the (any) cell is the (0,0) tamriel persistent group cell although i could be wrong.
User avatar
Katy Hogben
 
Posts: 3457
Joined: Mon Oct 30, 2006 12:20 am


Return to V - Skyrim