Icon representing a recipe

Recipe: Band Strength 1.0

created by LociOiling

Profile


Name
Band Strength 1.0
ID
102607
Shared with
Public
Parent
Band Utility
Children
Created on
January 28, 2018 at 21:55 PM UTC
Updated on
January 28, 2018 at 21:55 PM UTC
Description

Set strength for all bands to a specific numeric value. Does not use a slider. Strength must be >= 0 and <= 10. Scientific notation allowed, for example 1.2E-1 is 0.12.

Best for


Code


-- -- Band Strength -- -- Based on Banding Utility by Ronin-Sensei -- -- Sets the strength of all bands to the indicated value -- -- 1.0 - LociOiling - 2018/01/28 -- local strength = 1.0 local rc = 0 local good = false local errmsg = "" local bc = band.GetCount () local dlg = dialog.CreateDialog ( "Band Strength 1.0" ) repeat if bc > 0 then dlg.strength = dialog.AddTextbox ( "Band Strength", tostring ( strength ) ) else errmsg = "ERROR: no bands found" end if errmsg:len () > 0 then dlg.errmsg = dialog.AddLabel ( errmsg ) end if bc > 0 then dlg.ok = dialog.AddButton ( "OK", 1 ) end dlg.cancel = dialog.AddButton ( "Cancel", 2 ) rc = dialog.Show(dlg) if rc == 1 then strength = tonumber ( dlg.strength.value ) if strength ~= nil then if strength >= 0 and strength <= 10 then good = true else errmsg = "ERROR: invalid band strength, must be between 0 and 10" end else strength = dlg.strength.value errmsg = "ERROR: non-numeric strength" end else good = true -- cancel end until good if rc == 1 then for ii = 1, bc do band.SetStrength ( ii, strength) end print ( "changed strength of " .. bc .. " bands to " .. strength ) end

Comments


LociOiling Lv 1

Band Strength sets the strength of all bands to the value you specify.

Band Strength allows you to enter an exact value, which is difficult using the sliders found in the Set Strength dialog or other Foldit recipes.

The strength value must be between 0 and 10.

Scientific notation is accepted. For example 1.2E-1 translates as "1.2 time 10 to the minus 1 power", or 0.12.

Band Strength is also an example of how to check user input for errors and provide an error message.