n = nLineDefsSelected
if NotEqual("n,1")
       show "You must select select one linedef."
       abort
endif

Input ( width, "Width?", 32 )
Input ( kind, "0=metal; 1=silver", 0 )

If Equal("kind,0")
	t1 = "METAL"
	t2 = "CEIL5_2"
Else           
	t1 = "SHAWN2"
	t2 = "FLAT23"
Endif

; *** Get the selected linedef
GetSelectedLineDef n
GetLineDefProperty MAPANGLE, n, Angle
GetLineDefProperty sec, n, FrontSector

; *** Split it in three with middle length specified width
SplitLineDef3 n, width                          
; *** Delete middle piece
DeleteLineDef nLineDefs - 1
LD1 = nLineDefs

GetVertexProperty x1, nVertex - 1, X
GetVertexProperty y1, nVertex - 1, Y
MoveTo x1, y1

DuplicateSector sec
GetSectorProperty ch, nSectors, CeilingHeight
SetSectorProperty nSectors, CeilingHeight, ch - width
SetSectorProperty nSectors, CeilingTexture, t2

LineDefFlags = 0
LineDefFrontSector = sec
LineDefFrontMainTexture = t1
Move width
Left
LineDefFrontSector = nSectors
LineDefFlags = LF_LOWERUNPEGGED
Move width
Left
LineDefFrontSector = sec
LineDefFlags = 0
Move width

TurnAround
Up
Move width
Right
Move width
Left
Down

LineDefFlags = LF_TWOSIDED + LF_UPPERUNPEGGED
LineDefFrontSector = sec
LineDefBackSector = nSectors     
LineDefFrontAboveTexture = t1
LineDefFrontMainTexture = "-"

Move width
Left
Move width
Left
Move width
