Creating a Library filled with Turn-Scripts/Commands/Rooms. (Unsolved)

Hello all!

I was wondering if creating a library with turn-scripts, rooms or commands is the same way you do it with Functions?

Anonynn.


Pretty much. When a game is published, the line <include ref="SomeLibrary.aslx"/> is replaced by the contents of the library; so it can contain anything that a regular game file does.

If you want to put objects in a library, you can give them a "parent" attribute and they should be moved to the right place as soon as the game is loaded; not sure how easy that is to do within the editor.

Putting rooms in a library seems a little odd. In most of the circumstances where you might consider this, it would be more efficient to have the library contain a type, and then put the actual room in the main game file. But if you're using library functionality to split different parts of your game into different files, then go ahead ^^

(Note: I'm only referring to the way the player handles libraries; I don't know if the GUI is going to be a pain over them)


If you want to put objects in a library, you can give them a "parent" attribute and they should be moved to the right place as soon as the game is loaded; not sure how easy that is to do within the editor.

But do not do it the other way around. If an object in the main file has a parent attribute set to a room or object in the library, Quest will crash when opening the GUI interface.

Generally I would not recommend moving rooms and objects to a library, just because it is so much easy to edit them through the GUI. If you have a whole chunk of your game that is finished, it might be worthwhile moving that, for a very large game (and I know Anonynn's is).


Thanks guys :D I appreciate your time!

Yeah, once I completely remaster the first chapter which is very, very close to being finished, I was thinking of just moving the entire section into a library.

For the time being, I'm learning how to move Functions over and was going to start doing the same to the Commands and Turn-Scripts too that way I can reduce the size. I think it's around 10-11MB and I've been getting really weird out-of-memory errors dealing with CEF or something like that (not even the normal Error out of memory error) xD

If you don't mind I'll likely ask for Objects and Rooms to libraries down the road when it comes time!

Anonynn.


(filler for getting my edited post, updated/posted)
(again, filler for getting my edited post, updated/posted)


to expound upon mrangel's post about how library files work (or rather what are library files, whatever, lol) ...


LIBRARY FILE USAGE GUIDE (below within this post and within my additional posts below as well)


think of the files as literally folders for your entire game code:

  1. you got your 'NAME_OF_GAME_FILE.aslx' game file, which requires some special code in order to run/play your game (the 'asl' GAME OBJECT, human language and engine code, the special Game Settings and Publishing Info 'game' Object, a Room Object containing a Player Object, and etc code?)

  2. otherwise, you got your 'NAME_OF_LIBRARY_FILE.aslx' library files, which requires the 'library' LIBRARY OBJECT, and whatever game code (aside from the required game code for the game to run, as this code must be within the game file) you want to put/store within your library file


you can literally have your entire game code within a single "folder" (file): your 'NAME_OF_GAME_FILE.aslx' game file

but, when your game gets big, this becomes a huge hassle, having all of your code in a single file, lots of searching/scrolling... lol

which is when you should use library files for separating/organizing various segments/parts/pieces/types of your game code


but first, let's just examine/understand game files and library files...


the default new game file:

(example name of our game file: example_game_file.aslx)

<asl version="550">

  <include ref="English.aslx" />
  <include ref="Core.aslx" />

  <game name="example game">
  </game>

  <object name="room">

    <inherit name="editor_room" />

  </object>

  <object name="player">

    <inherit name="editor_object" />
    <inherit name="editor_player" />

    <attr name="parent" type="object">room</attr>

  </object>

</asl>

more game code (an 'orc' Object, also contained within the 'room' Room Object, just like the 'player' Player Object):

<asl version="550">

  <include ref="English.aslx" />
  <include ref="Core.aslx" />

  <game name="example game">
  </game>

  <object name="room">

    <inherit name="editor_room" />

  </object>

  <object name="player">

    <inherit name="editor_object" />
    <inherit name="editor_player" />

    <attr name="parent" type="object">room</attr>

  </object>

  <object name="orc">

    <inherit name="editor_object" />

    <attr name="parent" type="object">room</attr>

  </object>

</asl>

now, let's just compartmentalize/organize/"file-folder-away"/separate parts/pieces/segments/types of our game code into multiple files (a game file and a library file):

our 'example_game_file.aslx' game file:

<asl version="550">

  <include ref="English.aslx" />
  <include ref="Core.aslx" />

  <include ref="orc_library_file.aslx" />

  <game name="example game">
  </game>

  <object name="room">

    <inherit name="editor_room" />

  </object>

  <object name="player">

    <inherit name="editor_object" />
    <inherit name="editor_player" />

    <attr name="parent" type="object">room</attr>

  </object>

</asl>

and our (example named):

'orc_library_file.aslx' library file

<library>

  <object name="orc">

    <inherit name="editor_object" />

    <attr name="parent" type="object">room</attr>

  </object>

</library>

these two files are the exact same as if we only had our game file containing all of our game code (the required stuff and our 'orc' Object)

as literally the:

<include ref="NAME_OF_LIBRARY_FILE.aslx" />


code line is telling quest to go find and open up that file, highlight and copy all of its code (except the '<library>' and '</library>' code lines), and then to paste it into your game file's code, just as if you just had all of the code within your game file to begin with

Organizing your code, via multiple files (your game file and your X-quantity-of library files), makes it much easier on you!

(there are some issues though in using multiple, aka library, files, as they got to be compatible: placed in the correct order, and etc various other issues involved, like duplication of your code, unfortunately I don't think quest as the 'def/ifdef/ifndef' functionality for its library files: https://msdn.microsoft.com/en-us/library/2a1b21sf.aspx , though please correct me, if it indeed does have this very important functionality!)


P.S.

IMPORTANT:

your library files must be within the same folder as either: your game file and/or quest (the 'quest.exe' file-program), as otherwise, quest won't be able to find/locate your library files (these are the places/folders that it searches for your library files)


you can have any (more or less, might be some exceptions) Element (Objects, Functions, Commands, Turnscripts, Timers, Verbs, Object Types, and etc) within a library file:

<library>

  <object name="orc">

    <inherit name="editor_object" />

    <inherit name="monster_type" />

    <attr name="parent" type="object">room</attr>

  </object>

  <object name="ogre">

    <inherit name="editor_object" />

    <inherit name="monster_type" />

    <attr name="parent" type="object">room</attr>

  </object>

  <type name="monster_type">

    <attr name="dead" type="boolean">false</attr>

  </type>

  <command name="example_command">
  </command>

  <function name="example_function">
  </function>

  <verb name="example_verb">
  </verb>

  <turnscript name="example_turnscript">
  </turnscript>

  <timer name="example_timer">
  </timer>

</library>

P.S.

library files can be nested (library files can be loaded/copied into other library files: library files do NOT have to be loaded/copied into the game file, well, eventually they have to from some library file, but hopefully you understand from the example below), an example of it:

(btw: the 'Core.aslx' is the default/built-in engine code and it's a hub library file to the various/numerous individual 'core' library files found in the quest folder)

'example_game_file.aslx' game file:

<asl version="550">

  <include ref="English.aslx" />
  <include ref="Core.aslx" />

  <include ref="monster_hub_library_file.aslx" />

  <game name="NAME_OF_GAME">
  </game>

  <object name="room">

    <inherit name="editor_room" />

  </object>

  <object name="player">

    <inherit name="editor_object" />
    <inherit name="editor_player" />

    <attr name="parent" type="object">room</attr>

  </object>

</asl>

'monster_hub_library_file.aslx' hub library file:

<library>

  <include ref="orc_libary_file.aslx" />
  <include ref="ogre_libary_file.aslx" />
  <include ref="troll_libary_file.aslx" />
  <include ref="goblin_libary_file.aslx" />
  <include ref="gremlin_libary_file.aslx" />
  <include ref="cyclops_libary_file.aslx" />

  <object name="monster_object">

    <monster_species_stringlist_attribute type="stringlist">

      <value>orc</value>
      <value>ogre</value>
      <value>troll</value>
      <value>goblin</value>
      <value>gremlin</value>
      <value>cyclops</value>

    </monster_species_stringlist_attribute>

  </object>

</library>

'orc_library_file.aslx' library file:

<library>

  <object name="orc">

    <inherit name="editor_object" />

    <inherit name="orc_type" />

    <attr name="parent" type="object">room</attr>

  </object>

  <type name="orc_type">

    <attr name="species_string_attribute" type="string">orc</attr>

  </type>

</library>

'ogre_library_file.aslx' library file:

<library>

  <object name="ogre">

    <inherit name="editor_object" />

    <inherit name="ogre_type" />

    <attr name="parent" type="object">room</attr>

  </object>

  <type name="ogre_type">

    <attr name="species_string_attribute" type="string">ogre</attr>

  </type>

</library>

'troll_library_file.aslx' library file:

<library>

  <object name="troll">

    <inherit name="editor_object" />

    <inherit name="troll_type" />

    <attr name="parent" type="object">room</attr>

  </object>

  <type name="troll_type">

    <attr name="species_string_attribute" type="string">troll</attr>

  </type>

</library>

'goblin_library_file.aslx' library file:

<library>

  <object name="goblin">

    <inherit name="editor_object" />

    <inherit name="goblin_type" />

    <attr name="parent" type="object">room</attr>

  </object>

  <type name="goblin_type">

    <attr name="species_string_attribute" type="string">goblin</attr>

  </type>

</library>

'gremlin_library_file.aslx' library file:

<library>

  <object name="gremlin">

    <inherit name="editor_object" />

    <inherit name="gremlin_type" />

    <attr name="parent" type="object">room</attr>

  </object>

  <type name="gremlin_type">

    <attr name="species_string_attribute" type="string">gremlin</attr>

  </type>

</library>

'cyclops_library_file.aslx' library file:

<library>

  <object name="cyclops">

    <inherit name="editor_object" />

    <inherit name="cyclops_type" />

    <attr name="parent" type="object">room</attr>

  </object>

  <type name="cyclops_type">

    <attr name="species_string_attribute" type="string">cyclops</attr>

  </type>

</library>

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

Support

Forums