G.E.C.K. Scripting - AddItem From Variable

ZephyrWarrior

First time out of the vault
Hey, so, I'm not sure where to post this, but this seemed like the most applicable subreddit.
I'm trying to make a G.E.C.K. script accept a variable to add items to that player (or anyone)'s inventory. My goal is to accomplish this without having lengthy if statements checking against a numerical variable, for example "If var == 1, add item x. If var == 2, add item y." etc. Ideally it would just be "player.additem var #".


Examples of things I've tried:


Code:
ref ActiveTech
set ActiveTech to 6b465
player.additem ActiveTech 1
This did not error out, but did not work either.


Code:
ref ActiveTech
set ActiveTech to ArmorTeslaHelmet
player.additem ActiveTech 1
This did not error out, but did not work either.


(Other script)
Code:
ref ActiveTech
(This Script)
Code:
set FFOutcasts.ActiveTech to 6b465
player.additem FFOutcasts.ActiveTech 1
"Reference not allowed in this context."


(Other script)
Code:
ref ActiveTech
(This Script)
Code:
set FFOutcasts.ActiveTech to ArmorTeslaHelmet
player.additem FFOutcasts.ActiveTech 1
"Reference not allowed in this context."


It's entirely possible I'm just being stupid. I'm not a scripting novice, but I am relatively new to the G.E.C.K.


Any help would be greatly appreciated.
 
im confused

you are trying to make a script that adds items to all actor inventories or just player?


ref is not a pointer to an object but a pointer to an object type. so for example a baseball bat reference is a baseball bat. if you add 2 baseball bats you cannot pick one out of two using ref both are same ref type. kinda annoying as fuck. only quest items. npcs, actors and scripts are unique so ref on them returns that specific object. interestingly enough any of the same object with a script attached will actually create a copy of the script . so if you have a global uniqueCount that is 0 by default and add 2 baseball bats with uniqueCount = uniqueCount +1 you gonna get 2 n the global as both scripts ran and added uniqueCount + 1 + 1 . so if you need to get specific inventory objects in player's inventory you have a script running on that type of object and check if is in inventory of the player do something etc.



but for what you're asking you can do it in many ways. using a token that keeps track of what's in the inventory of the actor. using a container placed outside the actor and a script on the actor. using scripts on the objects in question that checks against a container or a form list. or if you use fose use dynamic form lists . etc etc.
 
Last edited:
yeah i was looking on GECK seems first option should be legal but you may be missing the flag

rContainer.AddItem Pencil01 1 1
1 = 1 item last 1 = hide message

should work first 2 options but you must do it this way

ref ActiveTech
set ActiveTech to ArmorTeslaHelmet
player.additem ActiveTech 1 1
 
Back
Top