server debugging mod

Place to get help with not working mods / modding interface.
Post Reply
SNACKaJACK
Burner Inserter
Burner Inserter
Posts: 13
Joined: Thu Mar 21, 2019 8:06 pm
Contact:

server debugging mod

Post by SNACKaJACK »

I have been running a small server and its been awfully annoying to monitor the servers performance in detail, because the debugging tool build in shows you only data from your local machine. I have decided I want to try to make a mod that gives more insight on the status of the server side of things while using the debug tool. Now I'm kinda new to the modding community of this game and don't 100% know what I'm doing, but while looking through the API I could not even find a single mention of the word debug. Is there a way I can add fields to the in game debugging tool with mods?
(Yea I know I will have many more hurdles to clear to get info about the server to the local machine, but first things first)

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: server debugging mod

Post by DaveMcW »

No, you cannot access any info that is not in the API.

What info are you interested in specifically? It may be in the API under a different name.

SNACKaJACK
Burner Inserter
Burner Inserter
Posts: 13
Joined: Thu Mar 21, 2019 8:06 pm
Contact:

Re: server debugging mod

Post by SNACKaJACK »

Currently I'm mainly looking to add things to the debug screen, not read from it. I want to calculate my own things based on different API's and output the results in the debug screen.
One of the things I would like to add there is a (approximated) server UPS, since there is currently no real way to find that value. (Except from a very manual workaround I found)

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: server debugging mod

Post by DaveMcW »

Your client runs at the server's approximate UPS.

If your client is too fast, it is forced to slow down.
If you client is too slow, it is disconnected.

SNACKaJACK
Burner Inserter
Burner Inserter
Posts: 13
Joined: Thu Mar 21, 2019 8:06 pm
Contact:

Re: server debugging mod

Post by SNACKaJACK »

that is true. however the UPS shown in the debug mode is not the UPS the game is actually running when you are playing a multiplayer game. Its the UPS your local machine is capable to keep up with. I noticed this when i had to move to a temporary server with kinda horrible CPU performance, the game was very noticeably slowed down because UPS was running low, however in debug mode it still showed 60 UPS and FPS. that's because my local machine was significantly more powerful than the server I ran on then.
I also estimated the UPS of the server with the manual workaround I discussed earlier. Basically you kill someone and watch the timer on his body and compare that to a stopwatch, if the times go the same speed you are at 60 UPS and if the bodies time decays slower you can calculate the UPS by using a ratio in comparison to the stopwatch. In that case found that the server was running at about 1/4th the speed of my stopwatch so it was around 15 UPS while debug was still saying 60 UPS.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: server debugging mod

Post by DaveMcW »

Code: Select all

script.on_nth_tick(60, function()
  if not global.profiler then global.profiler = game.create_profiler() end
  game.print(global.profiler)
  global.profiler.reset()
end)
Obviously you will have to design a different output method for your mod. Note that while you can display the profiler result, you can't inspect or edit it in lua.

SNACKaJACK
Burner Inserter
Burner Inserter
Posts: 13
Joined: Thu Mar 21, 2019 8:06 pm
Contact:

Re: server debugging mod

Post by SNACKaJACK »

so outputting it in debug screen is out of the question? Im guessing just writing it directly onto the screen based on a mod setting (default off) is the next best thing i can do? or is there a better way to hide it for everyone except people actively enabling it?

eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: server debugging mod

Post by eduran »

Adding to the debug screen is not possible. You can, however, create your own UI elements (in this case probably just a label displaying text) and show/hide that on a per-player basis. How you want to toggle it is up to you. A hotkey, per-player mod setting or console command can be coded.

Getting information on server UPS is going to be more tricky. Lua scripts have to run in synchronized lockstep. That means their output is identical on all machines, otherwise you would run into a desync. The closest you can come to this is reading a LuaProfiler every X seconds. It will display Y>=X seconds and you can calculate average UPS. The latter you will have to do manually, as lua has no access to the timing information.

Post Reply

Return to “Modding help”