Trouble with flags (solved)

So I'm running through the tutorial, and have gotten to the bit where it has you use an item to revive a guy, and the it wants me to make it so that when I use the item again, the text changes. Problem is, when I use the item, It shows me both the item used text, and the text I want it to display when the item is used a second time. It seems to me that it's running both scripts at once, when I want it to do one and then switch to the other. It wants me to script it to check for the flag and I cant figure it out.

This is the link for the part of the tutorial I'm on: http://docs.textadventures.co.uk/quest/tutorial/more_things_to_do_with_objects.html

This is what the tutorial is telling me to do: "Notice what happens when you type “use defibrillator on bob” a second time - you get the same response again. You should know how to fix this now - update your “use defibrillator on bob” script to check for the “alive” flag. Update this now." I can't figure this bit out


You are not alone
https://textadventures.co.uk/forum/quest/topic/8etnyofloecugeiqookcaw/newbie-tutorial-help-bob-the-defibrillator-solved
http://textadventures.co.uk/forum/quest/topic/8qxlobyu8koyqc6y1_1cng/need-help-on-quest-tutorial-more-things-to-do-with-objects


I figured it out two seconds ago and feel incredibly dumb. Learning to think like a computer is difficult. Essentially the thought process it has to go through is "does it have flag x? no? okay next line of script. Give it flag x." and that's what tripped me up. Spent an hour an a half trying to figure that out though. Thanks for the help! I really appreciate it.


That happens to everyone ^_^ it's definitely a learning curve. You'll get the hang of it the more you look at code and practice it first-hand. Matter of fact, I would go as far to say that you should aim to practice writing out the code in the code-view when you can, and use the GUI as little as possible. I say that because writing things out in code-view (once you get proficient) will save you tons and tons of time.

Anonynn.


it takes awhile to train your brain to think in terms of 'if -- code -- computer' logic, it's kinda like "should I do this or should I do that", except that it's: "if this/if I do this or if that/if I do that":

(we actually do think this way, but it's natural/instinctive/sub-consciously, so we aren't used to doing it cognitively, and thus it takes time to train your cognitive brain functionality for this mentality/thought-process)

animal_object.type_string_attribute = "lion"

if (animal_object.type_string_attribute = "lion") { // beginning of this 'if~else if' if block
// if ("lion" = "lion") { ---> TRUE, do the/its nested (indented) 'msg' script, and then goto the end of this 'if~else if' if block
  msg ("You run as fast as you can, hoping you're faster then the other person with you!")
} else if (animal_object.type_string_attribute = "deer") { // this gets skipped due to the above condition check (the 'if') being successful (TRUE)
  msg ("Ahhh, look at the cute deer, you stop to admire it, in total safety")
} // end of this 'if~else if' if block

// output: You run as fast as you can, hoping you're faster then the other person with you!

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

animal_object.type_string_attribute = "deer"

if (animal_object.type_string_attribute = "lion") { // beginning of this 'if~else if' if block
// if ("deer" = "lion") { ---> FALSE, goto the next (and last) condition check (the 'else if') of this 'if~else if' if block
  msg ("You run as fast as you can, hoping you're faster then the other person with you!")
} else if (animal_object.type_string_attribute = "deer") {
  msg ("Ahhh, look at the cute deer, you stop to admire it, in total safety")
} // end of this 'if~else if' if block

// output: Ahhh, look at the cute deer, you stop to admire it, in total safety

when you're done with the tutorial, XanMag has a tutorial 2 game 'templates and tutorial', to help bridge the huge gap between the tutorial and trying to do stuff on your own (trying to make your own game): http://textadventures.co.uk/forum/games/topic/5940/quest-tutorials-and-templates-published

and here's a more detailed guide on Attributes and the 'if' Script usage:

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk

and there's also onimike's youtube videos, but I don't know the link to them (and I usually total forget about them existing, so, this is rare I'm remembering them, lol)


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

Support

Forums