Lua Feature Priorities

Started by Tlaloc

Tlaloc Lv 1

In the message when foldit starts, it says that the development team is working on lua features. What can we be expecting?

If I had a preference, the first thing I'd want is the ability to easily use an external editor on lua scripts. You guys need to get out of the editor business, because you will never have the resources to do it right. The lua scripts would be in a particular directory on the hard drive with a .lua extension. I should press a button in the UI and edit the script which would fire up whatever was configured as the default editor for .lua files, either in the operating system or a field in the options dialog. When a change was made to the file and saved, the next invocation of the script would use the change.

Next, I want a reimplementation of the get_aa() function. My scripts need this right now.

The next thing would be addition of some of the lua standard library. I started a wiki page http://foldit.wikia.com/wiki/Lua_Standard_Libraries talking about what features I'd like from the library. I have been going over the lua documentation and trying to find which features would be safe to implement, without turning foldit into a virus engine. This page is a work in progress as I get a better understanding of the lua features. The package features probably do need to be implemented, but restricted in some way.

The next thing would be ability to have scripts call other scripts, talked about in the feedback I started here: https://fold.it/portal/node/987800

Then some of the other functions talked about on the wiki page I created here: http://foldit.wikia.com/wiki/Lua_Functions_That_Should_Be_Implemented

This would make working with scripting much more satisfying and powerful, resulting in better scores by the players. I now have a reasonable understanding of lua as a programming language, and I have been surprised at how much I like it considering that I generally hate loosely typed languages. It's small, powerful, and elegant, but many of the power comes from functions in the standard libraries that we don't currently have access to.

Finally, we need some better documentation of the foldit lua functions that are available. Like I still can't figure out how the do_local_rebuild() is supposed to work, and I don't know what the various first argument to get_segment_score_part mean (e.g. what does 'Reference' and 'Other' mean?).

Players: Do you think these are the right priorities, and what other features do you want?

Tlaloc Lv 1

At the same level as the get_aa() function (i.e. second on my list), I want a function that returns the score of the save in the 'Save Recent Best' slot. Something like get_recent_best_score().

dimension9 Lv 1

External Editor Option: - DEFINITELY!!!
Standard LUA Libraries: - esp math and table object - YES please.
Meta-Scripts: - I've been wanting this for a long while - Great Idea!
"LUA Functions that should be implemented": An amazingly complete compilation of most everything I've seen discussed in chat at various times, plus some great thoughts that I've never yet heard mention of. A "must-read" article for all the developers!
…and finally, "Better Documentation." I stand and applaud for this one!

Will add more ideas to this thread as they occur to me.

Hat's off to you Tlaloc, for so competently and thoroughly initiating this much needed and long overdue discussion. Hope everyone joins in upping this thread

Crashguard303 Lv 1

I second what dimension9 said.

Tlaloc, good idea with get_recent_best_score().
This will shrink the script-codes a bit, as we normally have to store the scores "manually".
Maybe a similar function for the save-slots would also help.

Cartoon Villain Lv 1

Thank you Tlaloc, the 2 wiki pages are great.

If the editor function is too much work for now, how about upload and download script script buttons. Even that would be a help.

I would also like the ability to have more than one recent best. So I could set a recent best at the start of script that would be a stand-in for the global best and then at least one more that i can use in the normal way. This would help me explore different structures with the scripts.

Crashguard303 Lv 1

@cartoon Villain:
Maybe I've got you wrong, but there are already 9 quicksave slots, which behave recent best.
Most scripts use only the first ones, so if you use number 9, you will be on the safe side.

Tlaloc Lv 1

There are actually 10 quicksave slots. The first three can be manipulated from the UI.

It is less important to be able to retrieve the score of a quicksave slot, since you have to write the code to store something in the quicksave, you can store the score just before you do into a variable.

But with the Recent Best, if you do a wiggle or a rebuild, foldit fills the recent best automatically. If you do a wiggle function, the score may improve, which causes a recent best to be stored, then drop again before the function returns. So there is currently no way to reliably know what the score is in the recent best without storing the current position to a quicksave slot, retrieving the recent best, getting the score, then restoring the quicksave. This is slow and causes the UI to flash.

I'm sure that foldit has that score being stored somewhere for their internal use, so they just need to give us a function to retrieve it. I'm sure it would be just a few lines of code for them to implement it, and very useful. As Crashguard says, this will reduce the size of our scripts.

Crashguard303 Lv 1

"But with the Recent Best, if you do a wiggle or a rebuild, foldit fills the recent best automatically. If you do a wiggle function, the score may improve, which causes a recent best to be stored, then drop again before the function returns."

You mean VERY best, not recent best, or?

"So there is currently no way to reliably know what the score is in the recent best without storing the current position to a quicksave slot, retrieving the recent best, getting the score, then restoring the quicksave. This is slow and causes the UI to flash."

Yes, using score watching, my scripts also cause this behaviour.
This is why I asked for a score threshold which ends shake/wiggle automatically by the "game engine".

Crashguard303 Lv 1

…the very first thing to change is making the get_score_command() returning scores below 0, so recipes can easily be run after threading or rebuild, without this slow pseudo-sum thingy:
http://fold.it/portal/node/987811

I don't know how the variables are handled in the game code, but it shouldn't be a big thing to make in contrast to other features, and in second, make the get_aa() function work again.

Cartoon Villain Lv 1

Tlaloc's analysis is dead on.

Is the multiple recent best the most important function to implement? No, but it should be trivial to implement and it would help, at least me, a fair bit. Right now my best scripts can only really work from the absolute best, I want to expand on that.

Priorities for me:
1) Editor
2) Math functions
3) freeze functions
4) others listed by Tlaloc et al (some where in there the multiple recent best)