npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dst-ts-api

v0.0.3

Published

饥荒联机版API

Readme

dst-ts-api

存档目录

~\Documents\Klei\DoNotStarveTogether

日志

服务端(森林):~\Documents\Klei\DoNotStarveTogether\master_server_log.txt

服务端(洞穴):~\Documents\Klei\DoNotStarveTogether\caves_server_log.txt

客户端:~\Documents\Klei\DoNotStarveTogether\client_log.txt

源码解析

源码位置

C:\Program Files (x86)\Steam\steamapps\common\Don't Starve Together\data\databundles\scripts.zip

main.lua

该文件是主入口,在ModSafeStartup中调用ModManager:LoadMods进行Mod加载。

mods.lua

ModWrangler就是在此文件中定义,在ModWrangler:LoadMods中处理了几件事:

  1. 通过KnownModIndex:UpdateModInfo更新所有Mod信息,该步骤需要Mod定义modinfo.lua文件。

  2. 通过KnownModIndex:LoadModOverides加载modoverrides.lua文件(这个文件不是Mod提供的,而是在存档目录下,只有一个,里面记录了所有Mod的配置)。

  3. 通过KnownModIndex:ApplyEnabledOverridesmodoverrides.lua中配置了enabled = true的Mod进行启用,否则禁用。

  4. 通过KnownModIndex:GetModsToLoad获取需要加载的Mod。

  5. TODO(了解该方法作用) KnownModIndex:LoadModConfigurationOptions暂不清楚作用。

  6. 通过CreateEnvironment为Mod创建一个环境,可以从这里查找Mod能使用的方法,具体方法将在后续解析。

  7. 通过KnownModIndex:ApplyConfigOptionOverrides应用modoverrides.lua中的Mod配置。

  8. 根据Mod的优先级排序。

  9. TODO(了解该方法作用) kleiregistermods 暂不清楚作用。

  10. TODO(验证猜想) 将Mod的scripts目录加入到package.path以加载其中的脚本,按照逻辑后面的Mod可以使用前面Mod的组件。

  11. 通过InitializeModMain先后调用Mod中的modworldgenmain.luamodmain.lua

CreateEnvironment创建的环境有以下方法:

  1. TODO(列出环境中的方法)

Mod结构

modmain.lua、modworldgenmain.lua

这两个文件是通过InitializeModMain方法调用的,全局变量从CreateEnvironment就能知道。

scripts/**/.lua

这个文件夹里的脚本是通过如EntityScript:AddComponent等方法来间接导入的,这些模块早已导入到游戏中,因此scripts/**/.lua也只会继承这些模块里的全局变量而非为Mod提供的CreateEnvironment里的全局变量。