Problem with tutorial (newbie)
thierry_st_malo
21 Mar 2016, 10:41Hi, all!
I am totally new to Quest, which I find quite interesting. I am half-way through the tutorial ("Use defibrillator on Bob" section) and I have completed the section's first part. But now I am told to check Bob's "alive" flag. How can I do that ? I can't see anything suitable in the If statement's checklist.
Thanks in advance,
Thierry
I am totally new to Quest, which I find quite interesting. I am half-way through the tutorial ("Use defibrillator on Bob" section) and I have completed the section's first part. But now I am told to check Bob's "alive" flag. How can I do that ? I can't see anything suitable in the If statement's checklist.
Thanks in advance,
Thierry
HegemonKhan
21 Mar 2016, 11:47The big first step (after getting the basics and terminology, and general usage of quest down) is understanding about:
Attributes and the the 'if' Script (and the 'if' logic mindset)
90% of everything that you want to do/create in a game, is done, epsecially when used together, with Attributes and the 'if' Script.
in the GUI~Editor, Attribute usage through Scripts are done via:
run as script -> add new script -> variables -> 'set a variable or attribute' Script -> (choose the needed option or choose the [EXPRESSION] option and code/write in what you want)
and the 'if' Script is done via:
run as script -> add new script -> scripts -> 'if' Script -> (choose the needed option or choose the [EXPRESSION] option and code/write in what you want)
--------------
you're already on a very good start, understanding that to 'check' something, you use the 'if' Script.
-----------------------------------------------
a bit of code to scare you, hehe
Object_name.Attribute_name = Value_or_Expression
for examples:
Object_name: orc
Attribute_name: dead
(Attribute Type: boolean)
Value: false
--
Object_name: katana
Attribute_name: damage
(Attribute Type: int) // int <--- integer (non-decimal numbers)
Value: 50
Object_name: katana
Attribute_name: parent
(Attribute Type: object) // this is not the same as an Object. This is an Object (Type) Attribute.
Value: player
// 'parent' is a built-in Object Attribute, which determines where an Object is located/inside of (having Objects in the player's inventory is the same as those Objects' having their 'parent' Object Attribute set to the Value of: player. In the GUI~Editor, you also got the 'MoveObject' Script, well the 'parent' Object Attribute does the exact same thing)
// http://docs.textadventures.co.uk/quest/ ... arent.html
Object_name: player
Attribute_name: damage
Expression: player.damage = player.katana.damage + player.katana.damage * player.strength / 100
// in code scripting 'player.katana.damage', means that: 'damage' is an Attribute of the 'katana' Object, and the 'katana' Object is, held/contained/put/placed/added-to/inside of, the 'player' Object.
--------------------
containment (parent-child) hierarcy:
grandfather
-> father
->-> son
->->-> grandson
grandfather is the main (root) parent
grandfather is the the direct parent of father
grandfather is the indirect parent of son and grandson
father is the direct child of grandfather
father is the direct parent of son
father is the indirect parent of grandson
son is the indirect child of grandfather
son is the direct child of father
son is the direct arent of grandson
grandson is the indirect child of grandfather and father
grandson is the direct child of son
C:\\ (drive)
-> programs (folder)
->-> quest (file)
player
-> bag
->-> gold coin
// Objects in (or put into) the player's 'inventory' simply means that those Objects are inside (or put inside) of the 'player' Object.
// the 'inventory' is actually an Object List Attribute of the 'player' Object, but ignore about Lists for now, as they're much too complicated for now.
HK
-> pants
->-> wallet
->->-> $1
multiverse
-> universe
->-> galaxy clusters
->->-> milky way galaxy
->->->-> the 'sun' (a star on the outer tendril of the milkyway galaxy)
->->->->-> the 'earth' (3rd planet from sun; planet in our sun's solar system)
->->->->->-> humans
etc etc etc containment/parent-child heirarcies
--------------------------
the custom (self-created) 'alive' flag is (well should be set/created/added as) a Boolean Attribute:
(Boolean Attributes are Attributes which only have two Values: true or false)
orc.dead = false
orc.dead = true
orc.alive = true
orc.alive = false
player.flying = false
player.flying = true
tv.switchedon = true
tv.switchedon = false
game.paused = true
game.paused = false
door.locked = true
door.locked = false
etc etc etc
and combining them together...
--------------
I don't know the GUI~Editor's Script options very well, but look for some 'if' Script option that involves:
Objects (Bob and defibulator) and Attributes (alive)
and see if you can figure it out...
--------
'defibulator' Object's 'use/useon' Verb/Command:
pseudocode example
Attributes and the the 'if' Script (and the 'if' logic mindset)
90% of everything that you want to do/create in a game, is done, epsecially when used together, with Attributes and the 'if' Script.
in the GUI~Editor, Attribute usage through Scripts are done via:
run as script -> add new script -> variables -> 'set a variable or attribute' Script -> (choose the needed option or choose the [EXPRESSION] option and code/write in what you want)
and the 'if' Script is done via:
run as script -> add new script -> scripts -> 'if' Script -> (choose the needed option or choose the [EXPRESSION] option and code/write in what you want)
--------------
you're already on a very good start, understanding that to 'check' something, you use the 'if' Script.
-----------------------------------------------
a bit of code to scare you, hehe
Object_name.Attribute_name = Value_or_Expression
for examples:
Object_name: orc
Attribute_name: dead
(Attribute Type: boolean)
Value: false
--
Object_name: katana
Attribute_name: damage
(Attribute Type: int) // int <--- integer (non-decimal numbers)
Value: 50
Object_name: katana
Attribute_name: parent
(Attribute Type: object) // this is not the same as an Object. This is an Object (Type) Attribute.
Value: player
// 'parent' is a built-in Object Attribute, which determines where an Object is located/inside of (having Objects in the player's inventory is the same as those Objects' having their 'parent' Object Attribute set to the Value of: player. In the GUI~Editor, you also got the 'MoveObject' Script, well the 'parent' Object Attribute does the exact same thing)
// http://docs.textadventures.co.uk/quest/ ... arent.html
Object_name: player
Attribute_name: damage
Expression: player.damage = player.katana.damage + player.katana.damage * player.strength / 100
// in code scripting 'player.katana.damage', means that: 'damage' is an Attribute of the 'katana' Object, and the 'katana' Object is, held/contained/put/placed/added-to/inside of, the 'player' Object.
--------------------
containment (parent-child) hierarcy:
grandfather
-> father
->-> son
->->-> grandson
grandfather is the main (root) parent
grandfather is the the direct parent of father
grandfather is the indirect parent of son and grandson
father is the direct child of grandfather
father is the direct parent of son
father is the indirect parent of grandson
son is the indirect child of grandfather
son is the direct child of father
son is the direct arent of grandson
grandson is the indirect child of grandfather and father
grandson is the direct child of son
C:\\ (drive)
-> programs (folder)
->-> quest (file)
player
-> bag
->-> gold coin
// Objects in (or put into) the player's 'inventory' simply means that those Objects are inside (or put inside) of the 'player' Object.
// the 'inventory' is actually an Object List Attribute of the 'player' Object, but ignore about Lists for now, as they're much too complicated for now.
HK
-> pants
->-> wallet
->->-> $1
multiverse
-> universe
->-> galaxy clusters
->->-> milky way galaxy
->->->-> the 'sun' (a star on the outer tendril of the milkyway galaxy)
->->->->-> the 'earth' (3rd planet from sun; planet in our sun's solar system)
->->->->->-> humans
etc etc etc containment/parent-child heirarcies
--------------------------
the custom (self-created) 'alive' flag is (well should be set/created/added as) a Boolean Attribute:
(Boolean Attributes are Attributes which only have two Values: true or false)
orc.dead = false
orc.dead = true
orc.alive = true
orc.alive = false
player.flying = false
player.flying = true
tv.switchedon = true
tv.switchedon = false
game.paused = true
game.paused = false
door.locked = true
door.locked = false
etc etc etc
and combining them together...
if (orc.dead) {
msg ("the orc is already dead, silly")
}
else if (not orc.dead) {
msg ("You attack the orc and kill it")
orc.dead = true
}
--------------
I don't know the GUI~Editor's Script options very well, but look for some 'if' Script option that involves:
Objects (Bob and defibulator) and Attributes (alive)
and see if you can figure it out...
--------
'defibulator' Object's 'use/useon' Verb/Command:
pseudocode example
if (object.name = "Bob") {
if (Bob.dead) {
msg ("You use the defibilator on Bob's still and pulse-less body... again and again trying to revive him. Just when you think it's no use, Bob gasps, alive and well. You saved his life!")
Bob.alive = true // this is atually setting Bob to being alive, as he's suppose to be alive now.
}
else {
msg ("Bob is already alive! What are you doing?! Are you trying to kill him?! You don't use a defibilator on someone who's breathing fine and alive!")
}
}
else if (object.name = "orc") {
msg ("No, you're not going to revive the orc, as it already tried to kill you when it was alive.")
}
HegemonKhan
21 Mar 2016, 12:25if interested, when I first found quest, I too got stuck on the defibilator section (and many others too), while I think it got changed since I did it, you can take a look at my thread and posts asking for help (though I quickly move onto learning quest's code, as I wanted to learn to code, and I've come pretty far... but got a long long ways to go... , programming / computer science, is a very big and major field, that just doesn't deal with programming, but also math and logic and etc, sighs):
viewtopic.php?t=3348
as you can see, this is from ~ 3 years ago, quest and the tutorial has changed since then, lol.
EDIT: $@$#... it's been now 4 years... time flies... laughs...
viewtopic.php?t=3348
as you can see, this is from ~ 3 years ago, quest and the tutorial has changed since then, lol.
EDIT: $@$#... it's been now 4 years... time flies... laughs...
Pykrete
21 Mar 2016, 12:50You can either add a Boolean attribute to the Bob object and set it to True if you want it to be flagged from the beginning, or if it's a script halfway through, add script, scroll down to variables, and it's the first option there; Set Object Flag. Select the Bob object and type in 'alive'. Watch your casing; if you use alive, make sure you reference alive. Alive, reference Alive.

XanMag
21 Mar 2016, 13:01Feel free to also play the "game" 'Quest - Tutorials and Templates'. Here you can see/play rooms that show an example of common problems. Also, in that room, you can type 'explain' to get a walk through on how that room was accomplished. There are 3-4 rooms that deal with flags specifically (especially see 'flag setting and unsetting room'.
http://textadventures.co.uk/games/view/ ... -templates
The .aslx file is also available for download in the forums. This is intended to be downloaded so you can actually see it as it was done in the Quest editor.
viewtopic.php?f=5&t=5940
Ask if you have questions!
http://textadventures.co.uk/games/view/ ... -templates
The .aslx file is also available for download in the forums. This is intended to be downloaded so you can actually see it as it was done in the Quest editor.
viewtopic.php?f=5&t=5940
Ask if you have questions!
thierry_st_malo
21 Mar 2016, 13:05Thanks to you all 
Thierry

Thierry