How do I comment my code?
imamy
20 Jul 2013, 13:13Is there a way to insert a comment or leave notes between the scripts?
Thanks.
Thanks.
imamy
20 Jul 2013, 13:29Oops, I know how to comment. Somehow I missed the comment option when I was looking at "add new script" (even though that was the first option).
HegemonKhan
21 Jul 2013, 03:24for in-code, for a Library File:
// (your comments)
or
<!-- (your comments) -->
or
<!--
(your comments)
-->
I think only the " // (your comments) " remains for within the GUI~Editor and Code View mode, of~for your Game File though.
------------
if you mean having a message in-during actual game play, then it's simply:
in code: msg ("your_message")
in GUI~Editor: Add a~new script -> Output -> Print a message -> [TEXT] for just a written message ~OR~ [EXPRESSION] for a script or a scripting message.
// (your comments)
or
<!-- (your comments) -->
or
<!--
(your comments)
-->
I think only the " // (your comments) " remains for within the GUI~Editor and Code View mode, of~for your Game File though.
------------
if you mean having a message in-during actual game play, then it's simply:
in code: msg ("your_message")
in GUI~Editor: Add a~new script -> Output -> Print a message -> [TEXT] for just a written message ~OR~ [EXPRESSION] for a script or a scripting message.
sgreig
21 Jul 2013, 07:35It's probably worth clarifying that the double slash is for single line comments only. If the comments need to be longer than one line, use the others. As such:
Technically you could also just put a double slash at the beginning of each line, but we're talking best practice here. I just thought I'd chime in and mention this so people can learn when it's appropriate to use which method of commenting. And now back to your regularly scheduled programming.
// This is a single line comment.
<!--
This is a multi-line comment.
If you tried to do this with a single slash it would generate an error.
-->
Technically you could also just put a double slash at the beginning of each line, but we're talking best practice here. I just thought I'd chime in and mention this so people can learn when it's appropriate to use which method of commenting. And now back to your regularly scheduled programming.

jaynabonne
21 Jul 2013, 09:25A few more comments about this:
1) Quest will strip out <!-- --> style comments in your main game file. If you are using libraries, you can use them safely.
2) The "comment" script command turns into the // style of comment. Those are preserved by Quest in all cases.
3) Note that if you are in code view, you can only use the // style of comment within script blocks. Outside of script blocks, it's not valid XML. (So basically, in your main game file, you can't have comments outside of code. For libraries you can, using the XML style of comment.)
1) Quest will strip out <!-- --> style comments in your main game file. If you are using libraries, you can use them safely.
2) The "comment" script command turns into the // style of comment. Those are preserved by Quest in all cases.
3) Note that if you are in code view, you can only use the // style of comment within script blocks. Outside of script blocks, it's not valid XML. (So basically, in your main game file, you can't have comments outside of code. For libraries you can, using the XML style of comment.)
imamy
29 Jul 2013, 01:09Thank you all for your help. I really appreciate all the tips. I wanted the comments to break up my script so I could read it more easily and now I have several ways of doing this!
HegemonKhan
31 Jul 2013, 04:31ah, just to recap along with the other's info that I was lacking:
use (refencing what rules the others said ~ must be done in a script block and limited to one line), as this doesn't get removed:
also, libraries seem complicated at first, but just think of them as like "patches" or "expansion packs" to a game (if you're a gamer, this analogy should make sense).
a library file is simply a way of adding extra code (which can add new code, change code, or remove code) to a game.
while, you probably won't be working with adding libraries to your games for now, making a library file is easy:
and then just make the file have this (same as quest's game files) extension: *.aslx (for example: HK_RPG_LIBRARY_FILE.aslx)
whereas, a Game File, looks like this (using the same extension: *.aslx, for example: HK_RPG_GAME_FILE.aslx):
also, this is a wonderful software-program for if~when you're ready to work with code:
http://notepad-plus-plus.org/
just set the language (after you got it open~up~running) to XML
this is really nice as it provides color coding, making it much easier to write and trouble shoot errors in your code.
--------
P.S.
here's the full default (new game) coding:
these are quest's default library files ("ref" = referenced ~added~ library files):
<include ref="English.aslx" /> // provides the language being used as english
<include ref="Core.aslx" /> // this is Quest's Core Coding
which you can see below:
use (refencing what rules the others said ~ must be done in a script block and limited to one line), as this doesn't get removed:
// your_comment
also, libraries seem complicated at first, but just think of them as like "patches" or "expansion packs" to a game (if you're a gamer, this analogy should make sense).
a library file is simply a way of adding extra code (which can add new code, change code, or remove code) to a game.
while, you probably won't be working with adding libraries to your games for now, making a library file is easy:
<library>
// your_mass_of_code
</library>
and then just make the file have this (same as quest's game files) extension: *.aslx (for example: HK_RPG_LIBRARY_FILE.aslx)
whereas, a Game File, looks like this (using the same extension: *.aslx, for example: HK_RPG_GAME_FILE.aslx):
<asl version="540"> // or whatever the newest~current version of quest is
<game name="blah">
// etc code (default~new game: rest of Game Object info and attributes, "room" Room Object, and "player" Player Object)
</game>
// etc mass of code
</asl>
also, this is a wonderful software-program for if~when you're ready to work with code:
http://notepad-plus-plus.org/
just set the language (after you got it open~up~running) to XML
this is really nice as it provides color coding, making it much easier to write and trouble shoot errors in your code.
--------
P.S.
here's the full default (new game) coding:
these are quest's default library files ("ref" = referenced ~added~ library files):
<include ref="English.aslx" /> // provides the language being used as english
<include ref="Core.aslx" /> // this is Quest's Core Coding
which you can see below:
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</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>
</asl>
HegemonKhan
31 Jul 2013, 05:17imamy wrote:I wanted the comments to break up my script so I could read it more easily and now I have several ways of doing this!
you can have line spaces in your code (though I think these get removed when you start up your game file, meh), for example:
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</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>
</asl>
though, this works fine with your library files (well, while you don't use them within a game anyways, or maybe even then the line spaces don't get removed, I haven't checked on this so I'm not sure):
(the only problem is that it makes your document get exceedingly longer, lol)
(I'll also add in the comment lines too, both types)
<library>
<!-- Objects -->
<object name="dark_forest">
<!-- Attributes of dark_forest -->
<inherit name="editor_room" />
<alias>forest</alias>
<object name="shadow_wood">
<inherit name="editor_object" />
<inherit name="editor_player" />
<inherit name="character_type" />
<alias>tree</alias>
<strength type="int">50</strength>
</object>
<object name="skeleton_lord">
<inherit name="editor_object" />
<inherit name="editor_player" />
<inherit name="character_type" />
<alias>skeleton</alias>
<undead type="boolean">true</undead>
<hostile type="boolean">true</hostile>
<strength type="int">25</strength>
</object>
<!--
This below is the Object Type for all of my "character" objects, both playable characters and nonplayable characters, and the nonplayable characters can be friendly or hostile ("monsters~enemies")
-->
<type name="character_type">
<strength type="int">0</strength>
<endurance type="int">0</endurance>
<dead type="boolean">false</dead>
<undead type="boolean">false</undead>
<hostility type="int">0</hostility> // when this reaches 100, it becomes hostile. 0 is as most "friendly", becoming your ally if it is one of the character objects that you allow to be an ally.
<hostile type="boolean">false</hostile> // when this is (set~changed to~as) "true", you can fight it
<ally type="boolean">false</ally>
</type>
</object>
</library>
The Pixie
31 Jul 2013, 06:45HegemonKhan wrote:though, this works fine with your library files (well, while you don't use them within a game anyways, or maybe even then the line spaces don't get removed, I haven't checked on this so I'm not sure):
You can use them in a library, and they do not get removed when you play the game (as Quest will never save your library file you can be sure it will never make any changes to it).
imamy
01 Aug 2013, 21:59Hege, thank you for all the suggestions especially about the library and the notepad. The Online Version tends to jump back to the top of the page when I refresh, so hopefully I'll be able to move on to writing my own code soon. Scrolling back to my position every time I refresh is a bit maddening.