Results 1 to 5 of 5

Thread: Calling functions from the Global Script

  1. #1

    Calling functions from the Global Script

    I have an object with its own script but I'd like to use a function i have writted in the Global Script within it. I see
    callLuaFunctionInOtherScriptWithParams( Object function_owner, string function_name, Table parameters )
    in the API which is what I think I need to use, but I'm not sure how I can pass a reference of the Global script for the first parameter.

  2. #2
    you just put nil in the 1st parameter to direct it to Global
    callLuaFunctionInOtherScriptWithParams(nil, 'name_of_global_function', {paramsTable} )

  3. #3
    Join Date
    Mar 2016
    Nil still works, but the correct syntax is to use the keyword 'Global'

  4. #4
    Now that I know the syntax I tried to do some stuff with the function, but I cant seem to get it to work.

    No matter what function i try to call with it, it always returns true and doesn't actually run the function I tell it to call. I've tried it with several different objects and functions and can't seem to do anything with it.

    Does anyone have an example of a working usage with this?

  5. #5
    I have buttons on the game board that are used by the players to perform certain actions. I'll cite a much simplified version here...

    In the script edit window for the button object I have something like...
    function onload()
        local button = {}
        button.click_function = 'fire'
        button.label ='FIRE!'
        button.function_owner = self
        button.position = {0, 0.14, 0}
        button.rotation = {0, 180, 0}
        button.width = 1400
        button.height = 1000
        button.font_size = 900
    function fire()
    Then in the Global script edit window I'll have a function like...
    function take_a_shot()

Posting Permissions

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