KIDOZ integration question...

The plugin integration is a little different like with the other ad networks, so my question regarding the documentation is:

when using this line in main.lua:

local plugin = require( "plugin.kidoz" )

does this automatically mean I have access to (for example) the following in ALL THE CODE and all scenes…?

kidoz.init()

Or do I have to use a global in main.lua, like this?

plugin = require( "plugin.kidoz" )

And what about the “kidoz”?.. Is this working automatically or shouldn’t it be this in main.lua instead the “plugin”?..

kidoz = require( "plugin.kidoz" )

Thx for your help!

Daniela

PS: One more thing: How can I use kidoz together with other ad networks? Is it possible to switch between them like for example between “vungle” and “admob”?

I would not call it “plugin”.

You should do:   local kidoz = require(“plugin.kidoz”) in each scene and then reference all of their methods as kidoz.init(), kidoz.show() etc.

As far as making kidoz a global, while we discourage it, this is one instance where it’s probably okay to make it a global. “kidoz” is a pretty unique variable name that would likely not be used in any other context (were “plugin” may be used internally and you don’t want to stomp on that). It’s also not a name that would be inside a loop to cause performance problems.

But doing a local kidoz = require(“plugin.kidoz”) isn’t an excessive amount of code in the 2-3 .lua files where you might use it and save any risk brought by globals.

Rob

Thank you for the info Rob.

Regarding the global names: How “far” is global defined? Do I have to keep in mind also stuff which is not visible in my code… like plugins loaded when the build is made for example?

Any plugin or external library could create global variables. 

Rob

I would not call it “plugin”.

You should do:   local kidoz = require(“plugin.kidoz”) in each scene and then reference all of their methods as kidoz.init(), kidoz.show() etc.

As far as making kidoz a global, while we discourage it, this is one instance where it’s probably okay to make it a global. “kidoz” is a pretty unique variable name that would likely not be used in any other context (were “plugin” may be used internally and you don’t want to stomp on that). It’s also not a name that would be inside a loop to cause performance problems.

But doing a local kidoz = require(“plugin.kidoz”) isn’t an excessive amount of code in the 2-3 .lua files where you might use it and save any risk brought by globals.

Rob

Thank you for the info Rob.

Regarding the global names: How “far” is global defined? Do I have to keep in mind also stuff which is not visible in my code… like plugins loaded when the build is made for example?

Any plugin or external library could create global variables. 

Rob