Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting undefined is not a function error when adding plugins #3

Closed
quorth0n opened this issue Aug 8, 2014 · 1 comment
Closed
Assignees

Comments

@quorth0n
Copy link

quorth0n commented Aug 8, 2014

Hello all,
When I try calling plugins.add, I get the following error:
Uncaught TypeError: undefined is not a function
Here is my code:

var createPlugins = require('voxel-plugins');
var plugins = createPlugins(game, {require:require});

//Load Plugins
plugins.add('voxel-health', {maxHealth: 20});
plugins.add('voxel-health-bar', {});
plugins.loadAll();

The error occurs where I attempt to add the voxel-health and the voxel-health-bar plugins.

Thank you all in advanced

@quorth0n quorth0n changed the title Getting undefined is not a function error when adding functions Getting undefined is not a function error when adding plugins Aug 8, 2014
@deathcap deathcap self-assigned this Sep 17, 2014
@deathcap
Copy link
Member

When using the require:require option, plugins have to be require()'d in the calling module before using plugins.add(), something like this:

require('voxel-health');
require('voxel-health-bar');
var createPlugins = require('voxel-plugins');
var plugins = createPlugins(game, {require:require});

//Load Plugins
plugins.add('voxel-health', {maxHealth: 20});
plugins.add('voxel-health-bar', {});
plugins.loadAll();

if you still see this when adding the require()s, could you include the full stacktrace for the "Uncaught TypeError: undefined is not a function" error.

In voxel-plugins 0.5.0+ (#8), added a new 'loaders' option which makes the dependencies clearer:

var createPlugins = require('voxel-plugins');
var plugins = createPlugins(game, {loaders:
  'voxel-health': require('voxel-health'),
  'voxel-health-bar': require('voxel-health-bar')
});

//Load Plugins
plugins.add('voxel-health', {maxHealth: 20});
plugins.add('voxel-health-bar', {});
plugins.loadAll();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants