Profile
Name: |
AfterAlignment V1.2 |
ID: |
2949 |
Created on: |
Mon, 06/21/2010 - 11:28 |
Updated on: |
Mon, 06/21/2010 - 18:28 |
Description: |
Coffee time!
This script simply does what many of us do after Alignment or rebuild. It does a shake, wiggle backbone, w-sidechains, w-all, but uses a threshold value to end those tools automatically.
I didn't want to reinvent the wheel, so this script is rather for non-experienced lua-scripters to show how score-watching is performed, also how to get score values below 0.
I hope this script will not be needed in future. See discussions and script for details. |
Best For
Comments
|
| | |
|
Want to try?
Add to Cookbook!
To download recipes to your cookbook, you need to have the game client running.
| |
| | |
| | |
|
-- AfterAlignment V1.x by Crashguard303
-- Useful after Alignment or rebuild.
-- Does automatic score-conditional shake, wiggle backbone, sidechains, all
function xtool(method,MaxPasses,threshold,NumSegs)
-- unifies score-conditional shake and wiggle into one function
OS="Method:"..method.." threshold:"..threshold.." maximum passes:"
if MaxPasses>0 then
OS=OS..MaxPasses
else
OS=OS.."None"
end -- if MaxPasses
print(OS)
current_pass=0
exit_condition=false
repeat
current_pass=current_pass+1
print("Pass #",current_pass)
tempScore=xscore(NumSegs)
if method=="S" then -- check which method is to use
do_shake(1)
elseif method=="WB" then
do_global_wiggle_backbone(1)
elseif method=="WS" then
do_global_wiggle_sidechains(1)
else
do_global_wiggle_all(1)
end -- if method
delta_abs=absolute_value(xscore(NumSegs)-tempScore) -- calculate absolute value of score difference before and after method
print("Delta: ",delta_abs)
if (MaxPasses>0) and (current_pass==MaxPasses) then exit_condition=true end
-- is maximum passes reached?
-- only if MaxPasses>0
if delta_abs
until exit_condition==true
end -- function
function xscore(NumSegs)
-- if puzzle score gotten by the regular function is 0,
-- it creates a pesudo-sum by adding all segment scores as reference
-- hopefully this function won't be needed in future game updates, as soon as get_score() returns values below 0
temp=get_score()
if temp==0 then
for k=1,NumSegs do
temp=temp+get_segment_score(k)
end -- k
end -- if
return temp
end -- function
function absolute_value(absolute_input) -- returns absolute value
absolute_input2=absolute_input
if (absolute_input2 < 0) then
absolute_input2=(absolute_input2*(-1))
end -- if
return absolute_input2
end
-- Use:
-- function xtool(method,MaxPasses,threshold,NumSegs)
-- method: what to do
-- "S": shake
-- "WB": wiggle backbone
-- "WS": wiggle sidechains
-- everything other: wiggle all
-- MaxPasses: iterations
-- if 0, Method is ended if score change is below threshold
-- >0, Method is also ended if score change is below threshold, but also if number of Passes is reached.
-- threshold: absolute score difference threshold value.
-- if abs(score change) is below this value, method is not repeated anymore.
-- NumSegs: number of segments in Puzzle
select_all()
xtool("S",0,1e-3,get_segment_count())
xtool("WB",24,1e-3,get_segment_count())
xtool("WS",24,1e-3,get_segment_count())
xtool("WA",24,1e-3,get_segment_count())