Super Noob: script for varying descriptions based on times something has occurred

I'm still muddling my way through the basics of using Quest, but by far the most common thing I want to do but don't know how to is to change which description/part of description is presented based on how many times something has happened. There is a basic provision for this right in your face in the game - the {once} command - but this only allows for 'this particular text is only presented once'.

Some examples of things I want to do:

  • Print three different messages, in order, each of the first three times you try to pick up a particular object. On the fourth try, a different message prints, and you are allowed to pick it up.
  • Present a wholly different room description the second+ time you enter the room. {once} does not exclude anything you write that isn't within its brackets, so I need a way to make something only appear on the second etc time entering the room.

I would say all of my other examples fall under those two options. I need a way to track the amount of times x has happened, i.e. 'tried to take item', 'entered x room', 'looked at x item', and so on, and then give different text responses based on that value. I assume I'd need to make some sort of script for every Thing Type that needs tracking, and then do some sort of 'get variable' thing to let the game know which text to present?


programming logic:

  1. you need an integer (non-decimal number) value (assigned/stored/held-within to an Attribute for global usage)
  2. you need to adjust/change (increase/decrease/etc-etc-etc) this integer value (Integer Attribute) as/when/where needed
  3. you need a script that checks the integer value (Integer Attribute), and acts upon that integer value (Integer Attribute), as/when/where needed, along with usually, scripting that also adjusts/changes (increase/decrease or reset) that integer value (Integer Attribute), as or if, needed

the 3 types of VARIABLES:

  1. Attribute VARIABLES:

because Attributes are the VARIABLES of an Object, so long as the Object exists (or still exists), you can use Attributes anywhere (Attributes are global VARIABLES) and they're permanent too, so...

Attributes are what you want to be using in Quest!!! especially for people new to coding

(except if/when you know coding and understand about scope issues, making local variables just for within scripts and etc stuff, but this is a bit more advanced stuff, for people who know coding)

NAME_OF_OBJECT.NAME_OF_ATTRIBUTE
// or
NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION

for examples:

create ("ball") // creating a 'ball' Object

ball.color = "red"

ball.weight = 5

ball.deflated = false

msg ("The " + ball.name + "'s weight is " + ball.weight + " lbs, its color is " + ball.color + ", and is the ball deflated? (Answer: " + ball.deflated + ")")

// output/display:

The ball's weight is 5 lbs, its color is red, and is the ball deflated? (Answer: false)

example of a more complex Attribute (storing the final value of a complex expression/calculation, instead of a simple literal/direct value):

create ("katana") // creating a 'katana' Object
create ("orc") // creating an 'orc' Object

katana.damage = 50

player.weapon = katana

player.strength = GetRandomInt (0,100)

orc.current_life = 500
orc.maximum_life = 500

player.damage = player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = (50) + (50) * ([0 to 100]) / 100
// player.damage = [50 to 100]

orc.current_life = orc.current_life - player.damage
// orc.current_life = (500) - ([50 to 100])
// orc.current_life = [400 to 450]

msg (player.name + " does " + player.damage + " damage to the " + orc.name + ".")

msg (orc.name + "'s Life: " + orc.current_life + "/" + orc.maximum_life)

  1. Variable VARIABLES:

these are local to their scripts, so they don't exist outside of their script (they get destroyed when their script ends), and so, they are also not permanent either, they're temporary (as soon as their script ends, they get destroyed, they don't exist outside of their script, they are LOCAL VARIABLES)

for the most part / generally, people new to coding, want to stay away from using Variable VARIABLES, due to the issues involving scope

but often, people new to coding, are doing/using Variable VARIABLES, and wondering why they're not working... as they don't understand that Variable VARIABLES are local, only exist within their script. They don't know to use Attribute VARIABLES.

NAME_OF_Variable
// or
NAME_OF_Variable = VALUE_OR_EXPRESSION

examples:

(notice that there's NO attachment, the dot/period, to an Object)

color = "red"

deflated = false

weight = 5

msg ("The ball's color is " + color + ", its weight is " + weight + " lbs, and is it deflated? (Answer: " + deflated + ")")

// output/display:

The ball's color is red, its weight is 5 lbs, and is it deflated? (Answer: false)

  1. Arguments/Parameters VARIABLES:

these are used within (mostly) Functions (and Commands and a few etc stuff too), which are special Variable VARIABLES, either directly ("literal") a Value or a VARIABLE's value (the "Argument"), is assigned into the "Parameter" Variable of) a Function, and these Parameter VARIABLES and their values, can be transferred from Function to Function as well, but we'll not get into this stuff, as its a bit more advanced stuff with using Functions, Commands, and few etc stuff


the 6 ways to adjust/change an integer value:

arithmetic:

  1. addition (+)

  2. subtraction (-)

  3. multiplication (*)

  4. division (/)

  5. modulus/modulo (%): this is a division operation, but instead you return/get/find the remainder value: the remainder value is for cyclic (repeating/intervals) needs/usage or factors/divisibility (which includes if a number is odd or even) of a number

factors/divisibility of a number:

number = GetRandomInt (0,100)

if (number % 2 = 1) {
  msg ("the number: " + number + ", is an odd number")
}

if (number % 2 = 0) {
  msg ("the number: " + number + ", is an even number")
  msg ("the number: " + number + ", is divisible by 2")
}

if (number % 3 = 0) {
  msg ("the number: " + number + ", is divisible by 3")
}

if (number % 4 = 0) {
  msg ("the number: " + number + ", is divisible by 4")
}

if (number % 5 = 0) {
  msg ("the number: " + number + ", is divisible by 5")
}

if (number % 6 = 0) {
  msg ("the number: " + number + ", is divisible by 6")
}

if (number % 7 = 0) {
  msg ("the number: " + number + ", is divisible by 7")
}

// etc etc etc

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

cyclic (usually involves time: clock time, dates: days in month, etc, and etc etc etc anything that repeats or acts at/upon intervals) needs/usage example:

(this actually is technically also just factors/divisibility of a number, lol, but its application can be used for cyclic stuff as seen below)

// number = 0

if (number % 5 = 0) {
  msg ("this message will be shown on every interval of 5 (number = 0, number = 5, number = 10, number = 15, etc etc etc)")
} else {
  msg ("this message will be shown always, except when 'number' value is on/at intervals of 5")
}

number = number + 1 // increases the 'number' value by 1

// how, just the code line (number = number + 1) directly above, works:

// this actually a programming operation, called an Assignment operation (=), the final value on the right side of the equal sign is assigned (stored or held within) to the variable on the left side of the equal sign

// unfortunately, math class usually never explains this, instead they just talk about comparison operations (algebra): finding the solution so that the values on both sides of the equal sign are the same

// comparison operations happen within (mainly) 'if' scripts in programming: if (animal = "lion") // string comparison, if (condition = "poisoned") // string comparison, if (number = 30 // integer comparison), if (cleaned_room = true) // boolean comparison, if (object = ball) // object comparison, etc etc etc

// also, usually programming languages use a '==' for its comparison operations, to distinguish between them and assignment operations using '=', but quest decided that this would be more confusing for non-coders, so it keeps the '=' sign for both comparison and assignment operations, being able to parse (aka, tell the difference) on its own for you

// the right side of the equal sign does have a sub expression/calculation (simple addition of +1) within it, but its final value is still being assigned/stored/held-within to the 'number' variable on the left side of the equal sign, which is very different than what you learned in math, just doing comparison operations (algebra), and likely never taught about that you're actually doing comparison operations, sighs. Math is about math, so these (programming) concepts (usually) don't get taught, sighs

// number = (number) + 1

// number = (0) + 1 = 1
// number = (1) + 1 = 2
// number = (2) + 1 = 3
// number = (3) + 1 = 4
// number = (4) + 1 = 5
// number = (5) + 1 = 6
// etc etc etc

another example, of clock time application:

hour_count = GetRandomInt (0,100)
minute_count = GetRandomInt (0,100)
second_count = GetRandomInt (0,100)

civilian_clock_hour = hour_count % 12
// civilian_clock_hour = [0 to 11]

military_clock_hour = hour_count % 24
// military_clock_hour = [0 to 23]

// clock_minute = minute_count % 60
// clock_minute = [0 to 59]

// clock_second = second_count % 60
// clock_second = [0 to 59]

another example of days in a month:

(very simplified and very non-real example, as month days is much more complicated, lol)

month_list = Split ("january;february;march;april;may;june;july;august;september;october;november;december")

month_integer = GetRandomInt (0,11)

month_string = StringListItem (month_list, month_integer)

day_count = GetRandomInt (0,100) // this is very impractical (non-real), but it's just for showing this example usage/application of the cyclic modulus/modulo operation

if (month_string = "february") {
  day = day_count % 28 // ignoring leap year complications (29 days in february instead of 28), lol
  // day = [0 to 27]
} else if (month_string = "april" or month_string = "june" or month_string = "september" or month_string = "november") {
  day = day_count % 30
  // day = [0 to 29]
} else {
  day = day_count % 31
  // day = [0 to 30]
}

non-arithmetic (programming):

  1. setting/resetting (no arithmetic operation, you just directly set/reset the value to what you want it to be)

example of (setting/resetting the 'number' variable to/back-to ZERO):

number = 0


getting tired... still got to get to conceptual examples of how to do this stuff that you're asking about (and then actual help on what you want to do, lol)... but I need a break

I'll try to get back to helping with this stuff, but it might not be until the weekend...


....well that will certainly be useful when I know enough about scripting to implement it! For now I think the most I can take from it is the tip to avoid variable variables, and also the understanding of the three basic points you outlined at the start as 'programming logic'. Thanks for putting all of that there for me! If you have the time/energy to do those conceptual examples you mentioned, and/or help with the implementation, I certainly won't complain. But this much is already appreciated.


{once:This appears the first time}

{notfirst:this appears the second and subsequent times}

{notfirst:{once:This appears the second time only}}

{notfirst:{notfirst:this appears the *third* and subsequent times}} because each notfirst makes it skip one occasion

I have a similar thing where you repeatedly examine an object. Every time you do so, it just adds one to a counter for that specific object, and the if/else loops display a message based on the count. On the last description, the counter is reset to one and the loop begins anew.


Log in to post a reply.

Support

Forums