SHARE
TWEET

CG303 Keep Distance V1.00

Crashguard303 May 21st, 2012 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2. Keep Distance by Crashguard303
  3. This script simply applies a band between two numerical entered segments.
  4. By default, this band has the same length than the segments' spatial distance.
  5. You can apply a factor to the measured distance if you want to do distance compression or expansion.
  6. ]]--
  7.  
  8. local NumSegs=structure.GetCount()
  9.  
  10. local ask = dialog.CreateDialog("Keep Distance")
  11. ask.which = dialog.AddLabel("Which segments should be banded?")
  12. ask.SegA = dialog.AddTextbox("Segment A:", 1)
  13. ask.SegB = dialog.AddTextbox("Segment B:", NumSegs)
  14. ask.Strength = dialog.AddSlider("Band strength:", 1, 0.0, 10.0, 1)
  15. ask.Factor = dialog.AddSlider("Band factor:", 1, 0.0, 10.0, 1)
  16.  
  17. ask.OK = dialog.AddButton("OK", 1)
  18. ask.Cancel = dialog.AddButton("Cancel", 0)
  19.  
  20. if dialog.Show(ask)>0 then -- If OK was pressed
  21.  
  22.   local SegA=tonumber(ask.SegA.value)
  23.   local SegB=tonumber(ask.SegB.value)
  24.  
  25.   if SegA<1 then SegA=1 end
  26.   if SegB<1 then SegB=1 end
  27.   if SegA>NumSegs then SegA=NumSegs end
  28.   if SegB>NumSegs then SegB=NumSegs end
  29.  
  30.   local OS="Adding band beween segments: "..SegA..":"..SegB
  31.   print(OS)
  32.   band.AddBetweenSegments(SegA,SegB)
  33.   local band_index=band.GetCount()
  34.  
  35.   local OS="Strength: "..ask.Strength.value
  36.   print(OS)
  37.   band.SetStrength(band_index,ask.Strength.value)
  38.  
  39.   local Distance=structure.GetDistance(SegA,SegB)
  40.   local Length=Distance*ask.Factor.value
  41.   local OS="Distance: "..Distance.." factor: "..ask.Factor.value
  42.   print(OS)
  43.   local OS="Resulting length: "..Length
  44.   print(OS)
  45.   band.SetGoalLength(band_index,Length)
  46.  
  47.  
  48.  else  -- If OK was not pressed
  49.   print("Canceled.")
  50. end -- if dialog.Show(ask)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top