ide.MakePlugin

80 views
Skip to first unread message

Alan Hendry

unread,
Mar 10, 2021, 10:51:29 AM3/10/21
to DroidScript
Hi,
I see the example of creating a WebView map plugin, and 2.06  ide.MakePlugin
I want to make some easily re-usable UI plugins.
Do we have any examples of coding, conversion, and use?
I've seen some examples of definition like
app.functionname = function (parameters) { body of function }
and usage 
app.functionname(parameters)
What would be considered best practice?
(Or am I barking up the wrong tree).
Regards, ah

Dave

unread,
Mar 11, 2021, 7:03:57 AM3/11/21
to DroidScript
Hi Alan,

The Map plugin is a good reference example, however it was written before the ide.MakePlugin existed.

If you create a fresh project in DS and include the ideMakePlugin call at the start, it will generate the necessary javascript and html files required for a simple DS plugin. You just need to reload your project to see the new generated files.  For example the code below will add 3 new files to your project - DemoPlugin.js, DemoPlugin.html and DemoPlugin.png

function OnStart() 
  //Package this project into a plugin and install it. 
  ide.MakePlugin( "DemoPlugin" ) 

   //Test the plugin functionality. 
   app.LoadPlugin( "DemoPlugin" ) 
   plg = app.CreateDemoPlugin() 
   alert( plg.Test( "World" ) ) 
}

You can examine those files to see the function pattern/style you need to use to add new features to your plugin.  These files will be re-generated every time you run the project and a DemoPlugin.ppk will also be generated every time (in the DroidScript/PPKs folder) which contains the packaged plugin, ready for deployment or uploading to the DS Store.

The MapView plugin is a bit more sophisticated as it wraps up a WebView control.  This technique allows you to make use of the many HTML5 and JavaScript libraries that exist on Github and around the web.

Hope that helps

Regards
David
Reply all
Reply to author
Forward
0 new messages