Couple of quick questions!
Bobinator
20 Mar 2018, 12:16Hey! I've been messing around with Quest, and I've been slowly figuring it out. But I have a few questions, and to be honest, I'll be likely to have a lot more as I go. Please bear with me.
OK, so.
-
If you're using hyperlinks, how do you have it so certain actions DON'T show? Let's say you have a key the player needs to unlock something with. Is there a way to have it so the "Unlock" command does NOT appear unless the player has a key? You can set a message if the player isn't holding a key, I'm aware, but that's not quite the same thing.
-
Is there a list of expressions Quest uses I can use for a reference? For example, I'd want to know somewhere I can check what the expression for checking if an object's Boolean value is off hand, instead of having to ask each time I have a question like that.
-
Is there a way to have something happen as SOON as a variable hits a certain value, instead of the turn after? Like, say, if you have a countdown, is there any way to have something on the turn the countdown hits zero, and not afterwards?
mrangel
20 Mar 2018, 13:55-
An object's
displayverbs
attribute is a string list containing the actions that will show on the menu. You can remove or add items to this list during the game; or set it's initial values on the object's "verbs" tab. -
Not quite sure what you mean by a list of expressions; but in most cases you'll probably want to be looking at the list of functions.
-
If you're checking the value of a variable each turn, then you just need to make sure that the check happens after the script that is changing the value.
Alternatively, you could use a change script. For example, if you change an object'scountdown
attribute, then a script attribute (on the same object) calledchangedcountdown
will be run immediately. You could create this script attribute, and have it do whatever actions are necessary. (Within the script, you can assume that the variableoldvalue
will refer to what the previous value of the changed attribute is).
Bobinator
20 Mar 2018, 14:48I'm really sorry, but would you mind going through that first point again? I tried to set up a turn script that was enabled at the start, where if the player was holding the key, a text value of "Unlock" would be added to door.displayverbs. Is that the best way to do it, or am I missing something?
Curt A. P.
20 Mar 2018, 16:181. What you need is the build-in displayverbs or inventoryverbs list.
You have the object key
Quest automatically make the stringlist key.displayverbs and key.inventoryverbs.
key.displayverbs
This list contains all verbs if the object is not in the player inventory. So it contains most likely take.
key.inventoryverbs
This list contains all verbs if the object is in the player inventory. So it contains most likely drop.
You can easily remove verbs and add verbs. Remove a verb from one of these two list won't affect the verbs behaviour itself. The player still can type 'unlock' by himself and it would run the verb's or the command's script.
I just show a example for the inventory verbs. Additionally, you can remove you 'unlock' verbs from the display verbs.
Removing/adding lists items via the editor or browser:
Click add new script >> Variables tab >> Remove a value from a list
The first text box is for the list. Type here: key.inventoryverbs
The next text box is for the value: "unlock"
The quotation marks are important. This let quest know the value is a string.
Code examples
list remove (key.inventoryverbs, "unlock")
list add (key.inventoryverbs, "unlock")
list remove (key.displayverbs, "unlock")
list add (key.displayverbs, "unlock")
There's also the object's object tab. At the bottom of this tab you can add and remove the display and inventory verbs. This good for the start, before you got the key.
Curt A. P.
20 Mar 2018, 17:022. Sounds like you are looking for the 'If' script. There you can select 'object has flag'. Have you played/created the tutorial game? Quest documentation - Tutorial
In code:
if (GetBoolean(player, "is_male")) {
}
3. Make a turn script and then 'If' again.
'If object attribute equals'
This would check every turn if the object's attribute reached a certain value.
In code:
create turnscript ("TurnCheckValue")
SetTurnScript (TurnCheckValue) {
if (player.lifepoints = 0) {
PrintCentered ("Game Over<br/><br/>You are dead")
}
}
Just a short example. Normally I ask for = 0 and <= 0.
I use this kind of turn script to keep things like the lifepoints under the maximum, too.
Bobinator
20 Mar 2018, 17:50OK, new problem... doing what Curt A. P. suggested, I made a turn script that checks if the player has the key every turn. Unfortunately, that has it so that every turn the player is holding the key, a new 'Unlock' option appears in the menu. I know this must be really obvious, but what can I do to fix this?
mrangel
20 Mar 2018, 18:06I thjnk you could use:
door.displayverbs = ListCompact (door.displayverbs + "Unlock")
Or something lkke
(typing on my phone, so may have typos due to autocorrect)
if (Has(key)) {
if (not ListContains(door.displayverbs, "Unlock")) {
list add (door.displayverbs, "Unlock")
}
)
else {
if (ListContains(door.displayverbs, "Unlock")) {
list remove (door.displayverbs, "Unlock")
}
}
Curt A. P.
20 Mar 2018, 18:32Maybe it helps if you tell what this flag is supposed to check. (?)
Edit: Idiot me...
Only if you try/need to unlock something you should check for the key.
You have a key.
There is a closed door.
Now, if you type 'unlock door' the first thing quest should do is checking for the key. Then you insert the scripts for what happens if you have the key and else.
Go to your unlock command or to the door's/key's verb tab. Here you need to check for the flag.
Turn scripts will be executed every turn and there dozens of ways to use it but there are scripts which won't make much sense.
Like moving the player to somewhere. I use a turn script to make sure my hidden inventory container is always in the same room as the player. Yesterday set a turn script for a morning > noon > evening > night day cycle.
hegemonkhan
20 Mar 2018, 22:29- here's some useful resources:
http://docs.textadventures.co.uk/quest/display_verbs.html (Pixie's guide on using, adding/removing and etc, the built-in 'displayverbs' and 'inventoryverbs' Stringlist Attributes)
http://docs.textadventures.co.uk/quest/attributes/displayverbs.html
http://docs.textadventures.co.uk/quest/attributes/inventoryverbs.html
- here's some useful resources:
http://docs.textadventures.co.uk/quest/
http://docs.textadventures.co.uk/quest/elements/ (Elements)
http://docs.textadventures.co.uk/quest/types/ (Attribute/Value/VARIABLE/Data Types)
http://docs.textadventures.co.uk/quest/null.html (the 'null' Data Type)
http://docs.textadventures.co.uk/quest/elements/object.html (all/most of the 'Object' Element's built-in Attributes and etc)
http://docs.textadventures.co.uk/quest/scripts/ (Scripts/Functions)
http://docs.textadventures.co.uk/quest/functions/ (more Scripts/Functions, categorical order)
http://docs.textadventures.co.uk/quest/functions/index_allfunctions.html (same as link above, but as alphabetical order)
- there's two ways of doing 'always checking' (which is what's done/needed for knowing immediately when a value changes):
(1) Turnscripts/Timers
(2) the 'changedNAME_OF_ATTRIBUTE' special Script Attribute for a specific Object
there's pros and cons to both of them:
the 'changed' Script Attribute runs immediately upon a value changing, but this can cause problems with the order of things happening, as you don't have control over it
Turnscipts/Timers provide great control (Timers much less so, do to all of the issues with actual time and its timing), but they have a few quirks with their internal turns if you're dealing with that stuff at that level of control with turns, there's some solutions, but it can be a hassle, trying to get it right
hegemonkhan
20 Mar 2018, 23:03@ Curt A.P.
"Yesterday set a turn script for a morning > noon > evening > night day cycle (Curt A.P.)"
this is a bit more advanced (and a new, I think) method for you:
there's the 'modulus' operator/operation: %
it's division, except it gets/returns/finds the REMAINDER
this enables cyclic (and odd/even and factors/divisible-ness) applications
for examples: (see below)
CYCLIC:
(you can use any number, such as '7' for days of the week: 0:sunday to 6:saturday, '4' for seasons: 0:winter to 3:autumn, '9' for decimal number system: 0 to 9 digits, etc etc etc, anything you can think of, any cyclic thing or usage you want/need/can-think-of)
msg ("Type in whatever integer number amount you want")
get input {
if (IsInt (result)) {
input_integer_variable = ToInt (result)
game.civilian_hour_integer_attribute = input_integer_variable % 12
game.military_hour_integer_attribute = input_integer_variable % 24
game.clock_second_or_minute_integer_attribute = input_integer_variable % 60
msg ("Civilian Hour: " + game.civilian_hour_integer_attribute)
msg ("Military Hour: " + game.military_hour_integer_attribute)
msg ("Clock (Second or Minute): " + game.clock_second_or_minute_integer_attribute)
// the 'civilian hour' will always be: 0 to 11
// the 'military hour' will always be: 0 to 23
// the 'clock second or minute' will always be: 0 to 59
} else {
msg ("Wrong input, try again")
}
}
Factors/Divisibility (and even/odd of a number):
msg ("Type in whatever integer number amount you want")
get input {
if (IsInt (result)) {
input_integer_variable = ToInt (result)
if (input_integer_variable % 2 = 0) {
msg (result + " is a EVEN number, as " + result + " is divisible by 2 (or to say it differently: 2 is a factor of " + result + ")")
} else if (input_integer_variable % 2 = 1) {
msg (result + " is a ODD number, as " + result + " is NOT divisible by 2 (or to say it differently: 2 is NOT a factor of " + result + ")")
} else if (input_integer_variable % 3 = 0) {
msg (result + " is divisible by 3 (or to say it differently: 3 is a factor of " + result + ")")
} else if (input_integer_variable % 4 = 0) {
msg (result + " is divisible by 4 (or to say it differently: 4 is a factor of " + result + ")")
} else if (input_integer_variable % 5 = 0) {
msg (result + " is divisible by 5 (or to say it differently: 5 is a factor of " + result + ")")
}
// etc 'else ifs' of numbers (6, 7, 8, ...)
} else {
msg ("wrong input, try again")
}
}
I'll let you try to apply this stuff, such as for your 'hours of the day' (twilight, dawn/sunrise, morning, noon/mid-day, afternoon, dusk/sunset, twilight, evening, night, midnight, etc), but if you need help, let me know
here's a hint: use the 'modulus' and a stringlist (or rather, an 'if' with a range check) of the hours of a day
Curt A. P.
21 Mar 2018, 00:10@hegemonkhan
Oh- Thank you,
this is what I'm looking for. If it's what I think I can see a way to a game based on a full clock. Last time I dropped the 24 h clock inc. seconds indicator because applying scripts to certain times was a pain of work. I already finished a working clock with day counter and waiting command where the player could type a integer and the time unit to wait. I haven't touched weekdays and months because my method efforts too much work.
I had many calculations like this to handle the different time units:
[•••]
if (player.waiting_integer <= 60) {
player.waiting_integer = world_time.clock_minutes + player.waiting_integer - 60
world_time.clock_minutes = 0
world_time.clock_minutes = world_time.clock_minutes + player.waiting_integer
if (world_time.clock_hours = 59) {
world_time.clock_days = world_time.clock_days + 1
}
world_time.clock_hours = world_time.clock_hours + 1
}
}
else {
SetObjectFlagOn (world_time, "wait_check_1")
}
if (player.waiting_integer >= 60) {
msg ("<br/>You can only wait 60 minutes. Please type hours for longer waiting sessions.<br/>")
}
[•••]
With this Cyclic function I can already smell how good it would work.
@hegemonkhan
Btw: Yesterday I've read your guide about lists. It was very useful and I do understand lists, especially object lists, much better now.
List and Dictionary Extensive Guide (by HK)
Edit:
@hegemonkhan
Oh, and finally I do understand the 'For' function xD
hegemonkhan
21 Mar 2018, 00:31if you want a creative/unique/novel (but complicated: used change scripts to do the carrying/adjusting of the digits: 9 to 0, increase the higher-next digit by 1, etc etc etc) way of doing a 'countdown' timer (this was before I learned of the modulus operation myself, lol):
http://textadventures.co.uk/forum/samples/topic/4162/countdown-timer-code
it was fun creating it and then seeing it work, lol
time and date stuff is really complicated stuff... you probably just want to use Pixie's stuff, unless you're really smart, good with math, and good at programming, as time and date stuff is really complex (well, if you try to do non-simple advanced/extensive time and date stuff/mechanics/features in your game, especially, lol)
Curt A. P.
21 Mar 2018, 00:58time and date stuff is really complicated stuff... you probably just want to use Pixie's stuff, unless you're really smart, good with math, and good at programming, as time and date stuff is really complex (well, if you try to do non-simple advanced/extensive time and date stuff/mechanics/features in your game, especially, lol)
Yes, realized it by myself and dropped it completely. Later I decided to make simple day and night system. The possible times was only day and night. Also counting the days. So it wasn't much of a effort to make it morning, afternoon, evening and night (+ counting days). Just thinking of it, I believe it's best to keep it like this until I am more experienced with programming.
Lol, Math was always one of favourite school themes. I did not like English in school, so this is (only) a bit problematic with Quest. The last six years I've learned English on my own via gaming, TV shows/movies, talking with English speaking persons (No grammar lessons or anything, sigh). I keep running into Functions which I don't understand as English word first.