Results 1 to 3 of 3

Thread: Call a global function from a local script

  1. #1

    Call a global function from a local script

    Hello,

    is it possible to call a global function from a local script? I want to create a lot of buttons for each figurine object on my table.
    Each button does the same for its parent figurine (at the position of the figurine), so that i dont want to copy and paste the function many times in a local script.

    e.g.
    [Button] -> [Local] (function localButtonAction(){ globalButtonAction(this) }) -> [global] (function globalButtonAction(obj) { //... } )

    maybe there is a better way to solve this?

    Thanks

  2. #2
    Join Date
    May 2016
    Posts
    1,072
    I haven't tried it, but did you try Global.call(functionNameString, tableOfParameters)?

  3. #3
    Hi, thx for your replay. That worked well!

    Global:call(...) is the right Syntax.

    for the sake of completeness:

    [Global]

    onload:
    create Buttons for each Figurine, Figurine is button_owner

    buttonAction(params)

    [localFigurineScript]
    localAction calls Global:call("buttonAction", {self})

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •