<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="46">
  <CheatEntries>
    <CheatEntry>
      <ID>0</ID>
      <Description>"Run Console Command"</Description>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
{$lua}
if syntaxcheck then
  return
end

local command = inputQuery("The Long Dark - Dev Console", "Enter command:", "")

local rec = memrec
local uncheckTimer = createTimer()
uncheckTimer.Interval = 1
uncheckTimer.OnTimer = function(timer)
  timer.destroy()
  rec.Active = false
end

if command == nil or command == "" then
  -- Bail out if the user cancelled or submitted an empty string
  return
end

LaunchMonoDataCollector()
mono_initialize()

local consoleClass = mono_findClass("", "uConsole")
local runCommandMethod = mono_class_findMethod(consoleClass, "RunCommand")

mono_invoke_method(nil, runCommandMethod, nil, {{type=vtString, value=command}})

[DISABLE]
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>2</ID>
      <Description>"Bind Hotkeys"</Description>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>{$lua}

[ENABLE]

if syntaxcheck then
  return
end

LaunchMonoDataCollector()
mono_initialize()

function runConsoleCommand(command)
  local consoleClass = mono_findClass("", "uConsole")
  local runCommandMethod = mono_class_findMethod(consoleClass, "RunCommand")

  mono_invoke_method(nil, runCommandMethod, nil, {{type=vtString, value=command}})
end

function onF1God()
  runConsoleCommand("god")
end

function onF2Lamp()
  runConsoleCommand("lamp_infinite")
end

function onF3ZeroWeight()
  runConsoleCommand("force_gear_weight 0")
end

function onF4ResetWeight()
  runConsoleCommand("reset_forced_gear_weight")
end

function onF5Save()
  local gmClass = mono_findClass("", "GameManager")
  local saveMethod = mono_class_findMethod(gmClass, "SaveGameAndDisplayHUDMessage")

  mono_invoke_method(nil, saveMethod, nil, {})
end

function onF6Load()
  local sgsClass = mono_findClass("", "SaveGameSystem")
  local gmClass = mono_findClass("", "GameManager")
  local getSlotMethod = mono_class_findMethod(sgsClass, "GetNewestSaveSlotForActiveGame")
  local loadSlotMethod = mono_class_findMethod(gmClass, "LoadSaveGameSlot")
  local slot = mono_invoke_method(nil, getSlotMethod, nil, {})

  mono_invoke_method(nil, loadSlotMethod, nil, {slot})
end

tldF1Hotkey = createHotkey(onF1God, VK_F1)
tldF2Hotkey = createHotkey(onF2Lamp, VK_F2)
tldF3Hotkey = createHotkey(onF3ZeroWeight, VK_F3)
tldF4Hotkey = createHotkey(onF4ResetWeight, VK_F4)
tldF5Hotkey = createHotkey(onF5Save, VK_F5)
tldF6Hotkey = createHotkey(onF6Load, VK_F6)

[DISABLE]

if tldF1Hotkey then
  tldF1Hotkey.destroy()
  tldF1Hotkey = nil
end

if tldF2Hotkey then
  tldF2Hotkey.destroy()
  tldF2Hotkey = nil
end

if tldF3Hotkey then
  tldF3Hotkey.destroy()
  tldF3Hotkey = nil
end

if tldF4Hotkey then
  tldF4Hotkey.destroy()
  tldF4Hotkey = nil
end

if tldF5Hotkey then
  tldF5Hotkey.destroy()
  tldF5Hotkey = nil
end

if tldF6Hotkey then
  tldF6Hotkey.destroy()
  tldF6Hotkey = nil
end

</AssemblerScript>
    </CheatEntry>
  </CheatEntries>
  <UserdefinedSymbols/>
</CheatTable>
