Profile
| Name: |
Scaffolding V1.0 |
| ID: |
8457 |
| Created on: |
Mon, 08/16/2010 - 10:56 |
| Updated on: |
Mon, 08/16/2010 - 17:56 |
| Description: |
Script request by Mat747.
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.
| |
| | |
| | |
|
-- Scaffolding by Crashguard303
-- Script request by Mat747
-- Applies bands between segments,
-- if their distance is inbetween an user-specified range,
-- resulting a relative position lock of these segments (scaffolding).
-- This example creates bands between all segments, which have have a distance from 9 to 11.
-- NOTE:
-- At the moment, FoldIt doesn't allow us to set band lengths greater than 20.
-- We can't apply bands between adjacent segments, so these are skipped
function Scaffolding(MinDist,MaxDist,DeleteAllBands,Strength)
local MinDist=MinDist
local MaxDist=MaxDist
local DeleteAllBands=DeleteAllBands
local Strength=Strength
local k
local l
local NumSegs=get_segment_count()
if MinDist<1 then MinDist=1 end -- if value is smaller than 1, set it to 1
if MinDist>20 then MinDist=20 end -- if value is bigger than 20, set it to 20
if MaxDist<1 then MaxDist=1 end
if MaxDist>20 then MaxDist=20 end
if MinDist>MaxDist then MinDist,MaxDist=MaxDist,MinDist end
-- If Min>Max, swapt them becasue it wouldn't make sense
if DeleteAllBands then
while get_band_count()>0 do
band_delete(get_band_count())
end -- while
end -- if
print("Connecting segments with distance ",MinDist,"-",MaxDist,"...")
local Finish=NumSegs-1
for k=1,Finish do
local Start=k+1
for l=Start, NumSegs do
if (l-k)>1 then -- check that there is at least 1 segment between
local Distance=get_segment_distance(k,l) -- get distance
if Distance>=MinDist then -- above or equal minimum?
if Distance<=MaxDist then -- below or equal maximum?
print("Connected ",k,":",l," distance:",Distance) -- show
band_add_segment_segment(k,l) -- connect
local TempBandCount=get_band_count() -- get new band amount
band_set_length(TempBandCount,Distance)
band_set_strength(TempBandCount,Strength)
end -- if Distance
end -- if Distance
end -- if l-k
end -- l loop
end -- k loop
end -- function
-- CHANGE PARAMETERS HERE:
MinDist=9 -- Minimum segment distance to band, float value
MaxDist=11 -- Maximum segment distance to band, float value
DeleteAllBands=true -- boolean value
-- If true, all existing bands are deleted before script is executed.
-- If false, previous bands are kept, however.
Strength=1 -- Band strength of the scaffold
-- I forgot minimum and maximum value.
-- Please look for yourself :p
Scaffolding(MinDist,MaxDist,DeleteAllBands,Strength) -- Call script with these parameters