Profile
Name: |
PuzzleCleaner V1.1 |
ID: |
6210 |
Created on: |
Mon, 07/26/2010 - 06:25 |
Updated on: |
Mon, 07/26/2010 - 13:25 |
Description: |
Turns small solitary helix and sheet chunks into loops to make the puzzle more flexible.
See 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.
| |
| | |
| | |
|
-- PuzzleCleaner V1.x by Crashguard303
-- Cleans puzzle of small solitary chunks of helices and sheets
-- by making loops out of them, to make the puzzle more flexible.
-- Default is a solitary helix with length of 4 (and shorter),
-- and a solitary sheet with a length of 1.
function CheckPosition(Pos,LTS,Length,NumSegs)
-- checks at position, if search structure (loop or helix, depending on string LTS)
-- is surrounded by other secondary structures and filled with search structure
Found=true -- create default value, any other circumstance will right set it to false
Pos1=Pos-1 -- first position to check (start tip, must be unequal LTS)
Pos2=Pos+Length -- last position to check (end tip, must be unequal LTS)
if Pos1>=1 then -- check only if the puzzle doesn't start with helix or sheet
if get_ss(Pos1)==LTS then Found=false end -- look if there is another SS at start tip
end -- if
if Found==true then -- we only have to do the next checks then
if Pos2<=NumSegs then -- only if the puzzle doesn't end with helix or sheet
if get_ss(Pos2)==LTS then Found=false end -- look if there is another SS at at end tip
end -- if
if Found==true then -- we only have to do the next checks then
Pos1=Pos1+1 -- adapt to exclude start tip
Pos2=Pos2-1 -- adapt to exclude end tip
exit_condition=false -- clear exit condition
k=Pos1 -- set k to first segment
repeat -- look if all pieces within are the same
if get_ss(k)~=LTS then
Found=false
exit_condition=true
end
k=k+1
if k>Pos2 then exit_condition=true end
until exit_condition==true
if Found==true then -- if solitary helix or sheet is found, replace it by loops.
deselect_all()
for k=Pos1,Pos2 do
select_index(k) -- select all including segments but not the tips
end
replace_ss("L") -- and make loops of them
print("Segment ",Pos1," to ",Pos2," cleaned.")
end -- if Found==true
end -- if Found==true
end -- if Found==true
end -- function
function PuzzleCleaner(MaxHelix,MaxSheet)
NumSegs=get_segment_count()
SSL={"H";"E"} -- Search string table. 1:Helix 2:Sheet
SLS={MaxHelix,MaxSheet}
for m=1,2 do -- 1:Helix 2:Sheet search
LTS=SSL[m] -- Letter to search
SL=SLS[m] -- Maximum length to search
if SL>=1 then -- if not, skip it
for k=SL,1,-1 do -- start with longest solitary chain and end with shortest
print("Searching for ",LTS," with length ",k,"...")
LastSeg=NumSegs-k+1
for l=1,LastSeg do -- check at all positions
-- print("Position: ",l)
CheckPosition(l,LTS,k,NumSegs)
end -- l loop
end -- k loop
end -- if SL>=1
end -- m loop
print("Finished.")
end -- function
-- USE:
-- PuzzleCleaner(MaxHelix,MaxSheet)
-- MaxHelix: Maximum length of helix chunk to wipe out
-- MaxSheet: Maximum length of Sheet chunk to wipe out
-- Use values equal or below 0 to skip
PuzzleCleaner(4,1)