Don't Starve Together

Don't Starve Together

43 ratings
[API] Time Control
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
312.029 KB
9 Aug, 2021 @ 4:33pm
12 Jul, 2022 @ 10:19pm
7 Change Notes ( view )

Subscribe to download
[API] Time Control

In 1 collection by 󰀏Niko
My favorite creations
9 items
Description
An API mod made to allow creators to add time manipulation for individual objects and the world itself. Many actions such as harvesting and crafting are currently unaffected by local timescale. I am trying to find a fix for this.

If you have the "Dev tools" mod you can access a handy-dandy little menu for easily adjusting global or local timescales and toggling debug mode as seen in the above screenshot. Amazing for testing out what this mod is capable of.

All functions will work identically when ran from both server and client and will automatically make sure every current client is synced up. You must be an admin to call these functions from the client.

Note that when using a function from the console "GLOBAL" is not required, however elsewhere it is.

---[Global timescale]---
<Overview>
Global timescale is the speed of the world itself as seen by all players, lower speed makes everything play in slow motion and may make animations a bit choppier. Higher speed makes the world faster and has no noticeable issues.
Setting to 0 may cause issues.
Currently global timescale is not saved so reloading a save may require it to be readjusted.

<Functions>
"GLOBAL:SetGlobalTimeScale(nil, value)": adjusts the global timescale to "value".
For example, typing "SetGlobalTimeScale(nil, 0.5)" in the console will make the game go at half the speed it normally does.

"GLOBAL:GetGlobalTimeScale()": outputs the global timescale, that's all.


---[Local timescale]---
<Overview>
Local timescale is the speed of a particular object, an object with lower speed will move slower, have slower animations, and SOME actions will take longer. local timescale seems to not play well lag compensation, it is recommended to turn it off when adjusting local timescale of the player. Very high values may make some actions fail.

<Functions>
"GLOBAL:SetLocalTimeScale(nil, inst, value)": adjust the local timescale of "inst" to "value".
For example, typing "SetLocalTimeScale(nil, ThePlayer, 2)" in the console will make your character move at twice the speed, play animations twice as fast, and do some actions faster.

"GLOBAL:GetLocalTimeScale(nil, inst)": outputs the local timescale of "inst", that's all.


---[Other functions]---
"GLOBAL:SetTCDebug(nil, boolean)": adjusts debug settings, currently only "true" or "false". Setting this to true will have it tell you anytime it does anything. Most function will tell you who or what activated them, useful for pinning blame on a pesky admin or player who sneakily got admin access.
11 Comments
芬迪 17 Sep @ 9:46pm 
Hello, whenever I enable this mods, it always shows that there is something wrong with the server, etc. If I turn it off, it will be fine. I have tried it for a while and it is really a problem with Hat kid. I'm sorry:steamsad: @skylarr
Skylarr  [author] 26 Nov, 2021 @ 4:38pm 
After some light experimentation, your attack period code just needs some slight adjustment to work, and it appears to work without errors in my uses. Here's what I've used.

https://pastebin.com/W8RNh2Gy
󰀏Niko  [author] 12 Nov, 2021 @ 1:20am 
Oh, silly me, I didn't apply my changes to anything other than the debug function, my bad.
Skylarr  [author] 11 Nov, 2021 @ 11:16pm 
I hate to bother you more, but I'm not sure if the update fixed the problem, still getting the same crash.

I think it may be best to check if it's the server sending the command inside IsAdmin(), something like this https://pastebin.com/xUXnmH1U
󰀏Niko  [author] 11 Nov, 2021 @ 3:43pm 
I think either it didn't work well and/or it had side-effects that I wasn't happy with.
Skylarr  [author] 11 Nov, 2021 @ 10:51am 
Awesome! While I was snooping around in the mod, I noticed commented out code that adjusts attack period, is that code broken? For my use, having the attack period adjustment would make a lot of sense.
󰀏Niko  [author] 11 Nov, 2021 @ 9:20am 
I think that I have fixed the issue, seems that I forgot to have it not check if the sender was an admin when it's the server that sent it.
Skylarr  [author] 10 Nov, 2021 @ 10:43pm 
It was a locally hosted server with caves enabled, not dedicated. World settings and such were completely set to default and I was the only player on the server. I was calling SetLocalTimeScale() from a prefab in my mod.

Now that I think it, does IsAdmin() check if there actually IS a player or not?
󰀏Niko  [author] 10 Nov, 2021 @ 9:51pm 
Hm... interesting, Ill have to look into that tomorrow. In the meantime If you could tell me a bit more information of the server settings such as was it a hosted world or a dedicated server, and were caves enabled?
Skylarr  [author] 10 Nov, 2021 @ 1:30pm 
I'm getting a crash when calling SetLocalTimeScale, though it seems to not be related to the actual time manipulation, rather the IsAdmin check is failing, though I'm not experienced enough to fix it myself. I bypassed the crash by just making IsAdmin always return true, but of course that's temporary.

Crash Log: https://pastebin.com/Sw6EMYj0

This tool is great so far, when bypassing the crash it works (as far as I can tell) pretty well! I didn't even know you could manipulate stategraphs like you did, but I guess I have a lot to learn then.