class Modsvaskr::Xedit

Helper to use an instance of xEdit

Attributes

install_path[R]

String: Installation path

Public Class Methods

new(install_path, game_path) click to toggle source

Constructor

Parameters
  • install_path (String): Installation path of xEdit

  • game_path (String): Installation path of the game to use xEdit on

# File lib/modsvaskr/xedit.rb, line 20
def initialize(install_path, game_path)
  @install_path = install_path
  @game_path = game_path
  # Set of scripts that have been run
  @runs = {}
end

Public Instance Methods

parse_csv(csv, &row_block) click to toggle source

Parse a CSV that has been dumped by a previous run of xEdit

Parameters
  • csv (String): Name of the CSV file (from Edit Scripts), without .csv

  • row_block (Proc): Code called for each CSV row

    Parameters
    • row (Array<String>): CSV row

# File lib/modsvaskr/xedit.rb, line 59
def parse_csv(csv, &row_block)
  CSV.parse(Encoding.to_utf_8(File.read("#{install_path}/Edit Scripts/#{csv}.csv", mode: 'rb'))).each(&row_block)
end
run_script(script, only_once: false) click to toggle source

Run an xEdit script

Parameters
  • script (String): Script name, as defined in xedit_scripts (without the Modsvaskr_ prefix and .pas suffix)

  • only_once (Boolean): If true, then make sure this script is run only once by instance [default: false]

# File lib/modsvaskr/xedit.rb, line 32
def run_script(script, only_once: false)
  return if only_once && @runs.key?(script)

  FileUtils.cp "#{__dir__}/../../xedit_scripts/Modsvaskr_#{script}.pas", "#{@install_path}/Edit Scripts/Modsvaskr_#{script}.pas"
  run_cmd(
    {
      dir: @install_path,
      exe: 'SSEEdit.exe'
    },
    args: %W[
      -IKnowWhatImDoing
      -AllowMasterFilesEdit
      -SSE
      -autoload
      -script:"Modsvaskr_#{script}.pas"
    ]
  )
  @runs[script] = nil
end