Jump to content

Debug Keys


Cheerio

Recommended Posts

  • Developer

In the latest build, the debug keys used here at Klei are now available for use.  You guys might already have something similar to this but I thought you might find some of these useful.  They used to not be part of the build but were never re-enabled after modding support was added which basically lets you cheat like no other :).

 

If you want to give it a try, they're all listed in 'debugkeys.lua'.  Just add these two lines to your 'modmain.lua'.

 

GLOBAL.CHEATS_ENABLED = true
GLOBAL.require( 'debugkeys' )
 
The two keys I use all the time are:
- CTRL-R:  jumps from in game to the main menu and reloads all your scripts.
- Right Shight: jumps from main menu into the first save slot.
 
Using these two keys you can just iterate on scripts without having to restart the game.  You can also use '0' to jump to the caves instead.
Link to comment
Share on other sites

This is so awesome! It's the most tedious part to quit and restart the game every time I change a script. So this will save me (and probably everyone else) a ton of time. I'm curious to see what other stuff are in stores ^^

A possibly stupid question: Is there also a way to reload your script after runnning into an error screen? Cause that would make me never shut down Don't Starve.

Link to comment
Share on other sites

This is so awesome! It's the most tedious part to quit and restart the game every time I change a script. So this will save me (and probably everyone else) a ton of time. I'm curious to see what other stuff are in stores ^^

A possibly stupid question: Is there also a way to reload your script after runnning into an error screen? Cause that would make me never shut down Don't Starve.

Alternatively, you may also use the attached mod.

What it does is add a "Reload Game" button to error screens, which reloads the current save if a save is being played, and the main menu otherwise. When reloading, all mods are reloaded as well.

ReloadOnError.zip

Link to comment
Share on other sites

You're also welcome to use (and tweak as you see fit) a little mod I've been using (and just now extended to include the enabling of debugkeys, as well as a slightly improved version of the mod I previously posted). It's a very simple mod, with just a few conveniences for general testing.

Sweet, thanks  ^^  I'm not quite sure I know what it does from your post but it must be good, so I'll take a look when I can

Link to comment
Share on other sites

Sweet, thanks  ^^  I'm not quite sure I know what it does from your post but it must be good, so I'll take a look when I can

It's very basic (so I wouldn't call it "good", just "something you may find useful"). I didn't detail what it does because the code is very simple, short and self-explanatory. But here's the list:

  • Enables debug keys.
  • Adds a new row of buttons to error screens, with a button for reloading the game state (like the previous mod) and another one for going straight to the main menu (without any saving).
  • Runs consolecommands.lua (redundant if you also use Better Console) and exports a utility function called gimme(), which works like DebugSpawn, except that it returns the spawned entity (so that you can set it to a variable for further console work on it) and also sets it as the debug entity (accessible through the console command c_sel()).
Link to comment
Share on other sites

It's very basic (so I wouldn't call it "good", just "something you may find useful"). I didn't detail what it does because the code is very simple, short and self-explanatory. But here's the list:

  • Enables debug keys.
  • Adds a new row of buttons to error screens, with a button for reloading the game state (like the previous mod) and another one for going straight to the main menu (without any saving).
  • Runs consolecommands.lua (redundant if you also use Better Console) and exports a utility function called gimme(), which works like DebugSpawn, except that it returns the spawned entity (so that you can set it to a variable for further console work on it) and also sets it as the debug entity (accessible through the console command c_sel()).

 

Sounds "good" to me, like in "very useful"  ; )  So thanks again!

Link to comment
Share on other sites

Is there a way to get it to flush the logs? I notice I can get an error on a brain or stategraph construction, and the displayed error is just a null pointer. The logs have the second trace above it - but when I use the refresh it doesn't appear to dump the contents to let me see what I missed

Link to comment
Share on other sites

  • Developer

Is there a way to get it to flush the logs? I notice I can get an error on a brain or stategraph construction, and the displayed error is just a null pointer. The logs have the second trace above it - but when I use the refresh it doesn't appear to dump the contents to let me see what I missed

I don't think you can because it has exclusive access to the file and there's currently nothing exposed to flush it.  I've always wanted it to flush the logs so if I get some time, I'll look into it :).

Link to comment
Share on other sites

@Cheerio I have looked through the DebugKeys and it knda openened my eyes to some very useful functions TheSim has to offer that I didn't know before. Though some things are kind of confusing, I hope you don't mind if I ask you this single question (beware, it might be stupid)

What does

TheSim:SetTimeScale

actually do. I've been setting all different values and can't seem to figure out any difference. And it sounded so cool at first...

Link to comment
Share on other sites

  • Developer

@Cheerio I have looked through the DebugKeys and it knda openened my eyes to some very useful functions TheSim has to offer that I didn't know before. Though some things are kind of confusing, I hope you don't mind if I ask you this single question (beware, it might be stupid)

What does

TheSim:SetTimeScale

actually do. I've been setting all different values and can't seem to figure out any difference. And it sounded so cool at first...

I've never used that before and I don't know if anyone currently uses it.  The code seems to imply that it will scale the game's update time which sounds like it could speed up or slow down the game time.  It also seems to clamp the range between 1 and 4.

Link to comment
Share on other sites

I've never used that before and I don't know if anyone currently uses it.  The code seems to imply that it will scale the game's update time which sounds like it could speed up or slow down the game time.  It also seems to clamp the range between 1 and 4.

And I was hoping for a secret slow-mo-function xD  For waht it is now I can just as well use DoLongUpdate I guess.  Thx  ^^

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...