Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Keep Distance by Crashguard303
- This script simply applies a band between two numerical entered segments.
- By default, this band has the same length than the segments' spatial distance.
- You can apply a factor to the measured distance if you want to do distance compression or expansion.
- ]]--
- local NumSegs=structure.GetCount()
- local ask = dialog.CreateDialog("Keep Distance")
- ask.which = dialog.AddLabel("Which segments should be banded?")
- ask.SegA = dialog.AddTextbox("Segment A:", 1)
- ask.SegB = dialog.AddTextbox("Segment B:", NumSegs)
- ask.Strength = dialog.AddSlider("Band strength:", 1, 0.0, 10.0, 1)
- ask.Factor = dialog.AddSlider("Band factor:", 1, 0.0, 10.0, 1)
- ask.OK = dialog.AddButton("OK", 1)
- ask.Cancel = dialog.AddButton("Cancel", 0)
- if dialog.Show(ask)>0 then -- If OK was pressed
- local SegA=tonumber(ask.SegA.value)
- local SegB=tonumber(ask.SegB.value)
- if SegA<1 then SegA=1 end
- if SegB<1 then SegB=1 end
- if SegA>NumSegs then SegA=NumSegs end
- if SegB>NumSegs then SegB=NumSegs end
- local OS="Adding band beween segments: "..SegA..":"..SegB
- print(OS)
- band.AddBetweenSegments(SegA,SegB)
- local band_index=band.GetCount()
- local OS="Strength: "..ask.Strength.value
- print(OS)
- band.SetStrength(band_index,ask.Strength.value)
- local Distance=structure.GetDistance(SegA,SegB)
- local Length=Distance*ask.Factor.value
- local OS="Distance: "..Distance.." factor: "..ask.Factor.value
- print(OS)
- local OS="Resulting length: "..Length
- print(OS)
- band.SetGoalLength(band_index,Length)
- else -- If OK was not pressed
- print("Canceled.")
- end -- if dialog.Show(ask)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement