Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Score Part all by Crashguard303
- This script calculates for each selected score part (score criteria) its score sum of all segments
- and their overall sum
- ]]--
- function DialogCheck()
- -- create dialog containing checkboxes with names as in ScorePartNames
- local ask -- initialize table ask for dialog display and storing chekbox values
- ask = dialog.CreateDialog("Get all score parts") -- windows title
- ask.which = dialog.AddLabel("Calculate which score part segment sums?") -- information
- local k
- for k=1,#ScorePartNames do -- by variable k, cycle through all score part names
- ask[ScorePartNames[k]] = dialog.AddCheckbox(ScorePartNames[k], false)
- -- for each name, create a checkbox with this variable-name and show it as text
- -- default value for checkbox is false
- end -- k loop
- ask.OK = dialog.AddButton("OK", 1) -- add OK button returning 1 in function if pressed
- ask.Cancel = dialog.AddButton("Cancel", 0) -- add cancel button retunrning 0 in function if pressed
- return ask,dialog.Show(ask) -- return what is in table ask (containing which score parts (by names) have been selected) and flag for OK button
- end -- function
- function ShowScores(ask)
- -- for all segments, calculate all score parts selected in ask and show them
- local ScoreAll=0 -- initialize variable for sum of all score-part-segment-sums
- local k
- for k=1,#ScorePartNames do -- by variable k, cycle through all score part names
- if ask[ScorePartNames[k]].value then -- if this score part name was checked in table ask (ask.ScorePartNames[k].value = true)
- -- same as if ask[ScorePartNames[k]]["value"]
- local ScorePart=0 -- initialize variable for score-part-segment-sum
- local l
- for l=1,NumSegs do -- by variable k, cycle through all segments
- ScorePart=ScorePart+absolutebest.GetSegmentEnergySubscore(l,ScorePartNames[k])
- -- add score part with name ScorePartNames[k] at segment l to score-part-segment-sum
- end -- l loop
- ScoreAll=ScoreAll+ScorePart -- when all single segment-scores of one score criteria have been added, add this score-part-segment-sum value to overall sum, too
- local OS=ScorePartNames[k]..": "..ScorePart -- show current score-part name and segment sum
- print (OS)
- end -- if ask
- end -- k loop
- local OS="sum of all: "..ScoreAll -- when all score-part-segment-sums have been shown, show overall sum
- print (OS)
- return ScoreAll -- return this value as function value
- end -- function
- NumSegs=structure.GetCount() -- set variable NumSegs to number of all puzzle segments fetched by function
- ScorePartNames={"clashing";"packing";"hiding";"bonding";"backbone";"sidechain";"reference";"disulfides";"other"}
- -- initialize table containing all score part criteria by name
- ScoreCheck={} -- initialize table containing information which score criteria should be checked, calculated and displayed
- local OKFlag -- initialize flag containing information if OK was pressed in score criteria selection dialog
- ScoreCheck,OKFlag=DialogCheck() -- set ScoreCheck and OKFlag by calling score criteria selection dialog containing checkboxes with names as in ScorePartNames
- if OKFlag>0 then -- if OK was pressed
- ShowScores(ScoreCheck) -- by content of ScoreCheck, calculate scores and show them
- end -- if OKFlag
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement