Custom Library: How to AUTOMATICALLY add object types to game object?

Hello! I'm working on a comprehensive library thingy. (The Quest Solaer Library / QSL)

I want to put some effort into making it compatible with other libraries, and one facet of doing that is to avoid overriding default Quest functions and object types if at all feasible.

However, just as the vanilla Quest libraries have to use the game object to store default values and feature toggles that can be changed in the editor, so does QSL.

The two ways I know of to do that are:

  1. Redefine the defaultgame object type (which I don't like at all)
  2. Create a solaergame object type, but game authors must manually add it to the game object (which is suboptimal)

So my question is: Is it possible for a library to tell Quest to automatically add an object type to the game object in addition to defaultgame, so that I can avoid overriding defaultgame and authors using my library will not need to add the object type manually for every game?


I don't think there's a neat way to do it.

When I was looking into making a library that would require something similar, my solution was to make it an object. You could have a solaergame object, and your library's code looks for its attributes there rather than on the game object. The main problem with this would be that it would be in the list returned by AllObjects(), which could possibly confuse other libraries that use that for something.

One possible solution would be to create an object and give it a script:

<attr name="_initialise_" type="script">
  foreach (attr, ListExclude(GetAttributeNames (this, false), Split("name;_initialise_"))) {
    if (not HasAttribute (game, attr)) {
      set (game, attr, GetAttribute (this, attr))
    }
  }
  destroy (this.name)
</attr>

Basically forcing an object to act like a type, copying all its attributes [aside from the initialise script itself and its name] onto the game element at startup.


While I myself might be able to work with that, that solution will not permit authors to reconfigure QSL through the Quest editor; for instance, my time system defaults to 24 hours in a day etc., but the author should be able to change that in the editor just as easily as they can change the game name or subtitle, etc.

For the time being, I think I'll have to settle for instructing authors to manually add the solaergame object type. I think this will be the least destructive solution, and the most intuitive one available without source code edits to Quest itself. x(


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums