how to work libraries?
onimike
23 Aug 2013, 15:21hey all,
I recently figured out how to input libraries into a game but the problem is the functions they run do not show up and I can't find them so its like adding a blank library what do I do? Please help
This is the code I added clock, journal, and shopping also the combat system but I manually put that code in on the coding view the rest I added to my files then was able to upload them to the game.
I recently figured out how to input libraries into a game but the problem is the functions they run do not show up and I can't find them so its like adding a blank library what do I do? Please help
<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<include ref="Clock_Lib.aslx" />
<include ref="Journal_lib.aslx" />
<include ref="Shopping_lib.aslx" />
<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>
<game name="defender">
<gameid>d153b745-24d8-4ed4-bfae-dd4f85b72cda</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
</game>
<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>
<verb>
<property>attack</property>
<pattern>attack;fight;strike;kill</pattern>
<defaultexpression>"You can't attack " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>equip</property>
<pattern>equip;draw</pattern>
<defaultexpression>"You can't draw " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>unequip</property>
<pattern>unequip;sheathe</pattern>
<defaultexpression>"You can't sheathe " + object.article + "."</defaultexpression>
</verb>
<turnscript name="attacktheplayerturnscript">
<enabled />
<script>
foreach (attacker, element_struct.attackers) {
do (attacker, "attackplayer")
}
</script>
</turnscript>
<object name="element_struct">
<elements type="stringlist">
<value>fire</value>
<value>frost</value>
<value>storm</value>
<value>earthmight</value>
<value>shadow</value>
<value>rainbow</value>
<value>divine</value>
<value>necrotic</value>
</elements>
<opposedelements type="stringdictionary">
<item>
<key>fire</key>
<value>frost</value>
</item>
<item>
<key>frost</key>
<value>fire</value>
</item>
<item>
<key>storm</key>
<value>earthmight</value>
</item>
<item>
<key>earthmight</key>
<value>storm</value>
</item>
<item>
<key>shadow</key>
<value>rainbow</value>
</item>
<item>
<key>rainbow</key>
<value>shadow</value>
</item>
<item>
<key>divine</key>
<value>necrotic</value>
</item>
<item>
<key>necrotic</key>
<value>divine</value>
</item>
</opposedelements>
<attackers type="objectlist"></attackers>
</object>
<object name="fists">
<inherit name="weapon" />
<alias>fist</alias>
</object>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
<type name="spell">
<displayverbs type="stringlist">
<value>Learn</value>
</displayverbs>
<inventoryverbs type="stringlist">
<value>Learn</value>
</inventoryverbs>
<drop type="boolean">false</drop>
<take type="boolean">false</take>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<learn type="script">
if (not this.parent = game.pov) {
this.parent = game.pov
this.inventoryverbs = Split ("Cast", " ")
msg (DynamicTemplate("SpellLearnt", this))
}
else {
msg ("Er, you already know that one!")
}
</learn>
</type>
<type name="attackspell">
<inherit name="spell" />
<cast type="script">
// 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 = game.pov) {
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 ("... No monsters present")
}
CancelSpell
}
else {
msg ("Er, you don't know that one!")
}
</cast>
</type>
<type name="nonattackspell">
<inherit name="spell" />
<cast type="script">
if (this.parent = game.pov) {
DescribeCast (this)
do (this, "spelleffect")
CancelSpell
}
else {
msg ("Er, you don't know that one!")
}
</cast>
</type>
<type name="lastingspell">
<inherit name="spell" />
<cast type="script">
if (this.parent = game.pov) {
DescribeCast (this)
do (this, "spelleffect")
CancelSpell
game.pov.currentspell = this
game.pov.status = this.status
}
else {
msg ("Er, you don't know that one!")
}
</cast>
</type>
<type name="weapon">
<attackbonus type="int">0</attackbonus>
<damagebonus type="int">0</damagebonus>
<damagedicenumber type="int">1</damagedicenumber>
<damagedicesides type="int">4</damagedicesides>
<take />
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Drop</value>
<value>Equip</value>
</inventoryverbs>
<equip type="script">
if (this.parent = game.pov) {
if (not game.pov.equipped = fists and not game.pov.equipped = null) {
msg ("You put away your " + game.pov.equipped.alias + " and draw your " + this.alias + ".")
}
else {
msg ("You draw your " + this.alias + ".")
}
game.pov.equipped = this
this.inventoryverbs = Split ("Look at;Drop;Unequip", ";")
game.pov.equippedstatus = "Wielding: " + this.alias
}
else {
msg ("You don't have it.")
}
</equip>
<unequip type="script">
if (this.parent = game.pov) {
msg ("You put away your " + game.pov.equipped.alias + ".")
game.pov.equipped = fists
this.inventoryverbs = Split ("Look at;Drop;Equip", ";")
game.pov.equippedstatus = "Wielding: nothing"
}
else {
msg ("You don't have it.")
}
</unequip>
</type>
<type name="fire_type" />
<type name="frost_type" />
<type name="storm_type" />
<type name="earthmight_type" />
<type name="shadow_type" />
<type name="rainbow_type" />
<type name="divine_type" />
<type name="necrotic_type" />
<type name="monster">
<inherit name="weapon" />
<defence type="int">0</defence>
<armour type="int">0</armour>
<hitpoints type="int">10</hitpoints>
<take type="boolean">false</take>
<displayverbs type="stringlist">
<value>Look at</value>
<value>Attack</value>
</displayverbs>
<makedead type="script">
if (not GetBoolean (this, "dead")) {
this.alias = this.alias + " (dead)"
if (HasString (this, "lookwhendead")) {
monster.look = this.lookwhendead
}
else {
this.look = this.look + " Oh, and it is dead."
}
this.dead = True
list remove (element_struct.attackers, this)
}
</makedead>
<attack type="script"><![CDATA[
if (not HasAttribute (game.pov, "equipped")) {
game.pov.equipped = fists
}
do (this, "settoattack")
attackroll = GetRandomInt (1, 20) - this.defence + game.pov.attack
attackroll = attackroll + game.pov.equipped.attackbonus
if (attackroll > 10) {
damage = game.pov.equipped.damagebonus
for (i, 1, game.pov.equipped.damagedicenumber) {
damage = damage + GetRandomInt (1, game.pov.equipped.damagedicesides) - this.armour
}
this.hitpoints = this.hitpoints - damage
if (this.hitpoints > 0) {
msg ("You swing " + game.pov.equipped.alias + " and hit, doing " + damage + " points of damage; " + this.hurt)
}
else {
msg ("You swing your " + game.pov.equipped.alias + " and hit, doing " + damage + " points of damage; " + this.death)
do (this, "makedead")
}
}
else {
msg ("You swing your " + game.pov.equipped.alias + " and miss.")
}
]]></attack>
<attackplayer type="script"><![CDATA[
attackroll = GetRandomInt (1, 20) - game.pov.defence + this.attackbonus
if (attackroll > 10) {
damage = this.damagebonus
for (i, 1, this.damagedicenumber) {
damage = damage + GetRandomInt (1, this.damagedicesides) - game.pov.armour
}
game.pov.hitpoints = game.pov.hitpoints - damage
msg (this.alias + " swings at you and hits, doing " + damage + " points of damage.")
if (this.hitpoints <= 0) {
msg ("You are dead!")
finish
}
}
else {
msg (this.alias + " swings at you and misses.")
}
]]></attackplayer>
<settoattack type="script">
if (not ListContains (element_struct.attackers, this) and not GetBoolean (this, "dead")) {
list add (element_struct.attackers, this)
}
</settoattack>
</type>
<type name="monsterarcher">
<inherit name="monster" />
<attackplayer type="script"><![CDATA[
attackroll = GetRandomInt (1, 20) - game.pov.defence + this.attackbonus
if (attackroll > 10) {
damage = this.damagebonus
for (i, 1, this.damagedicenumber) {
damage = damage + GetRandomInt (1, this.damagedicesides) - game.pov.armour
}
game.pov.hitpoints = game.pov.hitpoints - damage
msg (this.alias + " shoots an arrow at you and hits, doing " + damage + " points of damage.")
if (this.hitpoints <= 0) {
msg ("You are dead!")
finish
}
}
else {
msg (this.alias + " shoots an arrow at you and misses.")
}
]]></attackplayer>
</type>
<function name="SpellAttackMonster" parameters="monster, spell"><![CDATA[
do (monster, "settoattack")
element = GetElement (monster)
handled = False
if (not element = Null) {
if (DoesInherit (spell, element + "_type")) {
msg ("... " + monster.ignoreselement)
handled = True
}
msg ("looking for " + element)
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)
do (monster, "makedead")
}
}
}
if (not handled) {
monster.hitpoints = monster.hitpoints - spell.powerrating
if (monster.hitpoints > 0) {
msg ("... " + monster.hurt)
}
else {
msg ("... " + monster.death)
do (monster, "makedead")
}
}
]]></function>
<function name="CancelSpell">
if (HasObject (game.pov, "currentspell")) {
spell = game.pov.currentspell
msg (DynamicTemplate("SpellEnds", spell))
game.pov.currentspell = null
if (HasScript (spell, "terminate")) {
do (spell, "terminate")
}
}
</function>
<function name="GetElement" parameters="obj" type="string">
result = Null
foreach (element, element_struct.elements) {
type = element + "_type"
if (DoesInherit (obj, type)) {
result = element
}
}
return (result)
</function>
<function name="DescribeCast" parameters="spell">
if (HasString (spell, "description")) {
msg (DynamicTemplate("SpellCast", spell) + " " + spell.description)
}
else {
msg (DynamicTemplate("SpellCast", spell))
}
</function>
</asl>
This is the code I added clock, journal, and shopping also the combat system but I manually put that code in on the coding view the rest I added to my files then was able to upload them to the game.

jaynabonne
23 Aug 2013, 19:29Some questions:
1) I assume the library files are in the same folder as your game file?
2) Are you running this locally or on the server? (Are you even running it?)
3) What do you mean they do not show up? If you are talking about the editor, then you need to go to the Filter (bottom left) and then "Show Library Elements". If you mean you're getting a run time error because a function is not available, then what is the error?
1) I assume the library files are in the same folder as your game file?
2) Are you running this locally or on the server? (Are you even running it?)
3) What do you mean they do not show up? If you are talking about the editor, then you need to go to the Filter (bottom left) and then "Show Library Elements". If you mean you're getting a run time error because a function is not available, then what is the error?
onimike
23 Aug 2013, 20:31jaynabonne wrote:Some questions:
1) I assume the library files are in the same folder as your game file?
2) Are you running this locally or on the server? (Are you even running it?)
3) What do you mean they do not show up? If you are talking about the editor, then you need to go to the Filter (bottom left) and then "Show Library Elements". If you mean you're getting a run time error because a function is not available, then what is the error?
Thanks jay showing libraries did the trick.
Mike
HegemonKhan
24 Aug 2013, 04:11My apologies, I forgot to mention that bit, I forget that the button (Filter -> Show Library Elements) shows ALL libraries, and mistakenly think that the button is only for the core~default (Core+English) libraries, argh. my bad onimike!