Modding Discussion How to call a function when clicking a button

Discussion in 'Starbound Modding' started by DeadIsaac, Jul 28, 2016.

Tags:
  1. DeadIsaac

    DeadIsaac Space Hobo

    Hey there

    I'm having a hard time trying to bind a function to an UI button in chests and call the function when i click the button

    So far i found all the chests config files in packed/Interface/ and i know i can put lua files into scripts but how can i make the two working together ?

    This is what i found in one of these files :
    {
    "close" : {
    "type" : "button",
    "base" : "/interface/inventory/x.png",
    "hover" : "/interface/inventory/xhover.png",
    "press" : "/interface/inventory/xpress.png",
    "position" : [143, 135]
    }
    }

    But i don't understand how the game manage the events and make the link between the UI and the scripts when we click on UI controls

    Could someone experienced with this help me please ?
     
  2. Silent Strider

    Silent Strider Pangalactic Porcupine

    As far as I can tell, there are six files that do it in Vanilla Starbound, and which you can study to see how it's done:

    interface\scripted\ancientconsole\ancientconsolegui.config
    interface\scripted\cropshipper\cropshippergui.config
    interface\scripted\mannequin\mannequingui.config
    interface\scripted\mmupgrade\mmupgradegui.config
    interface\scripted\techupgrade\techupgradegui.config
    interface\scripted\vehiclerepair\vehiclerepairgui.config

    The tag to look for is "scriptWidgetCallbacks"; you add the names of the UI elements you want to trigger LUA functions to this list, and in the .lua file a function for each UI element with the same name as the element itself.
     

Share This Page