Results 1 to 2 of 2

Thread: Events updated to be hookable

  1. #1

    Events updated to be hookable

    This would be a pretty big addition, though fully backwards compatible with current system: the facility to add extra function calls to any given event. Right now we can override any event by declaring it in our code:
    function onUpdate()
    but you can't add additional calls to the update event; you can only replace it. A lot of times if you're writing a general-purpose #include module you'll want to get it to do stuff on certain events, and the only way to accomplish this is for mod code to manually add the relevant code to their event calls. For example, in my Console++ module, if you want all its features, you have to add 'console.load()' to your onLoad function. It would be great if we could write
    addHook(onLoad, func)
    Explicitly, rather than store a single function for each event, TTS would keep an array of functions. The first function in the array would be the standard event calls (onLoad, onUpdate, etc), followed by each hook in the order they are added. When the event triggers each function in the array is called in order. It would be best if the 'func' parameter were an actual function, rather than a string function name, but that would also be acceptable (if not as nice).

    N.B. This kind of system is implementable by us at the Lua level (I believe dzikakulka already has one, as do I), but its really the kind of thing you want standardized by inclusion in the API itself, so that different people's #includes all work with each other.

  2. #2
    Yeah, it would help a lot. Especially as it doesn't even needany special handling engine-wise, just a short Lua script loaded for each object.

    If this would be considered too advanced (not at all IMO), at least make it available under Assets/Resources/MoonSharp/Scripts and let use use "require" to load it. Because like Zekiar shown [URL=""]in his thread[/URL], it is available, supported under Unity and fully functional.

Similar Threads

  1. Ignore ScriptingButton events when typing in text fields
    By dzikakulka in forum Scripting Suggestions
    Replies: 0
    Last Post: 06-10-2017, 01:02 PM
  2. A way to HOTKEY scripting events.
    By Tragic in forum Scripting
    Replies: 8
    Last Post: 05-17-2017, 08:05 PM
  3. TTS Scripting is missing essential events
    By Thels in forum Scripting Suggestions
    Replies: 3
    Last Post: 02-10-2017, 05:56 AM
  4. Events for objects with multiple states attached
    By Korroz in forum Scripting Suggestions
    Replies: 2
    Last Post: 01-16-2017, 02:13 PM
  5. Triggering invisble events ?
    By bobb in forum General Discussion
    Replies: 2
    Last Post: 03-14-2015, 12:43 AM

Posting Permissions

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