Jump to content

Scripting with Sublime


Cheerio

Recommended Posts

  • Developer
Sublime is a really fast multi-platform free text editor with a ton of useful features.  It's also the most popular editor used to write lua here at Klei.  This guide will give you an introduction to what I think are some of it's most useful features.  This is not an introduction to modding or scripting however I do hope that both beginning and expert modders might find this guide useful :-).

 

Setup:

1. Install Don't Starve for Windows, Mac or OSX.

2. Install Sublime.

3. Unzip dont_starve_sublime_project.zip to your 'dont_starve/mods' folder.

4. Launch Sublime and click on 'project->open_project' and open the 'dont_starve.sublime-project' file.

 

Sidebar

post-283016-0-82588300-1381468540_thumb.

The tree view on the left side is called the Sidebar.  If you don't see it, you can turn it on in the 'view->sidebar' menu option.  The sidebar lets you browse both the script files used in 'Don't Starve' as well as any script files from any mods you may have downloaded.  What I really like about the sidebar is how it opens files just by clicking them.

 

Goto Anything - Shortcut='CTRL+P'

post-283016-0-59230600-1381467795_thumb.

This dialog lets you search for files and preview their contents.  Once you start getting used to the filenames in the project, it becomes much faster to open them through this window.

 

Goto Line - Shortcut='CTRL+G'

post-283016-0-71015600-1381467803_thumb.

This dialog lets you jump to a line within a file.  This is really useful when scripting because whenever you have a script error, 'Don't Starve' tells you the file and line number.

 

Find - Shortcut='CTRL+F'

post-283016-0-95760200-1381468459_thumb.

This dialog lets you search the currently opened file for a given string and will outline anything that matches it. You can then press 'F3' to jump through each match.

 

Find in Files - Shortcut='CTRL+SHIFT+F'

post-283016-0-14521900-1381467815_thumb.

This dialog is similar to the 'Find...' dialog except it searches through all files.  Most development I do in 'Don't Starve' involves reusing and extending existing scripts, so this dialog becomes incredibly useful at finding what I'm looking for.

 

And that's it!  These are just a few of Sublime's features.  It has many others and a huge plugin development community.  If you do give it a try or if you have a different favorite ide, let me know.  I'm always looking for ways to write code faster/smater/better :-).

 

For more Sublime tutorials, check out Perfect Workflow in Sublime Text 2.
Link to comment
Share on other sites

  • Developer

This is pretty cool unfortunately sublime does cost some money after a bit.

 

I would suggest using notepad++ and windows grep as an alternative its not quite as easy but they work.

I bought a copy for my own use but I thought the trial was infinite, it just started nagging you after a while.  This is what it says on the website:

 

"There is currently no enforced time limit for the evaluation."

Link to comment
Share on other sites

I bought a copy for my own use but I thought the trial was infinite, it just started nagging you after a while.  This is what it says on the website:

 

"There is currently no enforced time limit for the evaluation."

 

Interesting, I might try it I just don't want to get hooked on something I can't afford.

Link to comment
Share on other sites

Yep, trial doesn't end. And the occasional nagging is totally worth it for all the features you get.

I especially like the design which is so much more comfortable than any other editor I ever used. And I also like using "Ctrl"

+"LMB" to put a cursor multiple places in the code and type at each place at the same time.

So I can absolutely approve Cheerios post, get this program... now!

Link to comment
Share on other sites

Yea, I'm not understanding this. I've been trying to learn lua and it's confounding me. I thought this editor might help some by being able to see the sidebar and searching for things, etc. But I'm stuck just on the project file provided. I open it. It's just some paths, and I have nothing in my sidebar except that project file. What should I be doing to get everything to show up as shown in the tutorial? I'm on windows 7 x64

 

EDIT: Well I thought I figured out what I did wrong. I think I need to open this as a project and not a file. When I did, I had directories for mods and data/scripts in my sidebar, but they don't contain anything. Learning to code sure makes a semi-intelligent guy feel like a complete moron. What am I doing wrong?

Link to comment
Share on other sites

Yea, I'm not understanding this. I've been trying to learn lua and it's confounding me. I thought this editor might help some by being able to see the sidebar and searching for things, etc. But I'm stuck just on the project file provided. I open it. It's just some paths, and I have nothing in my sidebar except that project file. What should I be doing to get everything to show up as shown in the tutorial? I'm on windows 7 x64

 

EDIT: Well I thought I figured out what I did wrong. I think I need to open this as a project and not a file. When I did, I had directories for mods and data/scripts in my sidebar, but they don't contain anything. Learning to code sure makes a semi-intelligent guy feel like a complete moron. What am I doing wrong?

Where did you put the dont_starve.sublime-project file? It has to be inside dont_starve/mods, as the paths are relative.
Link to comment
Share on other sites

I had the same problem (relative paths did not work). Easiest solution I've found is to remove the folders in there, then go to Project>AddFolder and select your mods, scripts, DLC folder. This will place them in the project with the files like the tutorial has, allowing you to search through files, etc

Link to comment
Share on other sites

Yep. It's in there. Here's a screenshot of my mods folder, and one of what I get when I open Sublime with the folders in side bar expanded.

The dont_starve.sublime-project file itself needs to be directly inside the mods folder. You have it as dont_stave/mods/dont_starve_sublime_project/dont_starve.sublime-project when it should be dont_stave/mods/dont_stave.sublime-project.

But, as ProfFarnsworth said, it's really easy to recreate what the .sublime-project file does. I usually just drag & drop folders into the Sublime sidebar.

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...