How To Create a Library

TriangleGames
27 Dec 2013, 18:05
I'm making my own library for the first time, and I think I'm "doing it wrong."
I created the whole thing in Quest using the GUI, thinking I could just add the <library></library> tags in notepad after I finished it,
but it doesn't seem to like that. If it's possible to make it work, I'm assuming I need to remove something from it, or place the tags in a different spot maybe? I might be able to experiment and figure it out, but I thought I'd ask in case anybody else ever has this issue.

HegemonKhan
27 Dec 2013, 18:12
A Library File (.aslx):

<library>
-> // mass of code, everything has to be within the <library></library> tags
</library

you probably have to take out these tags too:

A Game File (.aslx):

<asl version="540">
</asl>

<game name="blah">
-> // and all of these code lines too removed
</game>

TriangleGames
27 Dec 2013, 18:19
That makes sense I guess. Remove anything that defines it as a game file.
One other problem I'm going to have then is that I've put custom attributes on the game object.
Where might I include these kind of "global attributes" after removing the <game> section?
Can I just leave them "loose" or will they need to be "attached" to something?

HegemonKhan
27 Dec 2013, 18:29
make a new Object (non-room and non-player), but NOT within any Room Object:

here's an example of it (as a Game File):

<asl version="540">
<include ref="English.aslx"/>
<include ref="Core.aslx"/>
<game name="Testing Game Stuff">
<gameid>d67ec73f-f879-4911-9d88-c02ea527c534</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
<object name="string_data_object">
<inherit name="editor_object" />
// all of my string attributes
</object>
<object name="boolean_data_object">
<inherit name="editor_object" />
// all of my boolean attributes
</object>
<object name="integer_data_object">
<inherit name="editor_object" />
// all of my integer attributes
</object>
<object name="double_data_object">
<inherit name="editor_object" />
// all of my double attributes
</object>
<object name="string_list_data_object">
<inherit name="editor_object" />
// all of my string list attributes
</object>
<object name="character_data_object">
<inherit name="editor_object" />
// all of my character attributes
</object>
<object name="equipment_data_object">
<inherit name="editor_object" />
// all of my equipment attributes
</object>
// etc etc etc "data objects"
</asl>

-------------

here's an example of one (my workings on date and time, and etc stuff, lol) of mine:

<object name="global_data_object">
<inherit name="editor_object" />
<month_string_list type="simplestringlist">january;february;march;april;may;june;july;august;september;october;november;december</month_string_list>
<thirty_one_day_string_list type="simplestringlist">1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31<thirty_one_day_string_list>
<thirty_day_string_list type="simplestringlist">1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30<thirty_day_string_list>
<twenty_nine_day_string_list type="simplestringlist">1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29<twenty_nine_day_string_list>
<twenty_eight_day_string_list type="simplestringlist">1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28<twenty_eight_day_string_list>
<gender_string_list type="simplestringlist">male;female</gender_string_list>
<specialization_string_list type="simplestringlist">combat;magic;stealth;diplomacy;science</specialization_string_list>
<maturity_string_list type="simplestringlist">baby;child;teen;adult</maturity_string_list>
<elemental_string_list type="simplestringlist">physical;magical;fire;water;air;earth;light;dark;holy;unholy</elemental_string_list>
<elemental_string_dictionary type="simplestringdictionary">physical=magical;magical=physical;fire=water;water=fire;air=earth;earth=air;light=dark;dark=light;holy=unholy;unholy=holy</elemental_string_dictionary>
<season_string_dictionary type="simplestringdictionary">january=winter;february=winter;march=spring;april=spring;may=spring;june=summer;july=summer;august=summer;september=autumn;october=autumn;november=autumn;december=winter<season_string_dictionary>
<month_string_dictionary type="simplestringdictionary">january=1;1=january;february=2;2=february;march=3;3=march;april=4;4=april;may=5;5=may;june=6;6=june;july=7;7=july;august=8;8=august;september=9;9=september;october=10;10=october;november=11;11=november;december=12;12=december</month_string_dictionary>
<human_string_list type="simplestringlist">european;african;asian;american</human_string_list>
<season_string_list type="simplestringlist">winter;spring;summer;autumn</season_string_list>
<day_string_list type="simplestringlist">sunday;monday;tuesday;wednesday;thursday;friday;saturday<day_string_list>
<skin_string_list type="simplestringlist">skin;fur;feathers;scales</skin_string_list>
<old_leap_year_integer type="int">2012</old_leap_year_integer>
<new_leap_year_integer type="int">2016</new_leap_year_integer>
<year_integer type="int">2013</year_integer>
<second_integer type="int">0</second_integer>
<minute_integer type="int">0</minute_integer>
<hour_integer type="int">0</hour_integer>
<day_integer type="int">0</day_integer>
<week_integer type="int">0</week_integer>
<month_integer type="int">0</month_integer>
<day_string type="string"></day_string>
<month_string type="string"></month_string>
<season_string type="string"></season_string>
</object>


----------------------------

here's a Library Template, that I like to use:

(and along with using notepad++)

<library>

<!-- Libraries -->

<!-- Templates -->

<!-- Verbs -->

<!-- Commands -->

<!-- Functions -->

<!-- Turnscripts -->

<!-- Timers -->

<!-- Object Types -->

<!-- Attributes -->

<!-- Strings -->

<!-- Booleans -->

<!-- Integers -->

<!-- Doubles -->

<!-- Lists -->

<!-- String Lists -->

<!-- Object Lists -->

<!-- Dictionaries -->

<!-- String Dictionaries -->

<!-- Object Dictionaries -->

<!-- Script Dictionaries -->

<!-- Scripts -->

<!-- Changed Scripts -->

<!-- Inherited -->

<!-- Game Object -->

<!-- Player Objects -->

<!-- Room Objects -->

<!-- Data Objects -->

<!-- Combat System -->

<!-- Equipment System -->

<!-- Magic System -->

<!-- Dialogue System -->

<!-- Game Mechanics -->

<!-- My Own Extra Notes -->

</library>


---------------------------

P.S.

just remember that your "statusattributes" String Dictionaries (your displayment within the game right side pane) must be placed back upon your "game" or "player" Objects for them to work.

--------------------------

P.S.S.

I just use my library file more simply as a "saved document", where I can just open it up and copy and paste whatever code I want into my game file of the game project that I'm working on.

As, making library files as "patches" or "expansion packs" to be included within a game, is still beyond my coding ability (I can't code simple and universal but powerful ones like Pixie, Sora, Chase, Jayna, and etc), lol.

TriangleGames
27 Dec 2013, 19:13
Aha! It works! Thank you so much! I was really afraid I had done all that for nothing. It took me a second to realize I needed to show the library elements in order to find my "briefcase" object with the attributes on it :lol: but everything is looking perfect now.

EDIT:
HegemonKhan wrote:
P.S.S.

I just use my library file more simply as a "saved document", where I can just open it up and copy and paste whatever code I want into my game file of the game project that I'm working on.

As, making library files as "patches" or "expansion packs" to be included within a game, is still beyond my coding ability (I can't code simple and universal but powerful ones like Pixie, Sora, Chase, Jayna, and etc), lol.

Well, you just taught me how to make a library in Quest using the GUI and convert it. There's NO WAY I could've made that thing without the GUI. The troubleshooting alone would've confounded me. This way, I was able to just pop over and hit "Play" to test each part at will. I think I will save myself a template file for copying the code into for next time though. That would help with this "conversion" trick.

HegemonKhan
28 Dec 2013, 05:45
You can also just simply look at others' posted library files, to see what they look like, and work, lol ;)

The "Libraries and Code Samples" Board~Forum of this site: viewforum.php?f=18

Also some Libraries (such as pixie's spell library) are here too: http://quest5.net/wiki/How_to
actually it's quite hidden, lol: http://quest5.net/wiki/Using_Types_and_Tabs_(Advanced) <-- (just add the ending ")" in the url, as it gets chopped off for some reason in this post, taking you to the null page)
(scroll down to the very bottom of the above link to find the 2 files to download)

And within the Tutorial as well (I think~ am pretty sure anyways, lol): http://quest5.net/wiki/Tutorial

And Lastly, here as well: http://quest5.net/wiki/Libraries

And, truly truly Lastly (lol): this forum itself, people's threads and posts.

-----------

here's an example, using Pixie's Spell Library File, a professional level of a Library File (unlike anything I could ever do at least right now, lol):

the "tab" coding is literally creating (adding more of) the GUI~Editor 's tabs, libraries create new tabs~abilities for using~within the GUI~Editor, to help you craft aspects of your game, and in this example, Pixie's spell library adds a magic system~options~settings~tabs to when you work on your game in the GUI~Editor.

err, when I copy and pasted this... the spacing and etc got all messed up, Pixie's library isn't actually this badly formated, lol.

<?xml version="1.0"?> // HK's note: this isn't needed, you don't need to include this code line in your library files, it can be removed in this library file of pixie's too, it's a way to use an online code language checker, to see if the code has any errors (but I just use notepad++ when writing, editing, and troubleshooting my code, lol)

<library>


<!--
This library adds a basic magic system to quest. It allows for three types of spells:

nonattackspell: Instant effect
lastingspell: An on-going spell. These last until another spell is cast
attackspell: Instant effect, attacking anything of the "monster" type that is not dead

Attack spells must be of an element, and eight are already set up. Monsters
can be assigned to elements too; they will be immune to that element, but take
four-fold damage from the opposed element.

A "Magic" tab is added to the editor to make setting up spells and monsters as easy as possible.
-->

<!--
Adding new elements involves a bit of effort. This system requires that elements are added in pairs or opposites,
such as fire and frost.
1. Create a new type for both elements, named [elemem]_type
2. In the data section, the object element_struct needs both elements added to both "elements" and
"opposedelements", and for the latter you need to put them in both ways around (look at existing entries)
3. You need to add both elements to the tab, both for "monster" and for "attackspell". Again, see existing
entries.
-->


<!-- =================================================== -->
<!-- Templates -->

<!--
Using templates makes it easier to convert to other languages, but also for other users to word it how they want it.
When templates are in the library that uses them (as here) the way to change the language is to
modify the template in the library, so really the only benefit is that all the text is together here.
Also modify the default responses in the verbs!
-->

<template name="Learn">learn</template>
<template name="Cast">cast</template>

<template name="LookDead">Oh, and it is dead.</template>
<template name="SpellAlreadyKnown">Er, you already know that one!</template>
<template name="SpellNotKnown">Er, you don't know that one!</template>
<template name="NoMonstersPresent">No monsters present</template>

<dynamictemplate name="SpellEnds"><![CDATA["The <i>" + GetDisplayAlias(object) + "</i> spell ends."]]></dynamictemplate>
<dynamictemplate name="SpellCast"><![CDATA["You cast <i>" + GetDisplayAlias(object) + "</i>."]]></dynamictemplate>
<dynamictemplate name="SpellLearnt"><![CDATA["In a process that seems at once unfathomable, and yet familiar, the spell fades away, and you realise you are now able to cast the <i>" + GetDisplayAlias(object) + "</i> spell."]]></dynamictemplate>



<!-- =================================================== -->
<!-- Verbs -->

<verb>
<property>learn</property>
<pattern>[Learn]</pattern>
<defaultexpression>"You can't learn " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>cast</property>
<pattern>[Cast]</pattern>
<defaultexpression>"You can't cast " + object.article + "."</defaultexpression>
</verb>


<!-- =================================================== -->
<!-- Functions -->

<!--
Handles an attack on the given monster, using the given spell.
Monster loses hit points according to the spell's powerrating.
If they share an element, then no damage, if elements are opposed, damage is multplied by 4
Handles monsters with no elements too, but spell must have an element set.
-->
<function name="SpellAttackMonster" parameters="monster, spell"><![CDATA[
element = GetElement (monster)
handled = False
if (not element = Null) {
if (DoesInherit (spell, element + "_type")) {
msg ("... " + monster.ignoreselement)
handled = True
}
if (DoesInherit (spell, StringDictionaryItem (element_struct.opposedelements, element) + "_type")) {
monster.hitpoints = monster.hitpoints - 4 * spell.powerrating
handled = True
if (monster.hitpoints > 0) {
msg ("... " + monster.hurtbyelement)
}
else {
msg ("... " + monster.deathbyelement)
Death (monster)
}
}
}

if (not handled) {
monster.hitpoints = monster.hitpoints - spell.powerrating
if (monster.hitpoints > 0) {
msg ("... " + monster.hurt)
}
else {
msg ("... " + monster.death)
Death (monster)
}
}
]]></function>


<!--
Call this when a spell is cast, to ensure any on-going spells
are terminated.
-->
<function name="CancelSpell"><![CDATA[
if (HasObject (player, "currentspell")) {
spell = player.currentspell
msg (DynamicTemplate("SpellEnds", spell))
player.currentspell = null
if (HasScript (spell, "terminate")) {
do (spell, "terminate")
}
}
]]></function>


<!--
Call this when a monster dies for some housekeeping.
-->
<function name="Death" parameters="monster"><![CDATA[
monster.alias = monster.alias + " (dead)"
if (HasString (monster, "lookwhendead")) {
monster.look = monster.lookwhendead
}
else {
monster.look = monster.look + " [LookDead]"
}
monster.dead = True
]]></function>


<!--
Returns as a string the name of this object's element (or null).
-->
<function name="GetElement" parameters="obj" type="string"><![CDATA[
result = Null
foreach (element, element_struct.elements) {
type = element + "_type"
if (DoesInherit (obj, type)) {
result = element
}
}
return (result)
]]></function>


<!--
Describes casting
-->
<function name="DescribeCast" parameters="spell"><![CDATA[
if (HasString (spell, "description")) {
msg (DynamicTemplate("SpellCast", spell) + " " + spell.description)
}
else {
msg (DynamicTemplate("SpellCast", spell))
}
]]></function>


<!-- =================================================== -->
<!-- Object types -->

<type name="spell">
<inventoryverbs type="list">Learn</inventoryverbs>
<displayverbs type="list">Learn</displayverbs>
<drop type="boolean">false</drop>
<take type="boolean">false</take>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<learn type="script"><![CDATA[
if (not this.parent = player) {
this.parent = player
this.inventoryverbs = Split ("Cast", " ")
msg (DynamicTemplate("SpellLearnt", this))
}
else {
msg ("[SpellAlreadyKnown]")
}
]]></learn>
</type>



<type name="attackspell">
<inherit name="spell"/>
<cast type="script"><![CDATA[
// Check the player has the spell
// If so iterate through all objects in the room
// Apply attack to those with the monster type that are not dead
if (this.parent = player) {
DescribeCast (this)
flag = False
foreach (obj, ScopeVisibleNotHeld ()) {
if (DoesInherit (obj, "monster") and not GetBoolean (obj, "dead")) {
SpellAttackMonster (obj, this)
flag = True
}
}
if (not flag) {
msg ("... [NoMonstersPresent]")
}
CancelSpell ()
}
else {
msg ("[SpellNotKnown]")
}
]]></cast>
</type>


<type name="nonattackspell">
<inherit name="spell"/>
<cast type="script"><![CDATA[
if (this.parent = player) {
DescribeCast (this)
do (this, "spelleffect")
CancelSpell ()
}
else {
msg ("[SpellNotKnown]")
}
]]></cast>
</type>


<type name="lastingspell">
<inherit name="spell"/>
<cast type="script"><![CDATA[
if (this.parent = player) {
DescribeCast (this)
do (this, "spelleffect")
CancelSpell ()
player.currentspell = this
player.status = this.status
}
else {
msg ("[SpellNotKnown]")
}
]]></cast>
</type>


<type name="fire_type">
</type>

<type name="frost_type">
</type>

<type name="storm_type">
</type>

<type name="earthmight_type">
</type>

<type name="shadow_type">
</type>

<type name="rainbow_type">
</type>

<type name="divine_type">
</type>

<type name="necrotic_type">
</type>

<type name="monster">
</type>


<!-- =================================================== -->
<!-- Data -->

<!--
This is a data store for elements (I call it a "struct" after the keyword in the C programming language)
If you add more elements to the name, you need to add them to both lists as well as creating a new type.
Note that your new type must end "_type", but that must not be included on these lists.
-->
<object name="element_struct">
<elements type="list">fire; frost; storm; earthmight; shadow; rainbow; divine; necrotic</elements>
<opposedelements type="stringdictionary">fire = frost;frost = fire;storm = earthmight;earthmight = storm;shadow = rainbow;rainbow = shadow;necrotic = divine;divine=necrotic</opposedelements>
</object>


<!-- =================================================== -->
<!-- Tabs -->

<tab>
<parent>_ObjectEditor</parent>
<caption>Magic</caption>
<mustnotinherit>editor_room; defaultplayer</mustnotinherit>

<control>
<controltype>dropdowntypes</controltype>
<caption>Spell type</caption>
<types>*=None; nonattackspell=Non-attack spell; lastingspell=Lasting spell; attackspell=Attack spell; monster=Monster</types>
<width>150</width>
</control>



<control>
<controltype>title</controltype>
<caption>Non-Attack Spell</caption>
<mustinherit>nonattackspell</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description (optional)</caption>
<attribute>description</attribute>
<mustinherit>nonattackspell</mustinherit>
</control>

<control>
<controltype>script</controltype>
<caption>Spell effect</caption>
<attribute>spelleffect</attribute>
<mustinherit>nonattackspell</mustinherit>
</control>



<control>
<controltype>title</controltype>
<caption>Lasting Spell</caption>
<mustinherit>lastingspell</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description (optional)</caption>
<attribute>description</attribute>
<mustinherit>lastingspell</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Status when active</caption>
<attribute>status</attribute>
<mustinherit>lastingspell</mustinherit>
</control>

<control>
<controltype>script</controltype>
<caption>Spell effect</caption>
<attribute>spelleffect</attribute>
<mustinherit>lastingspell</mustinherit>
</control>

<control>
<controltype>script</controltype>
<caption>Cacel spell effect</caption>
<attribute>terminate</attribute>
<mustinherit>lastingspell</mustinherit>
</control>



<control>
<controltype>title</controltype>
<caption>Attack Spell</caption>
<mustinherit>attackspell</mustinherit>
</control>

<control>
<controltype>number</controltype>
<caption>Power of attack (1-10)</caption>
<attribute>powerrating</attribute>
<width>100</width>
<mustinherit>attackspell</mustinherit>
<minimum>0</minimum>
<maximum>10</maximum>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description (optional)</caption>
<attribute>description</attribute>
<mustinherit>attackspell</mustinherit>
</control>

<control>
<controltype>dropdowntypes</controltype>
<caption>Element</caption>
<types>*=None; fire_type=Fire; frost_type=Frost; storm_type=Storm; earthmight_type=Earthmight; shadow_type=Shadow; rainbow_type=Rainbow; necrotic_type=Necrotic; divine_type=Divine</types>
<width>150</width>
<mustinherit>attackspell</mustinherit>
</control>



<control>
<controltype>title</controltype>
<caption>Monster</caption>
<mustinherit>monster</mustinherit>
</control>

<control>
<controltype>dropdowntypes</controltype>
<caption>Element</caption>
<types>*=None; fire_type=Fire; frost_type=Frost; storm_type=Storm; earthmight_type=Earthmight; shadow_type=Shadow; rainbow_type=Rainbow; necrotic_type=Necrotic; divine_type=Divine</types>
<width>150</width>
<mustinherit>monster</mustinherit>
</control>

<control>
<controltype>number</controltype>
<caption>Hit points</caption>
<attribute>hitpoints</attribute>
<width>100</width>
<mustinherit>monster</mustinherit>
<minimum>0</minimum>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description on injury</caption>
<attribute>hurt</attribute>
<mustinherit>monster</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description on death</caption>
<attribute>death</attribute>
<mustinherit>monster</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description on injury by opposed element</caption>
<attribute>hurtbyelement</attribute>
<mustinherit>monster</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description on death by opposed element</caption>
<attribute>deathbyelement</attribute>
<mustinherit>monster</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Description on ignore</caption>
<attribute>ignoreselement</attribute>
<mustinherit>monster</mustinherit>
</control>

<control>
<controltype>textbox</controltype>
<caption>Look (when dead)</caption>
<attribute>lookwhendead</attribute>
<mustinherit>monster</mustinherit>
</control>

</tab>
</library>