Jump to content
  • entry
    1
  • comment
    1
  • views
    1008

Running Script Functions From a Batch File


Hex Bolt

459 views

Batch files offer a convenient way to run console commands, but they're limited to the available console commands.  A simple way to run a script, with all the power of script functions, is to create a simple quest that runs a script at startup and then shuts down.  Here's an example.

 

I sometimes want to know the editor ID and Form ID of the cell where my character is.  If something looks wrong there, I'd like to quickly check it in a mod editor, or perhaps it's an interesting place that I'd like to return to with COC.

 

I made a simple quest that runs a script to print the cell info to the console and then stop.

 

Spoiler

WhereAmI.png

 

 

The script

Scriptname WhereAmI extends Quest

Actor Property Player auto

Function Fragment_0()
    MiscUtil.PrintConsole(Player.GetParentCell() + " " + Player.GetParentCell().GetName())
    Stop()
EndFunction

 

The batch file

StartQuest 0WhereAmI

 

Example output

Cell <SolitudeExterior01 (0000927B)>

 

 

As another example, I have a personal mod with some non-respawning containers.  Sometimes I like to drop one at the PC's position.  I used to do that with a batch file and the PlaceAtMe command with a hard-coded Form ID.  That works until I start a new game with a different mod list and the mod index for the container changes.  I added a simple quest to that mod that passes the container ID to a script.  The script spawns a new instance of the container at the PC's position, and for good measure rotates it 90 degrees (it looks better that way).  The script also moves it 25 units in the direction the PC is facing, so I don't end up awkwardly standing on it; this also lets me place the container closer to a wall, cliff, or tree than my character can approach.

 

It's a little extra work up front, but it lets me conveniently do things that console commands alone can't accomplish.

Edited by HexBolt8

1 Comment


Recommended Comments

donttouchmethere

Posted

Weee, Hexabolt8 goes blog!

Also very useful for RL sometimes: "StartQuest 0WhereAmI "

×
×
  • Create New...