-
Notifications
You must be signed in to change notification settings - Fork 134
Allow custom entities to have a custom model path. #523
Comments
I'm not sure I understand the probem. If a custom entity wants to use external code, just import the external code and call it. For example, assume that there is some external code for an arrow (for the bow) in a separate lib. You can call the lib from a map script with something like:
where my_custom_entity is a custom entity previously created (possibly from the editor). If you want the entity to be usable on several maps more easily, you can create the following custom entity model script in data/entities/arrow.lua:
And this script will be called for all custom entity that have this model. So models are just a way to avoid repeating code on each map that has the same kind of custom entity. This works exactly like enemies. For me, the library does not care about whether the user wants a model or not. It takes a custom entity as parameter and initializes with properties and callbacks of an arrow. For the particular case of arrows, a model is probably not necessary. You will typically create an arrow from only one place (the bow script), never from the editor or from another script. Models are more useful for entities that have to be placed repeatedly on lots of maps with the editor. An example of such entities are the stakes that have to be pushed with the hammer. In my opinion, the library should not focus only on custom entities. It should also provide common items, common menus, etc. |
Does the engine look for the entity in specifically the quest's directory, or also common lua paths, for |
Only require() looks in common Lua paths. The map, enemies, items and custom entity scripts are loaded in the quest directory or in the savegames directory. Maybe these scripts should be loaded using require() too somehow? I will think about that. |
I have an alternate solution that does not require an engine change. |
As of now, entities have no way to declare where the model is. This poses a problem for ekureina/libsolarus-mudora#1 and the library support that is enabled in lib.lua (in that repository). How does the game load an entity by model? That might be a barrier to this.
The text was updated successfully, but these errors were encountered: