coding?

onimike
Hey all, was wondering if there are any walkthroughs, videos or step by step instructions on learning quest coding? And if not could some one recommend what coding language I should look into to use with quest please? Thank you in advance.

jaynabonne
There's the tutorial linked to from here:

http://docs.textadventures.co.uk/quest/

Beyond that, just what's on the forums, that I know of. However, it wouldn't surprise me if there were something out there!

Edit: funny how when you look...

https://www.youtube.com/watch?v=uNrF4QB ... 04663EE7A2

Silver
That doesn't seem to cover coding though.

onimike
No but I thank you for checking I have seen those was looking for more of a direct coding and understanding including all functionality such as AllObjects (), GetInt, Got (obj) and what they mean, when to add in a script etc. But I'm looking at the coding itself when I use the GUI editor trying to understand :). Thanks again I'll have it down when they have an engine that does it all for you lmao.

jaynabonne
One good thing to do is to look at the Quest core code that ships with the desktop version. You can see how the various functions and methods are used. That's not a great answer, but it's how I learned a lot about how things worked (besides just trying it myself).

On my computer, those files live in:

C:\Program Files (x86)\Quest 5\Core

You can also view them in any editing session by clicking FIlter at the bottom left and then "Show Library Elements". That will make all the core script visible to be looked at. (They will all be gray and not editable unless you explicitly copy them into your game.)

onimike
Thanks Jay yeah its my best bet plus I need to learn any way if I want to make a good game and have the correct functionality.

HegemonKhan
HK is a good guide for you (albiet it might take him many attempts until his posts are clear and understandable, laughs) :D

I'd be happy to be your quest code guide or instructor, lol. HK likes (trying anyways) to teach others about quest's code, as I myself was a total noob 2-3 years ago, knowing nothing not only about quest's coding, but nothing about coding~programming in general as well, so thus I post a lot, as I want to give back to this great software and website, by trying to help others learn to code and~or just to code in general, hehe :D

--------

so, ask (post publically or pm me) away your questions at me (I'll be glad to help with everyone of them, ask all you want as much as you want), though I'm busy in real life (got a job), so I may not be able to answer right away though.

HegemonKhan
onimike wrote:AllObjects (), GetInt, Got (obj)


--------

AllObjects () : a 'scope like function' that gets *ALL* Objects in the ENTIRE game: as for exactly what it is doing internally: I *guess* it gets all the Objects and puts~uses them in a variable_name = NewObjectList (), as you see the similiarity: AllObjects () <===> NewObjectList () ~ the parenthesis' are empty, internally within the Function itself: AllObjects ()

------

get input { script } : this simply (internally~hidden from you) sets: result = (your typed-in input into the command bar during game play), so:

msg ("What is your name?")
get input {
// I type in during game play: HK
// hidden from you, this is done: result = "HK"
// thus this can be set below:
player.alias = result
// as conceptually: player.alias = result = "HK"
msg (player.alias)
// outputs: HK
}


as for GetInput... oops... haha... GetInt... wow, I need to read more closely, haha...

-----------

for 'Get' (Attribute: all types~any type, Int, String, etc):

variable_name = GetInt (Object_name, "Attribute_name")

'Get' is a one step process that does the three processes:

1. checking if your Object has the Attribute
2. checking if your Attribute has the correct Value (if the Attribute's Attribute Type matches up with the Attribute's Value's Attribute Type)
3. and if yes, then it returns~outputs that Value (in this case of GetInt, then the # amount, or if no, then it returns~outputs NULL (it fails to do the script as it failed the check conditions).

for direct example (I think I call ...

<function name="age_integer_function">
msg ("What is your age?")
get input {
if (IsNumeric (result) = true) {
if (ToInt (result) >= 0) {
} else if (IsNumeric (result) = false) {
}
}
</function>


-----

err... sorry... I just got called into work... got to go right now, lol...

jaynabonne
1) The parentheses are optional if there are no parameters.

2) The one difference in the Get* functions is GetBoolean, which returns false if the attribute doesn't exist - which is quite handy.

3) In this code:

<function name="age_integer_function">
msg ("What is your age?")
get input {
if (IsNumeric (result) = true) {
if (ToInt (result) >= 0) {
} else if (IsNumeric (result) = false) {
}
}
</function>

the "if IsNumeric = false" will never be true, as it will only get there if IsNumeric is already true. So that else is not needed. If you meant it to be the else for IsNumeric = true, then you don't need the check. A simple else will do. If it's not true, it must be false.

4) Got(object) returns true if the player currently has the object (that is, the object's parent is the player). More or less equivalent to whether the object is in the player's inventory.

HegemonKhan
err... I typo'ed in my haste to close out of quest and my pc (to get to work), I put it on the wrong line Jay, lol.

(now that I'm back from work, let me finish up this example)

(code is stupid and redundant, but doing it to show all the different uses: 'Is', 'Has', 'Get', and 'To' Functions)

<function name="age_integer_function">
msg ("What is your age?")
get input {
if (IsNumeric (result) = true) {
if (ToInt (result) >= 0) {
player.age_integer = ToInt (result)
if (IsInt (player, "age_integer") = true) {
if (HasInt (player, "age_integer") = true) {
if (GetInt (player, "age_integer") >= 0) {
msg (player.age_integer)
}
}
}
} else if (ToInt (result) < 0) {
// call function (loop~repeat function)
}
} else if (IsNumeric (result) = false) {
// call function (loop~repeat function)
}
}
</function>

HegemonKhan
Got:

http://docs.textadventures.co.uk/quest/ ... y/got.html

if (Got (million_dollar_bill) = true) {
player.alias = "HK"
msg (player.alias + " is very very very very happy !!!!!!!!!!!")
}

or, the exact same thing:

if (million_dollar_bill.parent = player) {
player.alias = "HK"
msg (player.alias + " is very very very very happy !!!!!!!!!!!")
}

Or, the exact same thing:

(syntax is probably wrong, too lazy to look up how to do it)

if (Contains (ScopeInventory (), million_dollar_bill) = true) {
player.alias = "HK"
msg (player.alias + " is very very very very happy !!!!!!!!!!!")
}


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

in case you're wondering about the:

IsNumeric vs IsInt

It took me a long time to understand the difference myself... lol

IsNumeric is asking if the character~symbol itself is a number, or not.

IsInt is asking if it's set as being the Attribute Type of 'Integer', or not.

HegemonKhan
as for coding language:

quest's code language is it's own, however it does resemble 'XML (eXtensive Markup Language)'

download this program~software:

http://notepad-plus-plus.org/

and when you got it installed and opened up:

at the top, click on 'languages', and choose 'XML', and craft your own (or copy and paste others' code into it, from posts in the forum such as mine or Jay's or Pixie's or etc's) quest code. Then for the file itself's name, change~rename it's extension to: *.aslx (ie: your_name_of_file.aslx), to play it as a quest game (if the code is that of a functioning game and is of the same version as your quest.exe, current is: version="550" ). Err, you can always have it be a library file, if its code does not create a functional game.

due to the color coding that it uses, it makes it SOOOO much easier ro read, write, and~or troubleshoot your (or others' ) quest code :D
(and a lot of other really cool features, which I've not learned to use yet... doh!)

also, it tells you the 'line' and 'line position' of where your cursor is at, so very useful for finding your errors from the error messages, made up example:

Error code: extra ' ) ' at line 8 position 5, hehe :D

or my own personal common typo~error:

Error code: missing ' { ' at line X position Y, hehe :D

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

as for learning to code in quest:

first first (forgot, lol): complete the tutorial in its entirety

first understand all the terms (or stuff) and about them (able to use them) in quest:

Elements (THINGS~Physics: MATTER)
-> Objects
-> Turnscripts
-> Timers
-> Verbs
-> Commands
-> Functions
-> Object Types
-> Exits
-> etc etc etc
Attributes (Types of Attributes) ~ (MECHANICS~DATA)
-> String
-> Integer (int)
-> Double
-> Boolean
-> Object
Scripting (ACTIONS~Physics: ENERGY~FORCES~WAVES)
-> 'set a variable or attribute' Script
-> 'if' Script
-> 'msg' Script
-> 'get input' Script
-> Parameters (Commands and Functions)
-> etc etc etc

second, understand Attribute usage (setting and altering Attributes)

third, understanding the 'if' code mindset~mentality~logic~thinking of scripting (which means: 'if' Scripts + 'set a variable or attribute' Scripts: understanding 'if' logic and Attributes)

fourth, 'character creation' Scripting

4.5 (forgot these), Parameters (Functions and Commands), Functions, Commands, and (separate~unrelated from the rest) Object Types

fifth, lists + 'foreach' and 'for' + Randomization Scripts~Functions ( 'DiceRoll', 'RandomChance', 'GetRandomInt', and 'GetRandomDouble' )

sixth, dictionaries + (see lists' above)

seventh, take some small simple code, learn it, and keep building up more and more small code things.

for challenges, when you feel you're ready:

combat, equipment, magic, 'explore' and 'travel', dynamic dialogue, and etc etc etc

jaynabonne
Just to comment a bit (since this is targetted to a new scripter who may not know otherwise):

In languages where you have boolean-taking "if" statements as well as boolean-returning functions (and there are a lot of them out there), you would never see something like this:

    if (IsNumeric (result) = true) {

except in newbie programmers who didn't understand. The thought of taking a boolean result and comparing it to true or false to generate *another* boolean result is not only unnecessary, but it breaks the readability of the code. All you need to do is:

    if (IsNumeric (result)) {

which actually reads the way you want ("If the result is numeric" as opposed to "if the result of the IsNumeric function on result is true"). I know HK prefers it that way, so I won't argue with him. But I would not want to propagate such a style issue to someone new. If you were working in an actual coding environment (e.g. a company) and wrote code like that, you'd end up with at least raised eyebrows and concerned looks if not outright censure.

As well, the basic construct for handling the two sides of a condtion is "if/else":

if (some_condition) {
// handle the condition
} else {
// handle the opposite condition
}

That is the idiom for if/else. If you had three conditions, you'd add in an additional "else if":

if (some_condition) {
// handle the condition
} else if (some_other_condition) {
// handle the second special condition
} else {
// neither of those
}


You would (should) never see code like this:
if (some_condition) {
// handle the condition
} else if (not some_other_condition) {
// handle the opposite case
}

Again, proper coding style guides for *any* language with such a construct would frown on that because:
1) it's needless additional code to test the opposite condition which a simple "else" already covers
2) it would probably be confusing to someone besides you looking at the code because the "else if" is setting up the idiom and expectation that there are more than two conditions being checked
3) it's just pointless and overly complicated. You have to actually work out and make sure you get right the opposite condition to the original if. That's an error and bug waiting to happen. And all to gain code bloat...
4) If you ever showed the code to anyone who knew better, you'd lose brownie points.

Now, people can write code how they want. It's always possible to write worse code than necessary, and I'm not one to dictate. Feel free. :) I just don't want to see some of the examples given above as the way you *need* to write the code. You can if you want. But there is absolutely no need to propagate boolean expressions ( "(((((IsInt(result) = true) = true ) = true)...") or avoid the use of a straight "else" in your conditionals. You really don't want to pick up bad style habits so early. Then you just have to break them later. As they say, Keep It Simple, Son!

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

Support

Forums