TheSim

As I understand, this is the low level API of the game. It is not linked to game instance (WorldSim looks to do this job).

### Entities

```
CountEntities
CreateEntity
FindEntities
FindEntities_Registered
FindFirstEntityWithTag
GetEntitiesAtScreenPoint
GetEntityAtScreenPoint
GetNumberOfEntities
HideAnimOnEntitiesWithTag
ReskinEntity
ShowAnimOnEntitiesWithTag

```

### Common useful thing

```
TheSim:SpawnPrefab
TheSim:GetLightAtPoint
TheSim:WorldPointInPoly (x,z, poly)
- checks if (x,z) point of a map is located inside a polygon (how one can set/get custom polygon?)
TheSim:SetActiveAreaCenterpoint
- something used with wallUpdate
TheSim:HasPlayerSkeletons
- some game setting about skeletons?

```

UI
--

```
TheSim:GetIsSplitScreen
TheSim:GetScreenSize
TheSim:ProjectScreenPos
TheSim:SetCameraDir
TheSim:SetCameraFOV
TheSim:SetCameraPos
TheSim:SetCameraUp
TheSim:SetUIRoot
```

### Controls

```
TheSim:GetMouseButtonState
TheSim:GetAnalogControl
TheSim:GetDigitalControl

##### Mouse
TheSim:IsKeyDown
TheSim:GetPosition
    -- gets mouse position
TheSim:GetScreenPos
```

### Utils

```
TheSim:GetUsersName
TheSim:GetClipboardData
TheSim:QueryServer
    - REST client, there examples in the code how to do GET/POST requests

TheSim:ApplyWordFilter
TheSim:DecodeKleiData
    - used for profanity filter

TheSim:GetTick
TheSim:GetTickTime
TheSim:GetRealTime
    - time functions

TheSim:GetGameID
    - can be used to check if it is "DS" or "DST"
TheSim:GenerateNewWorld
    - not sure if it should be called directly
```

1. 1. 1. 1. In-game controls

```
TheSim:GetTimeScale
TheSim:SetTimeScale
    - can be used to pause the game (exactly this function is used by Global Pause mod)
TheSim:TogglePause
    - it is present as a commented string once in a code. I'm not sure if it can be used in practice and how it will interract with
    TheSim:SetTimeScale function
```

1. 1. 1. 1. Graphics

```
TheSim:AtlasContains

TheSim:SetVisualAmbientColour
TheSim:SetAmbientColour
    - I guess it is used to set seasonal colors.
Related APIS: "ambientlighting"

TheSim:SetRenderPassDefaultEffect
TheSim:SetErosionTexture
    - these are called only once
```

### Fonts

```
TheSim:LoadFont
TheSim:UnloadFont
TheSim:AdjustFontAdvance
TheSim:SetupFontFallbacks
```

### Sound

```
TheSim:ClearDSP
TheSim:GetSoundVolume
TheSim:RemapSoundEvent
TheSim:SetSoundVolume
TheSim:SetReverbPreset
    - E.G: Changes how sound should be in caves
TheSim:SetLowPassFilter
TheSim:SetHighPassFilter
    - I'm not a musician, I have no idea what it does. But it sounds music related.
```

Related APIS: mixer

### Prefabs loading

```
TheSim:LoadPrefabs
TheSim:UnloadPrefabs
TheSim:RegisterPrefab
TheSim:UnregisterAllPrefabs
TheSim:UnregisterPrefabs
TheSim:UnloadAllPrefabs
    - Never called in base scripts. Must be dangerous.

    P.S. `TheSim:SpawnPrefab` is listed in above
```

## Game flow controls

```
TheSim:ForceAbort
    - Used to shut down the game in case of errors from mods.
TheSim:Quit
TheSim:Reset
```

## Debug functions

```
TheSim:GetBuildDate
TheSim:GetDebugPhysicsRenderEnabled
TheSim:GetDebugRenderEnabled
TheSim:IsDebugPaused
TheSim:ShouldInitDebugger
TheSim:SetDebugCameraRotation
TheSim:SetDebugCameraTarget
TheSim:SetDebugRenderEnabled
TheSim:Step
TheSim:ToggleDebugCamera
TheSim:ToggleDebugPause
TheSim:ToggleDebugTexture
TheSim:UpdateDebugTexture

TheSim:ToggleFrameProfiler
TheSim:TogglePerfGraph

TheSim:ProfilerPop
TheSim:ProfilerPush
- These two are used in pair. As I understand you can see how long does it takes to execute your code. (I havent tried it myself, dont know how to use it in practice yet)

TheSim:SetMemoryTracking
TheSim:SetMemInfoTrackingInterval
TheSim:SetListener
    - saw this in some debug functions (debugsound, followcamera). Not sure what it does

TheSim:PrintTextureInfo
TheSim:DumpMemoryStats
TheSim:FileBugReport
TheSim:LogBulkMetric
TheSim:LuaPrint
```

## Internal systems

### General application settings

```
TheSim:ShouldPlayIntroMovie
TheSim:CanReadConfigurationDirectory
TheSim:CanWriteConfigurationDirectory
TheSim:HasEnoughFreeDiskSpace
TheSim:SetInstanceParameters
TheSim:IsNetbookMode
TheSim:SetNetbookMode
TheSim:GetDataCollectionSetting
TheSim:GetLocalSetting
TheSim:GetSetting
TheSim:SetDataCollectionSetting
TheSim:SetSetting
```

### Game Network Code

```
TheSim:ReportAction
TheSim:SendCommandToInstance
```

### Player profile

```
TheSim:Profile
TheSim:SendProfileStats
TheSim:UpdateDeviceCaps
    - something related to player profile

TheSim:GetStashedPlayInstance
TheSim:StashPlayInstance
    - something about saving the game/sending stats to klei? Not sure. Used in
```

### Resource loading functions

```
TheSim:OnAssetPathResolve
TheSim:GetFileModificationTime
TheSim:AddBatchVerifyFileExists
TheSim:ClearFileSystemAliases
TheSim:RenderOneFrame
- used in keepAlive function. Looks like it is used to avoid os thinking that game is dead to render a frame from tim to time
TheSim:LoadKlumpFile
TheSim:LoadKlumpString
- not sure what klump file is, but there is klump.lua for these
TheSim:PauseFileExistsAsync
TheSim:PreloadFile
TheSim:StartFileExistsAsync
TheSim:VerifyFileExistsAsync
TheSim:PurgeLuaFileCache

```

## Message Of The Day

```
DownloadMOTDImage
DownloadMOTDImages
GetMOTDImage
GetMOTDQueryURL
HasMOTDImage
LoadMOTDImage
SetMOTDTarget

```

### Persistent Strings

```
CheckPersistentStringExists
ErasePersistentString
GetPersistentString
GetPersistentStringInClusterSlot
SetPersistentString
SetPersistentStringInClusterSlot

```

### Mod management functions

```
TheSim:GetModDirectoryNames
TheSim:GetWorkshopVersion
TheSim:StartWorkshopQuery
TheSim:ShouldWarnModsLoaded
TheSim:GetClientModsDownloading
TheSim:GetServerModsDownloading
TheSim:QueueDownloadTempMod
TheSim:StartDownloadTempMods

TheSim:CleanAllMods
TheSim:QueryTopMods
TheSim:QueryWorkshopModName
TheSim:SubscribeToMod
TheSim:TryLockModDir
TheSim:UnlockModDir
TheSim:UpdateWorkshopMod
TheSim:VerifyModVersions
TheSim:RAILGetModDetailPage
    - some function specific to Windows ("WIN32_RAIL" is any windows?) platform used to load mod info pages
```

### Klei Stuff

I dont think any mod should touch this.

```
TheSim:IsLoggedOn

TheSim:IsDocumentsWritable
TheSim:IsAppDataWritable
TheSim:GetNumLaunches
TheSim:SendGameStat
TheSim:SendHardwareStats
    - game stats gathering functions

TheSim:SendJSMessage
    - used on browser NACL platform to redirect users

TheSim:IsDemoExpired
TheSim:SetDLCEnabled
TheSim:IsDLCEnabled
TheSim:IsDLCInstalled

##### Game demo things
TheSim:SendUITrigger
TheSim:IsDemoExpired

##### Steam stuff
TheSim:IsBorrowed
TheSim:GetSteamIDNumber
TheSim:GetSteamBetaBranchName
TheSim:GetUserHasLicenseForApp
TheSim:QueryStats
```

```
AbortFileExistsAsync
AddTextureToStreamingGroup
AppendSaveString
ApplyLocalWordFilter
ClearAllDSP
ClearInput
ConvertSlotToCloudOrLocal
CopyLegacySessionToSlot
Crash
DebugPause
DebugPushJsonMessage
DebugStringScreen
DecodeAndUnzipString
DumpMemInfo
DuplicateSlot
EnsureShardIndexPathExists
FinalizeSaveString
GetAmbientColour
GetFolderForCloudSaveSlot
GetFPS
GetGroundViewDirection
GetNextCloudSaveSlot
GetSaveFiles
GetSaveString
GetStaticTick
GetSteamAppID
GetStep
GetUserPresetFiles
GetWindowSize
GetWorkshopVersionCompatible
HasValidLogFile
HasWindowFocus
Hook
InitSaveString
IsDataCollectionDisabled
IsPlaying
IsSteamChinaClient
LoadUserFile
LockModDir
MemTrackerPop
MemTrackerPush
OpenDocumentsFolder
OpenSaveFolder
PrintLoadedTextureInfo
RegisterFindTags
RemoveLastCommaSaveString
RequestPlayerID
ResetError
SetDebugPhysicsRenderEnabled
SetHoloTexture
StopAllSounds
ToggleDataProfiler
TurnOffReverb
UpdateRenderExtents
UserChooseDirectory
ValidateHeap
WorldPointInPoly
ZipAndEncodeString

```