Need help with scopes and objects.


I´m new to QUEST (and coding in general) and working on my first game. Unfortunately , I´ve hit a brick wall.

So... I want to have an interactable oven that can hold multiple ingredients. The player should be able to change the temperature of the oven and leave the room, while the oven continues baking the food. If the ingredients are in the oven for too long, they burn. (If the variable progress of an ingredient reaches 0, it burns)

What I did so far is this:

I have an object called "oven" with the variable "oven.temp = 10"

If you put an item into the oven, this script runs:

SetObjectFlagOn (this, "inoven")
this.progress= GetRandomInt(75, 100)
MoveObject (this, oven)

In the background a turnscript is always running:

foreach (inoven, GetDirectChildren (oven)) {
this.progress = this.progress - oven.temp

There is my problem. I don´t know what object I have to refer to. this.progress in the turnscript is wrong, I know that much. But how do I tell the game to look at each object individually and change its variables?

I could just spam the turnscript with

if (GetBoolean(ingredient1, "inoven")) {....
if (GetBoolean(ingredient2, "inoven")) {....
if (GetBoolean(ingredient3, "inoven")) {....

but there must be an easier way, that I just don´t know. I plan to add a lot of ingredients, so I´d like to avoid the IF spam.

I have spent waaay too much time trying to figure that out on my own.

I appreciate any help :)


You are SO close, you're probably gonna be mad when I tell you the problem! :)

foreach (iterator variable, list) { script }
                    ^ use this rather than "this"

foreach (inoven, GetDirectChildren (oven)) {
   inoven.progress = inoven.progress - oven.temp

Thank you very much!

I´ve spent hours browsing through the Quest documentation, but I got confused along the way. I had like 30 tabs open, looking for anything that contained the word "Object". ^^

Ha ha ha! (I'm laughing with you, not at you.)

You got that far the first game with only that one big problem? You also used the documentation? You also posted your relevant code along with your question, using the proper HTML formatting?

That's impressive, if you ask me.

If you need help with anything else, we'll be watching. (We are always watching. We never sleep. Bwahahahahaha!)


Only use this when the script is an object's script attribute.

Yeah, the documentation is really helpful for the beginner stuff. I just didn´t realize that baking food in an oven would be too much for me to handle. Haha.

Also, I don´t use that HTML voodoo. I use those pre-made commands (like in the tutorial). The first time I pressed the "Code View" button, was 4 hours ago to copy/paste my problem.

Thanks again. I´m sure I´ll be needing more help soon enough.

As expected, I need some more help :)

The "progress" variable from each object in the oven is correctly reduced. Now I want to set everything that reached the burning point to get the flag "burnt"

My turnscript looks like this:

foreach (inoven, GetDirectChildren (oven)) {
inoven.progress = inoven.progress - oven.temp
if (inoven.progress < 0) {
SetObjectFlagOn (???, "burnt")

Quest wants me to give a specific Object the "burnt" flag. Is there some sort of any or that object, that we were just talking about function?

Thanks for any help in advance!

SetObjectFlagOn (inoven, "burnt")


inoven.burnt = true

which is exactly the same thing.

I've not tried with SetObjectFlagOn, but for most functions that work on objects you have to choose "expression" before you can enter a variable, function, or anything that isn't a fixed object. Or just edit it in code view.

Now it works.

Thanks a lot!

Log in to post a reply.