maandag 10 november 2014



global BaseNr
global MyColor
global WingSym

rollout unnamedRollout "" width:411 height:637
(
    label lbl1 "Random Spaceship Generator" pos:[10,11] width:300 height:30
    spinner spn1 "Number of baseparts " pos:[38,67] width:325 height:16
    colorPicker cp1 "Color Picker" pos:[227,93] width:135 height:52
    groupBox grp3 "Base Parameters" pos:[10,50] width:382 height:104
    groupBox grp4 "Base Parameters" pos:[10,175] width:382 height:144
    editText edt2 "Number of engines " pos:[34,201] width:324 height:20
    editText edt3 "Number of wings " pos:[35,235] width:324 height:20
    editText edt4 "Number of tails " pos:[35,269] width:324 height:20
    checkbox chk1 "Wing Symmetry" pos:[34,294] width:226 height:18
    spinner spn2 "Amount of ships " pos:[135,360] width:125 height:16
    groupBox grp6 "Name of parts" pos:[12,340] width:E380 height:276
    button btn1 "Create ship(s) !" pos:[26,473] width:347 height:119
  
    on spn1 changed TempBaseNr do
        BaseNr = TempBaseNr
    on spn1 changed TempColor do
        MyColor = TempColor
    on EditEngineNm changed TxtEngine do
        EngineNm = TxtEngine
    on EditWingNm changed TxtWing do
)

createDialog unnamedRollout

fn GenerateShips =
(
while iCount <= ShipNr do
(
    engineNm = "Box"
    engineNr = (Random 1 BaseNr) as string
    OrgEngine = Execute ("$"+engineNm+"00"+engineNr)
    EngineCopy = copy OrgEngine
    EngineCopy.pos = [(random -70 70),0,0]
    EngineCopy.wirecolor = MyColor
    EngineCopy.Name = "Engine"+(iCount as String)

    WingLNm = "Sphere"
    WingLNr = (Random 1 BaseNr) as string
    OrgWingL = Execute ("$"+WingLNm+"00"+WingLNr)
    WingLCopy = copy OrgWingL
    WingLCopy.pos = EngineCopy.pos
    WingLCopy.wirecolor = MyColor
    WingLCopy.Name = "WingL"+(iCount as String)

    move WingLCopy [10,5,5]
  
    WingRNm = WingNm+"R"
    if WingSym = = true
    then WingRNr - WingLNr
    else WingRNr = (Random 1 BaseNr) as string

    WingRNm = "Sphere"
    WingRNr = (Random 1 BaseNr) as string
    OrgWingR = Execute ("$"+WingRNm+"00"+WingRNr)
    WingRCopy = copy OrgWingR
    WingRCopy.pos = EngineCopy.pos
    WingRCopy.wirecolor = MyColor
    WingRCopy.Name = "WingR"+(iCount as String)

    move WingRCopy [-10,5,5]

    TailNm = "Cylinder"
    TailNr = (Random 1 BaseNr) as string
    OrgTail = Execute ("$"+TailNm+"00"+TailNr)
    TailCopy = copy OrgTail
    TailCopy.pos = EngineCopy.pos
    TailCopy.wirecolor = MyColor
    TailCopy.Name = "Tail"+(iCount as String)
  
    iCount += 1
)
)