Icon representing a recipe

Recipe: The Hedgehog 1.0

created by isaksson

Profile


Name
The Hedgehog 1.0
ID
101235
Shared with
Public
Parent
None
Children
None
Created on
July 14, 2015 at 14:24 PM UTC
Updated on
July 14, 2015 at 14:24 PM UTC
Description

The Hedgehog 1.0 by isaksson

Best for


Code


--[[ isaksson, The Hedgehog, LUA V2 Description: This script creates 6 bands perpendicular toward each other with each segment as the origo. a) If option is checked, each freezed segment will get 6 perpendicular bands toward each other. This option should be used if some "holding" positions are required. b) If option is unchecked, each non freezed segment will get 6 perpendicular bands toward each other. By selecting each segment by freezing them, they will not have bands. Now that segmentation part that is not selected could be stretched at any direction manually and the rest of the structure stains in place. Why the name "The Hedgehog"? Isn't that obvious!!! ]]-- version = "1.0" segCnt = structure.GetCount() band_on_freeze_segment_flag = 0 rho = 3 pos_theta = {0,math.pi/2,math.pi/2,math.pi/2,math.pi/2,math.pi} pos_phi = {0,0,math.pi/2,math.pi,(math.pi/2)*3,0} math.randomseed(os.time()) math.random() -- Has to be use once, otherwise the random number doesn't produce any correct random number print("The Hedgehog ".." "..version) print("") print("Freeze each segment ...") print("... if checked ...") print("each freezed segment will get 6 perpendicular bands toward each other.") print("... if unchecked ...") print("each non freezed segment will get 6 perpendicular bands toward each other.") print("") function showConfigDialog() local ask = dialog.CreateDialog("The Hedgehog ".." "..version) ask.band_on_freeze_segment = dialog.AddCheckbox("Bands on freezed segment",band_on_freeze_segment_flag) ask.a0 = dialog.AddButton("Cancel",0) ask.a1 = dialog.AddButton("Ok",1) local result = dialog.Show(ask) if result == 0 then cleanup() end band_on_freeze_segment_flag=ask.band_on_freeze_segment.value end function main () showConfigDialog() behavior.SetClashImportance(1.0) if band_on_freeze_segment_flag then for i = 1 , segCnt-1 , 1 do if freeze.IsFrozen(i) then setbands(i) else end end else for i = 1 , segCnt-1 , 1 do if freeze.IsFrozen(i) then else setbands(i) end end end print("Number of bands:"..band.GetCount()) freeze.UnfreezeAll() end function setbands(i) j = math.random(segCnt) k = math.random(segCnt) while (i == j) or (i == k) or (j == k) do j = math.random(segCnt) k = math.random(segCnt) end for idx = 1, #pos_theta, 1 do theta = pos_theta[idx] phi = pos_phi[idx] band.Add(i,j,k,rho, theta, phi) index = band.GetCount() strength = band.GetGoalLength(index) band.SetStrength(index,strength) end end function cleanup() print("Clean up!") freeze.UnfreezeAll() band.DeleteAll() end -- main call xpcall ( main, cleanup ) --end of script

Comments


isaksson Lv 1

The Hedgehog v1.0

This script creates 6 bands perpendicular toward each other with each segment as the origo. This will hold a segment in place if bands is applied. The rest of the segments could be moved.

Regards

Isaksson