How to call or (expose to call) 3rd party plugin methods from Scripting?

1 favourites
  • 6 posts
From the Asset Store
Helping streamers give their viewers more excitement.
  • How can we call or (expose to call) 3rd party plugin methods from Scripting, similar to how we can call methods for plugins like Sprite, Text, etc. from scripts.

    I have used methods to work around this like call C3 event functions from script, but I benchmarked this and calling a C3 event function from Script has a higher performance cost for my project which drop performance below 10fps. I also benchmarked calling a function with no events and the action of just calling the empty function was also fairly heavy.

  • Ah, I think I am beginning to understand... I need to extend IWorldInstance w/ weakmap of functions I want to expose to scripting and register with:

    GetScriptInterfaceClass() {

    return self.IMyPluginInstance

    }

  • This worked very well, thanks for the nice interface / feature.

    Sped up perf by around 30X versus calling a C3 Event function from C3 JS scripting to access the plugin ACEs.

  • Mikal Sorry to re-open this old post, do you happen to have a quick example of what you did?

    I assume "extends SDK.IPluginBase" in instance.js will also have IWorldInstance but I'm unsure how or where to define the weakmap.

  • LordKhaos Check out one of the plugin examples here:

    construct-static.com/articles/downloads/46217/c3-plugin-sdk-v1-8.zip

    For example, look in the drawing plugin c3runtime/instance.js and search for "Script interface." Let me know if you have further questions. Also, I'm always curious, what kind of plugin are you working on?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So thats what this bit is about - got it working, thanks a mil for taking the time to help out!

    My plugin is basically a backend inventory manager - it handles adding items to the inventory, filtering and listing them by properties, incrementing specific properties (like when you are forging weapons), handling equiping an item, getting DEF (or other prop) a hero gets from all his equips, etc. Now that I'm happy with v1, just trying to simplify the way it works and how to debug it.

    I could do all of this with dictionaries and arrays on construct but after 2 weeks doing it, I just looked at my event sheet and tought it was going to be impossible to maintain it or modify it. Its way easier to just do this sort of things with JS.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)