Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by afflicto

I have a crate entity which have 'content's.

The contents, I set in weltmeister using the settings.

For example, I have a EntityHealthpotion object.
I create a 'crate' in weltmeister then put a key 'contents.1' to 'EntityHealthpotion'.

Problem is, how do I spawn this item in the crate's code?
I need to dynamically get access to that entity.

I don't want to bother typing all entities in the requires block for my crate.

Thanks in advance.

1 decade ago by jerev

If your objects are not spawned before runtime, you can simply require everything in the main game module.

You can make "empty" modules to require all your loot at once. For example:

ig.module(
  'game.loot.loot'
)
.requires(
  'game.loot.potions',
  'game.loot.weapons'
)
.defines(function() {
  
});

ig.module(
  'game.loot.potions'
)
.requires(
  'game.loot.healthpotion',
  'game.loot.manapotion',
  'game.loot.endurancepotion',
  'game.loot.staminapotion'
  // ...
)
.defines(function() {
  
});

Requiring a module in runtime is difficult because of the asset preloader.
Page 1 of 1
« first « previous next › last »