Checking "light" status moving between rooms

ken412
14 Feb 2014, 11:12
Hello all,

Years ago I wrote an IF game on an IBM mainframe in REXX to run in a TSO/ISPF environment. I've recently been asked if I can recreate the game for a web environment for a wider audiance. I have just found QUEST which looks like it could be the tool I need to prepare the game. I have not started the game yet, but think I might have come across a show-stopping problem whilst reading the documentation and looking through this forum. A very key feature to the game is "light". At the start it is daylight and all rooms will be lit by default. But after a fixed number of turns I want it to become night, where many (not all) rooms will become dark. The player must have found a light-source by then. If the player moves from one room to another room and BOTH rooms are "dark" then the player dies. So I need the "move" routine to be able to tell if:
1) the room the player is in is a light source itself
2) an object in the room is a light source
3) an object the player is carrying is a light source
4) the room the player is moving to is a light source
5) the room the player is moving to contains a light source.
If any condition is true the move is allowed, but if ALL are false the player will be killed off.
I have read that the "current room" can be tested for a light source, and I think it is possible to check if it contains a light source. But I'm not sure if it is possible to tell if an object the player is carrying (i.e. in the inventory) is a light source. More importantly have not read anything that looks like a way that will tell me if the "next room" is; or contains; a light source.
Before I start on the writing the game, can someone tell me if all this is possible or not? "Light" is very key to several puzzles in the game plan.

Sorry if this happens to be a very basic question, but I have only discovered QUEST yesterday and haven't even started a game yet.
Thanks in anticipation of your support :-)
Ken

HegemonKhan
14 Feb 2014, 12:26
yes, this can be done with quest.

Are you familiar with coding in general? (if not, let me know, and I'll help you through the GUI~Editor or through the Coding)

1. http://quest5.net/wiki/Category:All_Fun ... t_Commands (page 1, range: A-S)
2. http://quest5.net/w/index.php?title=Cat ... h#mw-pages (page 2, range: S-Z)

---------

this allows us to set the scripts that happen, for when the player changes rooms:

<attr name="changedparent" type="script">your_various_scripts</attr>

<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<attr name="changedparent" type="script">
// your various scripts here
</attr>
</object>


here's our game turns:

<game name="whatever">
// blah code lines
<attr name="turns" type="int">0</attr>
< attr name="changedturns" type="Script">
// scripting for changing day~night attributes
</attr>
<attr name="statusattributes" type="simplestringdictionary">turns = Turns: !</attr>
// blah code lines
</game>

<turnscript name="global_turn_script">
<attr name="enabled" type="boolean">true</attr>
<script>
game.turns = game.turns + 1
</script>
</turnscript>


the darkness~light scripts~functions~attributes:

http://quest5.net/wiki/SetDark
http://quest5.net/wiki/SetLight
http://quest5.net/wiki/SetObjectLightstrength
http://quest5.net/wiki/SetExitLightstrength
http://quest5.net/wiki/Dark
http://quest5.net/wiki/Darklevel
http://quest5.net/wiki/Lightstrength

this allows you to get all the child (sub) objects within their parent objects:

http://quest5.net/wiki/ScopeInventory
http://quest5.net/wiki/ScopeExitsForRoom
http://quest5.net/wiki/Foreach
http://quest5.net/wiki/AllObjects
http://quest5.net/wiki/AllExits
http://quest5.net/wiki/ScopeExits
http://quest5.net/wiki/ScopeReachableForRoom
http://quest5.net/wiki/ScopeReachable
http://quest5.net/wiki/ScopeReachableNotHeld
(etc scopes...)
http://quest5.net/wiki/GetAllChildObjects
http://quest5.net/wiki/GetDirectChildren

etc stuff (checking for darkness~light manually):

http://quest5.net/wiki/HasBoolean
http://quest5.net/wiki/HasAttribute
http://quest5.net/wiki/HasString

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

checking a room that you're not in, which you plan to move to, is a bit more complex... you could do it with commands, if you don't mind typing in where you want to go in your game design, otherwise, it's a bit beyond my ability, you'll need to get some one else's help, to work with the default exiting moving aspect...

---------

basically briefly, one way to do it, is like this (conceptual only and quasi code):

<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<attr name="changedparent" type="script" parameters="current_location,desired_destination">
if (HasBoolean (current_location, "light") or HasBoolean (desired_destination, "light") or HasBoolean (player, "light")) {
// you don't die
} else {
foreach (player_object_x, ScopeInventory) {
if (HasBoolean (player_object_x, "light")) {
// you don't die
} else {
room_objects_list = GetAllChildObjects (desired_destination)
foreach (room_object_x, room_objects_list) {
if (HasBoolean (room_object_x, "light") {
// you don't die
}
}
}
}
}
</attr>
</object>


the scripting for the "changedparent", can be used elsewhere (in other scripting), as it (the "changedparent" script) requires for the player to have moved rooms, which conflicts with the scripting, as it uses "desired_destination".

Pertex
14 Feb 2014, 14:23
Here is an example how to do it

ken412
14 Feb 2014, 14:38
@HegemonKhan and Pertex,

Wow, Thanks for the rapid reply chaps! And such a detailed responses as well, thank you very much.

My profession for many years was a mainframe systems programmer, but I have done some "real" programming over the years. I am proficient in REXX (looks a bit like BASIC), but only dabbled in C+ years ago. I also hand-code HTML (since 1995) and have been teaching myself a little JavaScript and PHP in recent years, though only enough to do what I need, so I wouldn't consider myself anything like an expert in either.

I was hoping to use the GUI functions of QUEST. I've watched the video tutorial and understand the GUI (I think! :-)) But I haven't got going yet, so don't yet know how to get into the native code to start with the coding solutions you have provided. It all looks rather like XML to me, which I haven't really used before, but I do understand the structure (not that far from HTML of course).

So you have both given me a lot to take in here, thank you, and I will see what I can do with all this information now.

So I guess that means I don't have an excuse to get started....! :-)

Thanks again,
Ken

HegemonKhan
14 Feb 2014, 19:54
let us know if you need help, you can download pertex' game file, and open it up into the GUI~Editor mode, to see how it looks (is done) in~via the GUI~Editor.

------

Explaining how to do things through~via the GUI~Editor is much more work, than simply writing, copying, and pasting it in code, laughs, so if you want it shown step by step through using the GUI~Editor, it'll take me a lot more time to do (as I'm also very new to coding myself, I actually started knowing ZERO about coding, but thanks to Alex' Quest program and his coding language, and all the excellent resources and help here, I've been able to slowly learn some basic "coding" for over a year now at this, trying to branch out a bit into the most basic programming that I knew of, a computer's command line prompt, lol, but it's slow. I hope to eventually expand out to the other and real programming languages eventually, though I'm still trying to learn how to code and understand the general coding logic and tactics, mainly in terms of doing so towards making an RPG, but it's slow as it is more limited and frustrating than quest's language, as I have a hard time grasping this totally new stuff and ways of thinking, but I'm making some progress! :D For example, I'm glad for quest's use of "lists" and "dictionaries", as *I think* these do the same functionality as "arrays", which totally confuse me, whereas I mostly understand fully with in using "lists" and "dictionaries" now, lol, heh :D )

-------

what pertex is doing conceptually (if I understand it myself) is setting a current room and a previous room, checking if they're both dark (by matching texts, including the dark~light state of the room), and if they are, then you die. Though this requires you to move to the new room (not sure if this matters actually in terms of playing the game ~ game design, verses using more fancy coding to get the desired destination's room dark~light level~state before you move to it ~ ie: before you're now within that new room).

-------

if you want to work with the code, there's two ways to get at it:

1. simply opening up the file with notepad, wordpad, notepad++ ( http://notepad-plus-plus.org/ ), or whatever else there is (being a programmer, you may know of and~or have a more advanced program than notepad++, I use notepad++ as it's free and quite good enough for me for my level, if you use notepad++, select "XML" for it's code language to use)

game files' name+extension (replace the asterisks with what you want to name the file as):

*.aslx

game files' code tags:

<asl version="whatever quest version you're using, ie for me still: 540">
// your massive game coding, lol
</asl>


library files' name+extension:

*.aslx

library files' code tags:

<library>
// your massive coding, lol
</library>


within a game file (it remains only within scripting, scripts ~ functions ~ commands ~ etc, only) comment code:

// your comments

within a library file:

// your comments

~and~

<!-- label ~ comments -->

~or~

<!--
comments
-->

2. within the GUI~Editor mode, at the top horizontal menu bar, there's a notepaper-like button, between the "play" and "?~help" buttons, this notepaper-like button is a toggle, to switch between the GUI~Editor mode and Code View (in-code) mode.

---------

I will try to help you, but I'm still not familiar with the coding for light~dark yet, nor am I that good at programming, so use Pertex' help, if he's willing, as he's a very good programmer, or the other mods (they too are all good programmers), or some of the members, who're good programmers. I can try to help myself, but I'll be fumbling along at it, doing it messily compared to one who knows programming well, if I can even do it myself, lol, and so it'll be harder for you to understand too if I were to help, because of that (me being still new to coding).

----------

Resources:

(if any links don't work, it's likely that the ending ")" got cut off when pasting this here ~ not sure why this happens, lol, so just add that back into the url to fix it)

01. index.php (this site's main page)
02. viewforum.php?f=10 (the site's forum, what we're on right now, lol)
03. viewforum.php?f=18 (the site's library board)
04. http://quest5.net/wiki/Main_Page
05. http://quest5.net/wiki/Tutorial
06. http://quest5.net/wiki/How_to
07. http://quest5.net/wiki/Libraries
08. http://quest5.net/wiki/Category:All_Fun ... t_Commands (page 1, range: A-S)
09. http://quest5.net/w/index.php?title=Cat ... h#mw-pages (page 2, range: S-Z)
10. http://quest5.net/wiki/Object_element
11. http://quest5.net/wiki/Attribute_Types
12. viewforum.php?f=15 (the site's quest software developer board)
13. viewforum.php?f=20 (IF and Game Design board of this site)
14. http://quest5.net/wiki/Upgrade_Notes (very useful for converting older versions coding syntax~format to newer versions coding syntax~format)

enjoy :D

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

also, I'd recommend that you actually go through the entire tutorial yourself (actually within your own game file using the GUI~Editor, trying to do the tutorial's contents), as I'm sure you know, reading~watching something doesn't translate into actually trying to do it yourself, practice at actually using the GUI~Editor.

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

I myself, moved off of using the GUI~Editor quickly, as I found that I was able to work with the code and understand it more quickly then I could figure out how to do more advanced stuff through the GUI~Editor (there's so many pull downs and options, that it was hard for me to find them and~or understood what they did, and~or how to use them together to get what I needed, compared to simply doing it on~in code), you can do I think mostly everything in the GUI~Editor that you can directly in code, but for me, I like (as I was better at) simply using the direct coding instead. Though, without the GUI~Editor and the tutorial, I've never have been able to grasp the coding, it allowed me to understand coding and to move into using the coding directly.

~ I also WANTED to learn to code finally (I wish I had started when I was very young, sighs. I could've been Bill Gates or created google, ... RIGHT... I wish... heh), lol, so that's a huge part of why I moved off of using the GUI~Editor too... lol.

(stupid U.S. school system... practically zero tech classes... liberal arts ~ huge waste of time ~ life ~ mostly not geared much towards getting jobs ~ making a living-salary, especially today, which has gone tech ~ our modern world. seriously, you need to know programming easily as much as even math and science, let alone all the other useless other liberal arts classes we had to take... knowledge is nice, but we need to live ~ survival ~ make money, as few of us have rich parents or are born into rich carreers: movie stars or other professional entertainers - athletes - musicians - etc, the actual real world outside of the elitist education~university~professors~government~school utopia bubbles... sighs. Behind everything we love or have, is tech, IT, programming, our modern world is only possible through programming, as our just robots that build cars, requires programming, for just a single example of just of Automation alone, nothing could exist in the modern world that we have and enjoy, without programmers! All engineering, requires computer modeling programs, which requires programming and programers!)

The GUI~Editor is very good, I just personally found it "easier" (I got A LOT to learn) for myself to directly code in the stuff.

ken412
16 Feb 2014, 15:27
Hi HegemonKhan

I have downloaded the (Windows) version, and am working through the tutorials (just as you also suggested). These are very useful. Having downloaded the application has allowed me to find the "notepad" icon to take me directly to the code. I've also downloaded Pertex's example file and used that. It does indeed show the workings of moving between light and dark rooms. I'm sure given time I will be able to expand that to include light sources in the rooms and being carried. But now I have an excellent start (many thanks Pertex :-) ) FYI: The suggestion of "moving" to the net room will actually work for me, because if the two rooms are dark, then the player is killed off anyway, so it doesn't matter whether the move actually took place or not, and if there is any light, then the player will be allowed to move. So win-win here for me. I can see other people may want a different solution if they want to force the player to stay in the same room.

I also use Notepadd++ and it is fine for my needs, so I'm comfortable working with that and I'm sure I will become comfortable working within QUEST.

Thank you for the basics in structuring a game. I'm sure I will pick things up as I continue. I don't mind working in code. I just don't know the code structure yet, so going by all the QUEST "advertising" of how the GUI makes things easy, I thought I would start there. But having a bit of a programming background I'm also happy to work in code format. This XML programming format is new to me though, but like yourself, I'm sure I will pick it up as I go along. And if that also makes it easier to help others, I'm more than happy to use this method.

Once I've finished the tutorials and sample game I will make a start. I already have other coding problems I will need to solve within QUEST, like I want to give a "long" room listing the first time a room is visited, but only a "short" description if the player returns, but having a verb of "LOOK" to display the long description again, and in other rooms (effectively a "maze") where a room exit may return to the same room , but I still want the engine to give the description (so it is not obvious the player is still in the same room). But I will have a go at solving these coding problems myself once I understand the code format and engine a bit better. If I get stuck, I will return to the forum, where I now know there is an active community and people like yourself and Pertex willing to pass on their experience. One day I hope to have gained enough knowledge and skill within QUEST to pass on some of my own! But a long way to go yet! :-)

The concept of libraries is interesting. I will have to understand these better. I see there is a section on these in the tutorials.

Thanks again.

ken412
16 Feb 2014, 17:42
Actually I have just found that jaynabonne and yourself have already answered a question from cybernetsurfer7 about different descriptions for first time or revisiting a room. That was useful, thanks. I just need to alter the "LOOK" script to force the room to be "Not visited" so the long description is used with look. But it is becoming obvious I can override many default actions, if I know how.

A thought strikes me. If I want all rooms to have both a long (first time) and short (re-visit) description, is it possible to alter the template for a room to have two boxes for descriptions, then alter the default room description script to display the appropriate one, so I don't have to add the code (as described in cybernetsurfer7's solution) to every room description? I'm assuming this would be via a "template" or is that wrong? I'd also need to alter the default action of the "LOOK" verb somehow?

HegemonKhan
17 Feb 2014, 00:28
you can simply copy and paste any code posted into a game file (and save), then switch to the GUI~Editor mode, to see how it is done through the editor (GUI), though it is a bit time-consuming and the GUI~Editor doesn't intuitively match up well with how it is syntaxed~formated (done) in code, lol. It's a lot of work learning to match up coding with the editor's style... at least it was for me... (see example directly below)

for example:

in code:

as tag creation:

<object name="orc">
-> <inherit name="editor_object" />
-> <attr name="dead" type="boolean">false</attr>
</object>

or in scripting creation:

orc.dead = false

and then to change it (via scripting):

orc.dead = true

to change it back (via scripting):

orc.dead = false

whereas, in GUI~Editor:

to create it via an attribute of an object:

"orc" (Object) -> Attributes (Tab) -> Attributes -> Add ->

Attribute Name: dead
Attribute Type: boolean
Attribute Value: false

to create it (via scripting):

Run as script -> Add a script -> Variables -> Set a variable or attribute -> orc.dead=false

to change it:

Run as script -> Add a script -> ??? (whatever it's category, 'Objects', I think) -> SetObjectFlagOn -> (set it up)

to change it back:

Run as script -> Add a script -> ??? (whatever it's category, 'Objects', I think) -> SetObjectFlagOff -> (set it up)

---------

I'm more than willing to guide with with using the GUI~Editor, if you don't want to work with code, but the main problem is time, as it takes more work~time to write out explanations and step by step instructions in using the GUI~Editor, vs just pasting in code, lol, and unfortunately, I am busy with real life, so if you don't mind to wait for when I got the time, I'd gladly help you with doing things in the GUI~Editor, when I got the time for doing it.

until then, (or until others are able to help you), the main sources of GUI~Editor help (with nice pictures of it too) are:

the tutorial ( http://quest5.net/wiki/Tutorial )
the wiki guides ( http://quest5.net/wiki/How_to )
and some of the libraries ( viewforum.php?f=18 )

though, it is a bit more limited, compared to the amount of coding help that exists.

----------

oh indeed, learning a new language is not easy, as you're used to the old format, and when you learn the new language, then you'll have a new problem of mxing up the two languages, not remembering what syntax~format goes with which language, lol.

however, quest's language is really noobie-friendly, so you should be able to pick it up quickly in-of-itself, though it does take time to adjust to any new language.

http://quest5.net/wiki/Category:ASLX_Elements
http://quest5.net/wiki/ASLX_Elements

the various elements:

Objects, Exits, Verbs, Commands, Timers, Turnscripts, Functions, Game, Object Type ( it's shortened in the tags to just: <type name="blah">attributes</type> ) (grouping~inheritance), Templates, Libraries, Walkthroughs, etc

basically, you do this (ignoring the optional attributes):

(can be written horizontally or vertically)

The Elements:

<object name="blah">attributes</object>
<verb name="blah">scripting</verb>
<command name="blah">scripting</command>
<type name="blah">attributes</type> // <type> is short for: Object Type
<turnscript name="blah">scripting</turnscript>
<timer name="blah">scripting</timer>
<function name="blah">scripting</function>
<exit name="blah">attributes</exit>
<attr name="blah" type="blah">values</attr>

attr = Attribute

The Attributes:

int = integer
boolean = specifically in terms of quest's coding usage, just "true~false" flags

coding conceptuality (no "flag" element~attribute actually exists, you create effect by~via scripting): 'flags' are binary: 0~1 and more expansively, dualism: 5~10, on~off, yes~no, in~out, up~down, hot~cold, red~blue, etc ~ aka: only two options~settings

(these are just custom ones, using my own labeling system~structure, for examples)

<object name="HK">
<attr name="parent" type="object">room</attr>
<attr name="gender_string" type="string">male</attr>
<attr name="strength_integer" type="int">0</attr>
<attr name="dead_boolean" type="boolean">false</attr>
<attr name="damage_double" type="double">156.84</attr>
<attr name="favorite_colors_string_list" type="simplestringlist">black;red</attr>
<attr name="clothes_object_list" type="objectlist">shirt;socks;shoes;pants</attr>
<attr name="fight_script" type="script"><![CDATA[
if (HK.dead_boolean=true) {
msg ("He's already dead, silly!")
} else if (HK.dead_boolean=false) {
player.hp = player.hp - HK.damage_double
msg ("HK attacked you.")
if (player.hp <= 0) {
finish // this ends the game
} else {
HK.hp = HK.hp - player.damage_double
msg ("You attack HK, ... (but you can NEVER kill him, muwahaha!)")
if (HK.hp <= 0) {
HK.dead_boolean=true
}
}
}
]]></attr>
// etc attribute types
</object>


-----------

there's a few ways to do different outcomes:

1. firsttime~otherwise script ( http://quest5.net/wiki/Firsttime and http://quest5.net/wiki/Otherwise )
2. the built-in boolean attribute: "visited" (only for "type: room" Objects though, I think...)
3. basic "if coding" or just "coding": your own flag effect of scripting, a simple example below:

game.count = 5

if (game.count = 5) {
-> msg ("hi")
-> game.count = 10
} else if (game.count = 10) {
-> msg ("bye")
-> game.count = 5
}

the "Value" (5,10,red,blue, etc) doesn't matter, if you only have two outcomes, than only two options~settings are needed, for another example:

game.count = red

if (game.count = "red") {
-> msg ("hi")
-> game.count = "blue"
} else if (game.count = "blue") {
-> msg ("bye")
-> game.count = "red"
}

the built-in boolean attribute:

room.visited = true

if (room.visited = false) {
-> msg ("hi")
-> room.visited = true
} else if (room.visited = true) {
-> msg ("bye")
-> room.visisted = false
}

using the "firsttime~otherwise" script~function (it probably does and uses the same thing~method as above for you ~ it probably changes~resets the built-in "visited" boolean attribute between "true" and "false"):

firsttime {
-> msg ("hi")
} otherwise {
-> msg ("bye")
}

----------

the simpliest method is using the "firsttime~otherwise" script:

<object name="room">
<inherit name="editor_room" />
<inherit name="editor_object" />
<attr name="look at" type="script"> // I believe this built in script attribute, is the 'room description', but I'm not exactly sure how the GUI~Editor works, as there's also the "onenterroom" or "onenterroomfirsttime" (a possible option too if it exists ~ can't remember off top of my head) and etc 'room description' scripts...
firsttime {
msg ("a long room description of all the scenery and etc stuff")
} otherwise {
msg ("a shorter description, without all the fluff")
}
</attr>
</object>


-----------

ken wrote:A thought strikes me. If I want all rooms to have both a long (first time) and short (re-visit) description, is it possible to alter the template for a room to have two boxes for descriptions, then alter the default room description script to display the appropriate one, so I don't have to add the code (as described in cybernetsurfer7's solution) to every room description? I'm assuming this would be via a "template" or is that wrong? I'd also need to alter the default action of the "LOOK" verb somehow?


"Templates" are more for responses (messages ~ msg), if you want to change the default or error_exception response, or it also makes it easier to translate the game into another (speaking, not programming lol) language (of font used), as they can be used as a 'called upon' (like you do with functions) or "invoke" (for scripts), but for a response (msg), instead.

however, what you want, is achieved by changing the scripting (script or function) itself of the built-in "room description" or "look at" scripts~functions, which can be done by:

an example:

Filter -> Show Library Objects~Elements (whatever it is called) (so it is toggled "on" obviously)

(Verb) eat (greyed font~text) -> copy -> alter it as you want

you can see all the built-in stuff by just clicking on "filter" to bring up the toggle button "show library objects~elements" within the GUI~Editor:

New Game's "Tree of Stuff":

Objects
Game
Verbs
Commands
Room
Player
Functions
Timers
Walkthrough
Advanced
Included Libraries
English.aslx
Core.aslx
Templates
Dynamic Templates
Object Types
Javascript
Filter -> Show Library Objects~elements (whatever it is)



***** AND *****


you can then alter~change these default built-in stuff by click on it (the light grey font'ed things) in the "tree of stuff" (so that it is highlighted) allowing you to see the coding of it and also to change it (via the "change" button in the upper right),

THOUGH do understand that these are global changes to the built-in stuff, which the underlying coding uses too, so be careful, as you may not want the global effect or it might cause the underlying code to not be able to work with your changes to these built-in things.

HOWEVER, by doing it this way, the quest engine is protected, as you're copying it, making changes to the copy, and thus not messing up the actual quest engine of coding (though your specific game file may not work because of your changes ~ but you don't have to re-download the quest program~software)

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

quest itself uses a default of two libraries (codings):

Core.aslx
English.aslx

(see the ' <include ref="blah" /> ' below)

<!-- New Game Code -->

<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>2014</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>


which makes it easy to add more libraries (codings) too:

<asl version="540">
<include ref="English.aslx"/>
<include ref="Core.aslx"/>
<include ref="Chase's Wearables Library File.aslx" />
<include ref="Pixie's Spell Library File.aslx" />
// etc library files
<game name="Testing Game Stuff">
<gameid>d67ec73f-f879-4911-9d88-c02ea527c534</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>


heck, let's completely re-customize quest, lol:

<asl version="540">
<include ref="English.aslx"/>
<include ref="HK's New Core (haha maybe 50 years later I'd have this coding ability lol) Library File.aslx"/>
// it's architecture is completely different, HK's own creation... my long long long term programming goal... lol
</asl>


so literally, libraries are "patches", "expansion packs", or even "the quest source~core code itself" of code (adds, changes, or removes code) that can be added to quest. Alex made quest extremely (easily) customizable for those good at programming.

libraries can be extremly simple, adding a single object to a game, or it can literally be a totally new source~engine code, lol.

I believe in the programming world, libraries are like your "data files" ???

aka:

actor(PCs~NPCs)_data_file
physics_data_file
media_data_file
game_mechanics_data_file
objects(NON-PCs~NON-NPCs)_data_file
scripts~events~flags_data_file
and etc data files

which are combined (or called upon) from a single: global data file or *.exe game file

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

here's an example of a library, and also how works and what are "templates":

Pixie's Spell Library:

<?xml version="1.0"?>
<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>

ken412
25 Feb 2014, 17:52
Sorry, I've not had an opportunity to come back to this for a while.

Many thanks for all the information. I am more than happy to deal with the code rather than the GUI, now that i have started to get into it and use it for a little bit. The code is much easier to describe here, for sure. You have given me plenty to look into now, and I'll try to find time to do more on this project.

Yes, my meaning of "template" comes from my web-building background. I now understand what a "template" in QUEST is now, and also how it makes it very customisable.

Okay, back to the code, and thanks again.

HegemonKhan
25 Feb 2014, 20:14
While I don't know what templates are in web building, I'm going to take a guess anyways, and mention about:

Object Types (shortened to "Types") are like "groups~groupings", a "Type basket" holding a bunch of "Attribute eggs"

<type name="blah">
-> // your attributes
</type>

<type name="character_object_type">
-> <attr name="strength_integer" type="int">0</attr>
-> <attr name="endurance_integer" type="int">0</attr>
-> <attr name="dexterity_integer" type="int">0</attr>
-> <attr name="agility_integer" type="int">0</attr>
-> <attr name="speed_integer" type="int">0</attr>
-> <attr name="piety_integer" type="int">0</attr>
-> <attr name="intelligence_integer" type="int">0</attr>
-> <attr name="spirituality_integer" type="int">0</attr>
-> <attr name="mentality_integer" type="int">0</attr>
-> <attr name="luck_integer" type="int">0</attr>
</type>

<object name="HK">
-> <inherited name="editor_object" />
-> <inherited name="character_object_type" />
</object>

<object name="orc">
-> <inherited name="editor_object" />
-> <inherited name="character_object_type" />
</object>

http://quest5.net/wiki/Types
http://quest5.net/wiki/Type_element
http://quest5.net/wiki/Inherit_element
http://quest5.net/wiki/Using_inherited_types
http://quest5.net/wiki/Using_Types
http://quest5.net/wiki/Using_Types_and_Tabs_(Advanced) ~ add the ")" in the url for it to work ~ maybe as a web builder you might know why this, the ")", gets cut off when within a post, as can be seen with this post, lol

but, do note, that there's a bit of an issue with using Object Types, with trying to alter an inherited (from the Object Type) Attribute. I however don't know all the details~pecularities about this though myself.