Back to Recipes Homepage
recipe picture
Recipe: Longest Dist Band V2.0
4.333335
Your rating: None Average: 4.3 (6 votes)
Used 150 times with an average impact of 356 points.

Profile

Name: Longest Dist Band V2.0
ID: 2963
Created on: Thu, 06/24/2010 - 04:34
Updated on: Thu, 06/24/2010 - 11:34
Description:

Script Request from Mat747. Now with table support.



Best For


Comments

Joined: 09/18/2009
Groups: SETI.Germany
That's how the code does look like

-- Longest distance banding V1.x by Crashguard303
-- Creates a band between each selected segment (by table) and this segment, which is most far away from it.
-- Default is segment 1.
-- A script request from Mat747

function get_field_length(Field) -- checks how many entries are in a list (table)
content=1
k=0
while (content~=nil) do
k=k+1
content=Field[k]
end -- while
return (k-1)
end -- function

function band_longest_distance(Field) -- band each segment which is contained in the field to this which is most far away
NumSegs=get_segment_count() -- check how many segments are there
FL=get_field_length(Field) -- get field length
if FL==0 then -- if Field has length of 0 (Field is empty), make Field[1...NumSegs]=1..NumSegs
FL=NumSegs
for k=1,NumSegs do
Field[k]=k
end -- k
end -- if FL
for k=1, FL do
band_longest_distance2(Field[k],NumSegs)
end -- k
end -- function

function band_longest_distance2(SegA,NumSegs) -- SegA is the segment to be banded
LD=0
if SegA<=NumSegs/2 then
Pos1=NumSegs
Pos2=1
StepSize=-1
else
Pos1=1
Pos2=NumSegs
StepSize=1
end -- if SegA

OS=""
E=0
print("Distances:")
for k=Pos1,Pos2,StepSize do
if k~=SegA then
D=get_segment_distance(SegA,k)
D2=D*1000
D2=D2-D2%1
D2=D2/1000
OS=OS..SegA..":"..k.."="..D2
E=E+1
if E<3 then
OS=OS.." "
else
E=0
OS=OS.."\n"
end -- if E
if D>LD then
LD=D
SegB=k
end -- if D
end -- if k
end -- k
print(OS)
band_add_segment_segment(SegA,SegB)
print("Band added between Segment ",SegA," and ",SegB,".")
end -- function

-- change 1 to the segment numbers you want to band HERE:
-- {1} bands only segment 1
-- {1,2,3} band segment 1, 2 and 3
-- {} band all to the most far away segments
band_longest_distance({1})

Want to try?
Add to Cookbook!
To download recipes to your cookbook, you need to have the game client running.
Parent

none

Children
Authors
Sitemap

Developed by: UW Center for Game Science, UW Institute for Protein Design, Northeastern University, Vanderbilt University Meiler Lab, UC Davis
Supported by: DARPA, NSF, NIH, HHMI, Amazon, Microsoft, Adobe, RosettaCommons