Conversations and loops

Abigail Storm
05 Dec 2016, 21:45

So, I figured out how to make a conversation. However, I cannot figure out how to loop the conversation back to the beginning until a player chooses to exit the conversation. can I have some help?


The Pixie
05 Dec 2016, 22:04

It is not trivial. You will need a function that will show the menu, and then, after the choice is made, and the result shown, will call itself to do the next step. You will also need some kind of data structure to hold the responses too, which is not easy with the on-line editor.

Are you wanting a branching conversation, where one choice leads to a new set of choices at the next step? Or a simple list of topics, with End conversation as the last option?


Abigail Storm
05 Dec 2016, 22:51

Simple list of options. I made one, but its taking forever to load.


Abigail Storm
05 Dec 2016, 23:38

I actually managed to do it! I found other, similar instances, and did some trial-and-error. Now my game just needs to be polished.


hegemonkhan
05 Dec 2016, 23:44

there's two main ways:

  1. using Functions, an example:

(do NOT do this without a way to end/terminate the looping, as the example does NOT end/terminate the looping: it's an endless/infinite loop, which will crash quest, as while the looping is infinite, quest's and the computer's resources are finite)

(this is just an example of how to loop with using a Function - but is not a proper example of a looping Function)

<game name="example_game">
  <attr name="start" type="script">
    example_function
  </attr>
</game>

<function name="example_function">
  msg ("hi")
  example_function
</function>

// output:
hi
hi
hi
hi
... and on and on, until quest/computer, runs out of resources, and quest (or the computer --- but this won't happen with quest) crashes

  1. or, using a Script Attribute, an example:

(same stuff for this as said for using a Function, it's an endless/infinite loop, so do NOT do this, you need a way to end/terminate the looping)

<game name="example_game">
  <attr name="start" type="script">
    example_script_attribute
  </attr>
  <attr name="example_script_attribute" type="script">
    msg ("hi")
    invoke (game.example_script_attribute) // or: do (game, "example_script_attribute")
  </attr>
</game>

// output:
hi
hi
hi
hi
... and on and on, until quest/computer, runs out of resources, and quest (or the computer --- but this won't happen with quest) crashes

here's a ton of example of looping Functions (they're a bit more advanced, but at least you get to see some of them / for ideas):

http://textadventures.co.uk/forum/samples/topic/4988/character-creation-crude-code-and-sample-game

ask if you need help, if you need help understanding the code (if you're new to coding), or need explanation or whatever.


Abigail Storm
05 Dec 2016, 23:58

Thanks! I made the conversation a function, and treated it as such. I then called the function within the function. it works beautifully, and I'm very proud of myself for it.


hegemonkhan
06 Dec 2016, 00:05

Congrats! Any success is another step in slowly learning to code! Slowly the successes build-up, and you start to learn to code


Abigail Storm
06 Dec 2016, 00:09

I felt really proud of myself, because I managed to achieve my result entirely through the GUI on the online version. (I'd have the Windows version if I was on a PC, but I have a Mac, so I have to make do.


hegemonkhan
06 Dec 2016, 00:13

ya, unforutnately, Alex and co, don't seem to have anyone who can convert (compile/r?) quest's coding into apple's coding, or maybe it's not possible (or just not worth the effort), though I think it should be... but you'd need someone who can and would do it.


Abigail Storm
06 Dec 2016, 00:15

I might ask for a PC for my birthday if I continue to use Quest. What processing power do you think it'd require? I'd be looking for something I could buy with my birthday money.


Abigail Storm
06 Dec 2016, 00:17

Also, I really wish I could get some beta testers, but I can't, and I don't know what to test for, which really sucks.


hegemonkhan
06 Dec 2016, 00:25

unless you're making some enormous massive uber RPG, any modern computer will be fine for processing code. Coding doesn't take much processing power (and computers are more and more powerful and have more and more space/memory, so coding really shouldn't ever be an issue in general. You can do bad or wrong code, but that's bad/wrong coding on your part, not the computer's fault in failing to handle it)

You only really need high performance (processing power) and high space/memory computer if you're doing graphical (especially 3D) coding/programming of things/software.


there is a bit of a difference between PCs and Apples... it takes some getting used to, in switching from one to the other...


I myself, when I was a kid, my family used Apples (Apple 2/e/ii whatever it is called, and Macs --- this after Apple 2/e/ii's and before Power Macs, which is before before Macbooks and safari, basically non-internet era computers, well you could use AOL's dialup internet... ugh), and I only got a PC (and the internet) when I was like 16 in high school...

I personally like PCs better, initially just for the gaming industry (Apples didn't have as much games, but they had some really cool good games), and now with the more "open-ness" (programmable/hackable) of PCs' system (though it's also more frustrating too).


Abigail Storm
06 Dec 2016, 00:27

Okay. Yes! It just sucks that I can't do health. Oh, I just remembered. If I really wanted, I could spend the money I was going to spend on a sewing kit on a computer, instead.


Abigail Storm
06 Dec 2016, 00:30

And sorry for my rant, I want to create an Oregon Trail inspired game next. I don't think I can do health, however. And I definitely can't do turn scripts, which sucks. I do need to polish this game first, but that would require some beta testing, and the first game is too dark to share with any of my potential beta testers.


hegemonkhan
06 Dec 2016, 00:39

Can you do the special 'changed' Script Attributes? They almost do the same effect as Turnscripts.

Also, do you have the 'set a variable or attribute' Script ??? If you do, you can do 'health/life/hp/etc' Integer or whatever Attribute.

I don't know the web/online version very well, and I often confuse it with the Game Book version, lol-argh.

(I miss being able to play my old '7th Guest' and 'The Dig' and 'Myst' games, also my friend, when we were little had an Indiana Jones game, the Apple had a lot of cool games, I really miss, 'Where in the USA/World/Etc is Carmen SanDiego" --- I got my impressive knowledge of geography from that game, lol. Oregon Trail, a classic. They've had other 'Trail' games too, Amazon Trail, for example)


and ya, Sewing machines are expensive (even the cheapest ones are still expensive but the best ones --- yikes, so expensive!)... I'll learn to sew by hand...


Abigail Storm
06 Dec 2016, 00:45

I can do turn scripts, sort of. I'm thinking each room is a different day. I need help programming diseases, however. I also need some cool made up disease names, as I'm doing it in space.


hegemonkhan
06 Dec 2016, 01:08

diseases/conditions/status_effects:

you can either use a 'string' Attribute if you only want to have one disease/condition/status_effect in effect at any time:

(err, the 'player' Player object would be more logical to use as the Object, instead of my use of the 'game' Game Object, meh)

game.condition_string_attribute = "normal"
game.condition_string_attribute = "poisoned"
game.condition_string_attribute = "dead"
game.condition_string_attribute = "undead"
game.condition_string_attribute = "paralyzed"
game.condition_string_attribute = "petrified"
game.condition_string_attribute = "stunned"
game.condition_string_attribute = "asleep"
game.condition_string_attribute = "unconscious"
game.condition_string_attribute = "confused"
game.condition_string_attribute = "silenced"
game.condition_string_attribute = "blinded"
game.condition_string_attribute = "crippled"
game.condition_string_attribute = "disabled"
game.condition_string_attribute = "cursed"
game.condition_string_attribute = "blessed"
etc etc etc

or, you can use a Stringlist Attribute if you want to have multiple diseases/conditions/status_effects in effect at any time:

game.condition_stringlist_attribute = split ("normal", ";")
game.condition_string_attribute = split ("poisoned;confused", ";")
game.condition_string_attribute = split ("poisoned;confused;silenced;petrified;paralyzed;stunned;cursed;blinded", ";")
etc etc etc

or, other method:

game.condition_stringlist_attribute = NewStringList()

list add (game.condition_stringlist_attribute, "normal")
// game.condition_stringlist_attribute = split ("normal", ";")

list remove (game.condition_stringlist_attribute, "normal")
// game.condition_stringlist_attribute = split ("", ";")

list add (game.condition_stringlist_attribute, "poisoned")
list add (game.condition_stringlist_attribute, "confused")
// game.condition_stringlist_attribute = split ("poisoned;confused", ";")


and here's guides on using lists/dictionaries:

http://docs.textadventures.co.uk/quest/guides/using_lists.html
http://docs.textadventures.co.uk/quest/using_dictionaries.html

http://textadventures.co.uk/forum/samples/topic/5137/list-and-dictionary-extensive-guide-by-hk
http://textadventures.co.uk/forum/samples/topic/5138/explore-and-travel-code-sample-by-hk


Abigail Storm
06 Dec 2016, 01:25

I checked, and I can't do it as an attribute. However, I can do it as a flag, possibly.


Abigail Storm
06 Dec 2016, 01:27

I'm going to move this to its own topic.