External editor for LUA Scripting

Case number:845813-986980
Topic:Game: Tools
Opened by:egon
Opened on:Monday, November 2, 2009 - 23:29
Last modified:Monday, August 22, 2011 - 21:40

Until the editor is not totally complete - cut & copy & paste, select, syntax highlighting, it would be nice to be able to use an external editor. (For example notepad++ or something similar.)

Here's one way to do it easily.

There's a folder X that FoldIt can access.
In that folder you have .lua scripts.

By clicking a button in FoldIt or (it does it automatically),
it loads all those scripts into your cookbook.
Also it adds as first line "--external". So it can later delete
them when it reloads scripts from folder X.

The second way:
You get a list of scripts in that folder X and you can
run them directly (that means does not load into cookbook) and
every time you run it, it loads the script from folder X.

(Mon, 11/02/2009 - 23:29  |  25 comments)

Joined: 09/18/2009
Groups: SETI.Germany

I would also like to do it this way.
The marquis and me do it mostly this way, that we write our recipe in an normal text editor and then paste the text into the lua script editor by pressing Ctrl-V.
Getting scripts out of Foldit is not that comfortable, but we've found our way.

@Egon: If you want to know how to get scripts out of foldit, let me know.

Joined: 04/13/2009
Groups: Contenders

Gneutral told me that pasting is broken in linux foldit -- that should be addressed.

Using control-v in windows foldit works, but there are some garbage chars that get pasted in. One looks like a little envelope and I think is a carriage return symbol. Scripts run fine with these "envelope" chars, but I've heard that when writing scripts on some non-English keyboards(?) other garbage chars get pulled in.

Of course, we can't cut from foldit -- you have to use crashguard's method of extracting the script text from the macro files. But that's a bit of a pain.

With all the issues with cutting and pasting (and no "save as"), I'm using an external text editor to store "master" versions of scripts. I paste in and run a script and then if it doesn't work right, I edit in the external editor, close the script in foldit, open a new blank one, paste in the edited script, and over and over and over ... till I get it how I want and actually save it ... it's a lot of work!!!

I like Egon's idea of a lua script folder. Most folks who do any serious scripting will probably want to use an external editor anyway (even if foldit's internal editor gets a lot better!) And it is simple enough for casual scripters, too.

Joined: 09/18/2009
Groups: SETI.Germany

I've made a new "discovery"!
Before you paste a recipe into foldit, you can replace all HEX 0D0A-Values by only 0A, that's enough for Foldit and the strange Xs will vanish.

For all who want to know:
0A in HEX means Carriange return
0D in HEX means Line-feed.

Foldit only needs 0A, Texteditors need both to give a readable content.

"I like Egon's idea of a lua script folder. Most folks who do any serious scripting will probably want to use an external editor anyway (even if foldit's internal editor gets a lot better!) And it is simple enough for casual scripters, too."

... and it's faster, independent and you can keep Foldit running your puzzles in background.

I could write a small program on Q- or Visual-BASIC for export/import, but I'll have to get some real-life-practice. In addition, automated binary access to files is a delicate thing.

But far as I've read, I could also programm an import/export-.EXE file with WINHEX.
Let me have a look.


egon's picture
User offline. Last seen 11 years 47 weeks ago. Offline
Joined: 11/01/2009
Groups: None

Alex you've got your 0A and 0D reversed.

0A is line-feed
0D is carriage return

Alex-s discovery means that they use UNIX format for newlines.

With Notepad++ it's easy to convert it - From menu [Format -> Convert to UNIX Format].
Probably some other extended editors have that feature.

Joined: 03/20/2010

scite editor has menu options to remove these characters and replace them with invisible ones

Joined: 09/18/2009
Groups: SETI.Germany

Oh, sorry.
0D in Decimal is 13, which is definetly ASCII-Code for return.
My fault :(

Notepad++? Where to get for Windows?
Well, this explains, why my Notepad(not ++) gives the best result.

Egon, you seem to have experience, do you know a free HEX-Editor which can perform search-and-exchange-macros?

egon's picture
User offline. Last seen 11 years 47 weeks ago. Offline
Joined: 11/01/2009
Groups: None

I don't use HEX editors that often so I'm not sure about that...

For notepad++

Notepad++ doesn't have built-in hex editing support but older versions have a plugins for it.

PSPad is quite nice and it has hex-editing, it can find & replace

If you want macros then learn emacs... top-down customizable and macros are it's key thing...

Non-free good ones are:
UltraEdit and TextPad

If previous ones don't suit you, try out these:

Joined: 09/18/2009
Groups: SETI.Germany

That sounds interesting.
I just tried to open a file with Notepad++, but it doesn't know, that it is unix format, and shows it as usual.
How should the file-ending be called?
Or how can I tell the program how to interprete the \\ commands?

egon's picture
User offline. Last seen 11 years 47 weeks ago. Offline
Joined: 11/01/2009
Groups: None

On status bar there's a reference what format it is. (Dos/Windows, Unix, Mac).

When you switch on all characters then you're able to see the line endings. Otherwise it would show file as usual and you won't know the difference which type of file you are editing.

Joined: 09/18/2009
Groups: SETI.Germany

Egon, you saved my day!
This is exactly what we need.
Only two steps to get a read- and insertable file!

Joined: 09/18/2009
Groups: SETI.Germany

I just made an article in the Wiki, how to do it with WORDPAD++

Joined: 09/18/2009
Groups: SETI.Germany

Egon, the curent version I loaded with plug-ins had a hex-editor, but it couldn't change three-byte-words to a one byte-word properly.

But the extended search mode is right for our needs!

With this, you can replace text by line-feed or carriage-return.

Joined: 09/18/2009
Groups: SETI.Germany

Judecca had the idea to share recipes here, as long as the server doesn't store them correctly:


My current recipe is stored here:


Joined: 09/18/2009
Groups: SETI.Germany
xedr's picture
User offline. Last seen 2 years 20 weeks ago. Offline
Joined: 05/16/2008

As of yesterday, the Ctl-v "paste" still does not work for my mac. This external macro alternative would be a godsend! Another possibility: provide a way to use the existing web interface. Write up a quick and dirty app that invokes the existing interface to load a recipe from a local folder.

Joined: 11/10/2007
Groups: Window Group

Ctrl-c, ctrl-v, and ctrl-x should all work on Windows, but not the other platforms. Cut and copy operate on the whole text box because there is no selection.

I'll look into adding a script folder as egon suggested.

Joined: 09/18/2009
Groups: SETI.Germany

That would be nice, thanks a lot!

Joined: 09/18/2009
Groups: SETI.Germany

Another idea, compatible with all OS:
Give the opportunity to view the code in the recipe section.

Doing it this way
1. You don't need to change the game
2. Copy and paste will work on all systems
3. You can directly see if the recipe was uploaded correctly (I uploaded some recipes which couldn't be loaded)
4. Parts of the code can be explained or discussed on the recipe's site.
5. The user who wants to test it has a first glimpse of the code size and what it will do.

Joined: 09/18/2009
Groups: SETI.Germany

Have you already tried the command(apple)-key instead of control?

Tlaloc's picture
User offline. Last seen 45 weeks 5 days ago. Offline
Joined: 08/04/2008
Groups: Mojo Risin'

I heartily concur with all that was said in this thread. Start by having a scripts folder with the lua files in them. I think it would be best to just punt completely on the editor, and bring up whatever editor is configured for lua files. Use notepad if there isn't anything else configured. Microsoft actually has a version of Visual Studio that has been modified to edit lua files for wow.

Joined: 09/18/2009
Groups: SETI.Germany

If there will be an external folder for scripts, it will be a good thing to also have at least one single file (maybe called "output.txt" or something like this) for saving a single output string or table, to save a list of segments which were improved (or found).
This would allow feeding the generated list into other scripts again.

Joined: 09/18/2009
Groups: SETI.Germany

For those people who have problems to get their recipes out of the game, I will help them here:

xedr's picture
User offline. Last seen 2 years 20 weeks ago. Offline
Joined: 05/16/2008

I'm thrilled that the copy feature is now working on my mac! It doesn't always work - I have to pretend that I'm selecting something before copying and then the copy command captures everything out of the editor.

And I am ecstatic that paste feature is (mostly) working!! WOOHOO!! When I copy something from TextEdit or from my Firefox browser window, I can paste it into the Foldit editor. However, when I copy something from Word or from Idle (the python IDE), the paste command does NOT work - the Foldit editor just ignores it.

So tonight I'm gonna do some real programming! Then copy from my preferred editor to TextEdit, then copy from TextEdit to Foldit, and presto! I'm in business. :)

Joined: 09/18/2009
Groups: SETI.Germany

Must have to do something with control characters, which are copied, too.
The game's editor just needs a linefeed at a line end, Word for example uses Carriage-return and Linefeed.
Maybe on Mac there is other stuff copied into the clipboard.

I gave scite a try.
Looks nice, too, but I'm used too Notepad++.
It also supports syntax highlighting for LUA, code folding and can remove control characters.

Joined: 06/17/2010
Status: Open » Closed

Duplicate to: http://fold.it/portal/node/990217


Developed by: UW Center for Game Science, UW Institute for Protein Design, Northeastern University, Vanderbilt University Meiler Lab, UC Davis
Supported by: DARPA, NSF, NIH, HHMI, Amazon, Microsoft, Adobe, Boehringer Ingelheim, RosettaCommons