1. The space forums use a separate registration system from the main virtual world. To comment on these forums, you need to create a separate forum account.
    Dismiss Notice
  2. Hey there, we have two Skype groups for space early users - if you're creating content, or need help, feel free to join in either the the beginners or advanced users groups.
    Dismiss Notice

Feature Request SGameObject.Script Component

Discussion in 'Feature Requests' started by Bibbi8448, Nov 11, 2017.

Share This Page

  1. Bibbi8448

    By:Bibbi8448Nov 11, 2017
    New Member

    Joined:
    Jul 4, 2017
    Messages:
    24
    Likes Received:
    0
    Currently we have the 'SShared.RegisterFunction / CallFunction' for functions and 'SShared.SetGlobal / GetGlobal' for properties, but could it be possible to access script functions and properties by doing something like the following. (Script 2)

    -- [[ SCRIPT 1 ]]
    SomeProperty = "Some Value";
    function SomeFunction()

    end

    -- [[ SCRIPT 2 ]]
    Space.Host.ExecutingObject.Parent.Script.SomeFunction();
    Space.Host.ExecutingObject.Parent.Script.SomeProperty = "New Value";
     
  2. Adam

    By:AdamNov 14, 2017 at 7:21 AM
    Developer
    Staff Member Moderator

    Joined:
    Aug 21, 2014
    Messages:
    575
    Likes Received:
    104
    In that method, no. We don't use duck typing in our Lua runtime; the right way to do that would be Register/Call function, but I guess if you want to do it on a specified object, we could do

    Space.Host.ExecutingObject.Parent.Script.ExecuteFunction("name", {args});

    Setting properties might be doable, although that's more complex.
     
  3. Bibbi8448

    By:Bibbi8448Nov 14, 2017 at 6:59 PM
    New Member

    Joined:
    Jul 4, 2017
    Messages:
    24
    Likes Received:
    0
    Yeah, that'll work just fine. I am curious though, why not call it SScript.CallFunction to match the name for in the Unity Event system option? I'd think it make more sense for most people as it'd make it a bit more clear as they do the exact same thing, except that this can have arguments when called.
     
  4. Adam

    By:AdamNov 16, 2017 at 6:22 PM
    Developer
    Staff Member Moderator

    Joined:
    Aug 21, 2014
    Messages:
    575
    Likes Received:
    104
    Call Function might be appropriate.

    Do you need return values, and/or immediacy? I would prefer to have it execute in the destination's script context - but that could mean the function doesn't execute until the next frame if that script has already executed this frame.
     
  5. Bibbi8448

    By:Bibbi8448Nov 16, 2017 at 7:53 PM
    New Member

    Joined:
    Jul 4, 2017
    Messages:
    24
    Likes Received:
    0
    Good point. At the moment, the places that I would like it don't need a return value, but I'm sure there will be a time and place where I and who knows how many others would like it to be able to return a value.
     
  6. Adam

    By:AdamNov 16, 2017 at 8:17 PM
    Developer
    Staff Member Moderator

    Joined:
    Aug 21, 2014
    Messages:
    575
    Likes Received:
    104
    I'd have to do the return via a callback to account for the possible orders of operations I think.