Script Module

  • FeynmanLogomaker
    27th Mar 2013 Member 1 Permalink

    The script:

    function modwin()
    elemtype = 'dmnd'
    typecount = 0
    --Window
    local modWindow = Window:new(-1, -1, 300, 210)

    local currentY = 10

    --Label
    local modLabel = Label:new(10, currentY, (select(1, modWindow:size())/2)-20, 16, "*Standard Variables Module*")

    --Button: Define the Element Type
    currentY = currentY + 20
    local elemButton = Button:new(10, currentY, (select(1, modWindow:size())/2)-20, 16, "Element type")
    elemButton:enabled(false)
    elemButton:action(
    function(sender)
    elemtype = tpt.input("Element type","Something will do stuff in this element")
    sender:text(elemtype)
    end
    )

    --Button: Define the property used
    currentY = currentY + 20
    local propButton = Button:new(10, currentY, (select(1, modWindow:size())/2)-20, 16, "Property")
    propButton:enabled(false)
    propButton:action(
    function(sender)
    proptype = tpt.input("Property","Something will do stuff with this property")
    sender:text(proptype)
    end
    )

    --Button: Which script to run
    currentY = currentY + 20
    local dofileButton = Button:new(10, currentY, (select(1, modWindow:size())/2)-20, 16, "File to do")
    dofileButton:enabled(false)
    dofileButton:action(
    function(sender)
    dofilefile = tpt.input("File","It will do this file after you hit 'Done'")
    sender:text(dofilefile)
    end
    )

    --Button: If a script needs to call another file
    currentY = currentY + 20
    local secondaryFileButton = Button:new(10, currentY, (select(1, modWindow:size())/2)-20, 16, "Secondary file to do")
    secondaryFileButton:enabled(false)
    secondaryFileButton:action(
    function(sender)
    filename = tpt.input("Secondary file","The script you run might do this")
    sender:text(filename)
    end
    )
    --Checkbox: Self-obvious once you run it
    currentY = currentY + 20
    local modCheckbox = Checkbox:new(10, currentY, (select(1, modWindow:size())/2)-20, 16, "Won't run");
    modCheckbox:action(
    function(sender, checked)
    if(checked) then
    sender:text("Will run")
    willRun = 1
    propButton:enabled(true)
    elemButton:enabled(true)
    dofileButton:enabled(true)
    secondaryFileButton:enabled(true)
    else
    sender:text("Won't run")
    willRun = 0
    propButton:enabled(false)
    elemButton:enabled(false)
    dofileButton:enabled(false)
    secondaryFileButton:enabled(false)
    end
    propButton:enabled(checked);
    end
    )



    --Progress bar
    currentY = currentY + 20
    local modProgressBar = ProgressBar:new(10, currentY, (select(1, modWindow:size())/2)-20, 16, 0, "Scale: 0");

    -- slider: Scale of something
    currentY = currentY + 20
    local modSlider = Slider:new(10, currentY, (select(1, modWindow:size())/2)-20, 16, 10);
    modSlider:onValueChanged(
    function(sender, value)
    modProgressBar:progress(value * 10)
    modProgressBar:status("Scale: " .. (value / 10) + 1)
    scale = (value / 10) + 1
    end
    )

    --Close button: Finished
    local closeButton = Button:new(10, select(2, modWindow:size())-43, 100, 16, "Done")

    closeButton:action(function() interface.closeWindow(modWindow) end)


    modWindow:onTryExit(function() interface.closeWindow(modWindow) end) -- Allow the default exit events
    modWindow:onMouseMove(
    function(x, y, dx, dy)
    --modLabel:text("*Standard Variables Module*")
    end
    )

    --Dofile button: Run the relevant script
    local otherDofileButton = Button:new(10, select(2, modWindow:size())-26, 100, 16, "Do file")

    otherDofileButton:action(
    function(sender)
    dofile(dofilefile)
    sender:text("Done")
    end
    )

    modWindow:onMouseMove(
    function(x, y, dx, dy)
    --modLabel:text("*Standard Variables Module*")
    end
    )

    -- Pointless button
    local yetAnotherDofileButton = Button:new(111, select(2, modWindow:size())-26, 135, 16, "Pointless button!")

    modWindow:onMouseMove(
    function(x, y, dx, dy)
    --modLabel:text("*Standard Variables Module*")
    end
    )

    modWindow:addComponent(modLabel)
    modWindow:addComponent(elemButton)
    modWindow:addComponent(propButton)
    modWindow:addComponent(dofileButton)
    modWindow:addComponent(secondaryFileButton)
    --modWindow:addComponent(modTextboxNotWorkingYey)
    modWindow:addComponent(modCheckbox)
    modWindow:addComponent(modProgressBar)
    modWindow:addComponent(modSlider)
    --modWindow:addComponent(textboxInfo)
    modWindow:addComponent(closeButton)
    modWindow:addComponent(otherDofileButton)
    modWindow:addComponent(yetAnotherDofileButton)
    interface.showWindow(modWindow)
    end
    --end

    You can run scripts for it, and edit variables. I will publish scripts that operate with it soon.

  • Pilihp64
    27th Mar 2013 Developer 0 Permalink

    Please use pastebin or code tags so we don't have to see a huge wall of unformatted lua.  A description might help too.

  • lapuminator
    27th Mar 2013 Member 0 Permalink

    WOAH! this is cool...

  • FeynmanLogomaker
    27th Mar 2013 Member 0 Permalink

    @cracker64 (View Post)

     Sorry, I tried to use code tags but it only kept half of the script.

  • mniip
    30th Mar 2013 Developer 0 Permalink
  • FeynmanLogomaker
    12th Apr 2013 Member 0 Permalink

    mniip: Too late.