Jump to content

Scripting in Fallout New Vegas for Dummies

Guest tomm434

Recommended Posts

Guest tomm434

Tired of contributors not being your personal wish executors? Want to learn scripting but don’t know where to start? Then this tutorial is for you!


First, this is alternative to “Bethsoft Tutorial Basic Quest” on GECK wiki. When I started scripting, it didn’t helped me a bit. I needed something to start with but there was no information about the very basic things. This tutorial is all about basic things, I aim to give you the starting boost you need to get into scripting, nothing more.


Before we start – what do you need?

  1. Fallout New Vegas
  2. GECK
  3. GECK Power UP
  4. NVSE

So you probably have Fallout already. Next comes the GECK.You can download it here (Fallout NW version)


Put it in your NW folder.

Next thing you want is to get GECK Power Up(you don’t want to script without it). Download it from here and put everything in Fallout folder (http://www.nexusmods.com/newvegas/mods/41642/?) - you can choose any version you want, Of course last one is the best.


Then you need NVSE. You probably already have one but in case you don’t, you should get it immediately. Imagine that every moment you’re playing without NVSE someone else getting his ass kicked IRL. Do you want that?Are you that cruel? I doubt so.

So, create shortcut from nvse_loader and add line “-editor”

The whole file path should look like this


“"C:\Games\Steam\SteamApps\common\Fallout New Vegas enplczru\nvse_loader1.exe" -editor”

From here on in you always run GECK through NVSE loader(this shortcut)

Why do you need NVSE


It adds new function and gives you new possibilities.



Start GECK, click "File-Data" and load FalloutNW.esm.

That’s all –you’re good to go!





Let’s start with one main principle of Fallout scripting – how does scripts work?

The combination is very simple  - I call it – EVENT(Conditions) – SCRIPT(Result).

You have EVENT which defines when script will run.(Game engine asks YOU "In what circumstances do you want script executed?")

You have SCRIPT which defines what will happen when EVENT comes true. (Game engine asks YOU "What exactly should I execute?")

A simple example

If playerRef. GetActorValue health <50

This code kills player character when his health goes under 50.

Read about GetAV.


GetActorValue == GetAV

“If playerRef. GetActorValue health <50” == “If playerRef. GetAV health <50”

If playerRef. GetActorValue health <50 is an event(condition). - According to it  result script executes only if player heatlh <50

PlayerRef.kill is a script(Result) which executes after condition is true (and it kills player)

Every condition has its borders. We tell game engine where they are by fencing them with If and Endif. Thus we have precision and we are sure that Script happens in the exact circumstances we need. This is probably hard to understand a first but you can look in spoiler. It’s not necessary for you right now and if you don’t understand it, you will in future.




Why do we need Ifs and Endifs?

Imagine that you have this code

If playerRef.getav health <500
If playerRef.GetIsSex male ==1

So how is game supposed to know in which circumstances player needs to be killed – if his health is less than 500 or if his sex is male? That is what Ifs and EndIfs for.

For example we need to make a script which adds item to player if his health <500 but if he is also a MALE – kills him (Sound feminine, I know).

In that case Ifs and Endifs wil be placed like that


If playerRef.getav health <500
playerRef.additem Weap10mmPistol 1

   If playerRef. GetIsSex male ==1

 playerRef.additem dogmeat 1


Script always go Up-Down meaning it will always check “If playerRef.getav health <500” contition first and executing everything that is between it and contidon’s endif(Red one).

In our case “player.additem 10mmpistol 1” line will execute(But NOT playerRef.additem dogmeat 1 - it is placed inside "If playerRef.getav health <500 - Endif conditions but If player. GetIsSex male ==1-endif  are there too and they are higher than yellow line )




Then game engine will face another condition – “If playerRef. GetIsSex male ==1”. If this is true, script will execute and player will be killed. If player is female, then conditions is not met and it will be fully skipped. That means blue code is not executed at all and game script continues to go down.


To make sure there are no misunderstanding, I will explain the process again:



1) First I execute  " playerRef.additem Weap10mmPistol 1"

2)Then I check "If playerRef. GetIsSex male ==1" condition. If it's true, I will execute everything inside it and move forward(to point 3). If it's not true, I will skip it utill it's endif and move forward(to point 3)

3) Then I will execute playerRef.additem dogmeat 1 line








Now we’ve got a condition and a script to execute. But where do we place them?

We can do it in many places but let’s start with a quest first. What is a quest? Basically, it’s what it sounds like -  an objective which player need to complete. In GECK quest contains of  scripts and dialogues. Usually, it is everything that is needed for a task – someone tells you to find a item and then scripts spawns that item. But it’s not important right now. We’re not going deep today.

First –create your own quest. Select “quest” subfolder from “Actor data”, rightclick and choose “NEW”. Then follow the instruction on picture.






Give quest a name and unique ID(I recommend starting ID from “aa” prefix because your quest will be easy to find in that case.). it’s important that first time you enter Quest name and ID  you don’t switch to other tabs because it will reset every field in “Quest Data” tab.

After you hit OK, find your quest and open it again. Now hit […] button. You’ll see and empty window. Click “Script” and choose “New..”. Then change Script type from “ObjectScript” to “QuestScript”. The copy the code below and save it.


Scriptname  aaMyQuestScript
Begin gamemode

  If playerREf.getav health <50
    PlayerRef.additem DogMeat 1


Then open the “quest data” tab again and choose in script list “aaMyQuestScript”.



Now stop and think about what you’ve just done.


1)First, you created your own independent quest.


2)“Start game enabled” check means that quest script will run from the start of the game(If you load existing safe, it will run too). The things is – you don’t need to start it manually.


3)Quest script is the script which is tied up to this quest. Exactly this script will run when quest starts(you already tied up quest script to quest if you followed he instruction)


What are the lines in quest script for?

The first one line is situated in every script there is in the game

Scriptname  aaMyQuestScript

It defines ID of the script (just how ID field in “Quest data” tab defines ID for script).

"Scriptname  aaMyQuestScript" is the same thing as "scn aaMyQuestScript".

I prefer long version though, it's more beautiful in my opinion.



Then you have “begin gamemode” block. This is a block. It’s pretty much like Conditions, only that blocks are more important. In out case this block tells game engine that everything inside it will run during gameplay. Just like contidions have Ifs and Endifs, blocks have “Begin” and “End” words. Read about gamemode block at Geck wiki


Remember that EVERY CONDITION AND SCRIPT should be placed inside gamemode block(Between “Begin gamemode” and “end”)


So, what do we have now? We have a quest which will run the moment you start playing and check if player’s health is less than 50. Then player will receive a dog meat. All you need to do is to save esp from GECK and activate it in your favorite mod manages(NEXUS MOD MANAGER OR FOMM OR Vanilla game launcher)


All quest scripts are made this way(Scriptname + gamemode block). Inside you can insert any conditions you like and I will be checked every 5 seconds. This is called script processing delay and it defines how faster will the code be executed. In our case game checks if  player’s health  is less that 50 every 5 seconds.


That means that if between checks PC’s health will drop to 49, nothing will happen. For script to work PC need to have less than 50 health in the exact moment script proceeds. We can lower that delay. If “Default” is checked – script processing delay is eval to 5 seconds. You can set it to any value more than 0.00001. You want script to run every 200 seconds? Why not? Just set Script processing delay and it will happen. But it’s not recommended to set delay to less than 0.0015 seconds because it will slow the game down for some PCs(remember – not only your quest is working – there are heavy mods that check not only for player’s HP but dozens of others conditions). You won’t notice the difference between 0.1 second 0.001 quest delay(except very rare cases but you don’t need to worry about that right now) but your CPU will.

If you want your code to run just one time you’ll have to introduce variables. But that’s for another guide.



Instead of “playerRef” part  in “playerRef.GetAV health <500” or “playerRef. GetIsSex male ==1” you can insert any actor. It will look like “ActorRef.getav health <500”. This is where we come to references.  That is also for another guide but for example you can transform our quest code for Sunny in Goodsprings. Every unique NPC in the game has his Reference. Reference is set in GECK and is used to give actors command or check his conditions. So, in GECK Sunny will have name “GSSunnySmiles”(type it in search field). But ingame we can’t give her commands by this name. Ingame she will have name “SunnyREF”. How can you know her reference?

(reference is not neccesariy have to end with postfix "Ref". It is added by developers to not get confused )

  1. Look at any script concerning her and copy Ref from there
  2. Go into “GSProspectorSaloonInterior” cell in cell list and double click on her. You will see her reference and the top field.

So, code with her will look like this:

If SunnyREF.getAv health <50
SunnyRef.setunconsious 1

Now compare it with player code. See the resemblance?

So if Sunny’s health <500, she will go unsoncsious. It can spoil your savegame and quest progression though.


Now you know everything you need to start scripting. Try placing “If player. IsWeaponOut” or “player.isRunning”.



Basic conditions and functions are listed here



Some random advices:


- Open vanilla quests and see what’s going on there, copy-paste some code.


-read another tutorials which go deeper into details (variables, nested conditions etc)


-download mods you are interested in and open them in GECK to see the script and learn from it.


-Don’t be afraid to experiment – nothing bad will happen to you. Just keep the save you did before starting the mod and you’ll be fine. You can always switch off esp from Fallout.


-If GECK Power UP tells you that script is broken – listen to it.  All broken script will not work in game. Just one error line will stop the whole script from progressing further down. Don’t hope that GECK makes mistakes – in 99% it doesn’t.


-Don’t be confused when tutorials say that some conditions “return” numbers. Return mean that instead of “player. GetIsSex male ==1” and player being male, game will transform it into “1 ==1”.

So, player.GetisSexMale will return (transform) into 1 if player character is male thus conditions will be true.

If player sex is female, “player.GetisSexMale” will return 0 and you will get “0==1” but “0!=1” so conditions is not true and code will not execute.


- Remember that any line that doesn’t have “==”(is not equal to something) is NOT equal to 0 . Meaning


 “If playerRef. GetIsSex male” is same thing as“if GetIsSex Male !=0”


which in this particular case is equal to “If playerRef. GetIsSex male ==1” (because GetIsSex male can return only 0 or 1).So if GetIsSex male !=0, it can only be equal to 1 and vice versa.




-Some useful commands


-playerRef.additem ItemName Count – gives player an item. You can see item’s name in GECK.

Player.additem DogMeat 7 will give player 7 DogMeats

PrintC “Your text here” –prints into console “Your text here” You will see only the message in console.

MessageEx “My message here” – will create a message in the top let corner of the screen with “My message here” text

MessageBoxEX “My message here” – will create a box at the center of the screen with your text.

Remember that if you leave any command without conditions(like that)

Begin gamemode
MessageEx “player is a dumbass”

Message will appear according to your script delay(every 5 seconds, every 0.01 seconds etc). No conditions are here so it will be executed under any cirsumstances according to Quest script delay. Still Event-Script principle works here. In this case event is "gamemode block".(Game engine asks you - When does script happen? - you answer - during gamemode)



Note about "player" and "playerRef". You can use "player" instead of "playerRef" but playerRef is recommended because some of NVSE command may glitch if you use "player"   fixed in v4.5 Beta 6 Still it is better to use PlayerRef when you mean PlayerRef (not player base object)



Well, I hope this is helpful for somebody. On the other hand, everybody is welcome to critisize it.


Link to comment
Guest tomm434
Good stuff man, keep it up!


Thanks a lot! I was planning to do 6 parts of the guide. 2 are already done. Third will be about dialogues and quest stages. Forth is about creating new NPC. Fifth is about Sexout. Part 6 will be about misc things(like nested conditions, spells) something that you might eventually need and which will save your time and nerves. So after reading 5 of them a person will be able to make a Sexout mod with existing or his own characters, that's my goal. But these are just plans. The most difficult part for me is about dialogues - it might be tricky to explain how they work.

Link to comment
  • 2 months later...
  • 8 months later...

How do you open a current mod to edit the scripts. I want to open crowdsB and read the scripts, but I seem to be opening the main fnv Esm also, and there are so many scripts I do not know what they are doing. Or which are with crowdsB and which are not.


Brand new at scripting.

Link to comment

Can't open a plugin without also opening its masters - after all they're needed.

If you select the plugin and hit "details" before you open, you can see a list of its assets. It can help to see if there's a prefix used throughout the mod that can help with looking things up.

Link to comment
  • 3 years later...


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use