Hey, I've been a user of Chyoa for a very long time (I believe since it took this webname), but it has been off and on and I've mostly stayed within fanfiction. I totally missed the ability to do more complex variables. I've read through the documentation but I had three questions. Can a variable be randomized? Example: on an attack decrease life by 3 to 8. Can arrays be created/used? Can threads be looped (such as with a battle scene where an action is taken, the results are displayed, the back to the battle passage until conclusion)? I have little programming knowledge outside of Twine. I was looking at doing a story using variables, but wanted to check if any of the above where possible before I got too deep into planning. Thanks. Archer
No, but this feature has been planned for something like four years now... so I imagine it will be implemented eventually. No, but there's nothing stopping you from creating several variables and naming them "array1", "array2", ... Yes, you can use link chapters to loop stories until a certain condition is met. Something like: Battle Menu - indicates your and your opponent's stats with perhaps flavour text based on those variables Attack - conditional flavour text for dealing damage - enemy's HP decreases by X Enemy attacks you - conditional flavour text for taking damage - your HP decreases by Y - can only be accessed if enemy HP > 0 Return to Battle Menu - link chapter (i.e. empty and invisible) that automatically redirects reader to Battle Menu - can only be accessed if your HP > 0 Play Defeat Scene - can only be accessed if your HP <= 0 Play Victory Scene - can only be accessed if enemy HP <= 0 Heal - conditional flavour text for dealing damage - your HP increases by Z Enemy attacks you- conditional flavour text for taking damage - your HP decreases by Y Return to Battle Menu - link chapter to Battle Menu - can only be accessed if your HP > 0 Play Defeat Scene - can only be accessed if your HP <= 0 Use Item - some flavour text Polymorph Potion - effect... Magic Amulet - effect... etc... This would loop infinitely until either your HP drops to 0 or less or the enemy's HP drops to 0 or less, at which point the reader is funneled into either the victory or defeat scene.
Insertnamehere, Thanks for the replies. I kind of suspected that is what I'd have to do for arrays, but wanted to check to make sure before I made more work than I needed to.
Hey archer15, Just going to chime in here with my own experience because it's pretty relevant to your questions (on battle scenes in particular). I have a story (https://chyoa.com/story/Paladin-Simulator.28810) that's meant to play like a RPG with a 'fully fleshed out' combat loop. Feel free to check it out, you might find some ideas to lift and/or improve on! Note that the lack of randomization and constraints in chapter conditional access (only 'AND' operators, with the changes in variables changed fixed per chapter etc.) all make it difficult to implement typical game mechanics without either forcing readers to click through a lot of screens & also doing a ton of work yourself to link many chapters. In fact, that's a large part of why I've put the story on hiatus! I've got the entire game-design side of the story planned out (and most of the story), but it's such a hassle to have to manually link 10 chapters for every action taken that I decided it's not worth working on until the game system gets reworked. It also doesn't help that spamming so many chapters caused a decent chunk of my followers to unfollow me... So if you want somebody to workshop ideas with or talk implementation, let me know
Bobbobbobthethir, While I used a battle as my example, it wasn't primarily what I was planning on doing, but thank you for your feedback. I used it as an example because it was something I knew people would understand. More details for anyone who wants to provide feedback. This is a Buffy the Vampire Slayer fanfic. The game/story is meant to be made up of a number of 'scripted' and random days. The scripted days are pretty straightforward and work like most games with the same choices always being presented. The random days would vary between play through. The game takes place in a school/college setting. The random days proceed through four phases, morning, day, evening, night. Each segment of the day would present two options that the player chooses for what they do. If I was doing this with Twine (I'm explaining this in case anyone sees a way I can do things better) is create a variable for time (will still do that) and an array for each time slot. So the day slot might have as possibilities, lunch, class, library, gym, etc. Each day two of those options would be drawn and those are the ones the player/reader would see as options for what they choose. So during the day it might show lunch or library, gym or class, lunch or gym, etc. I asked about randomization and arrays to see if there was a way to get that element, and looping because even though it might not look the same to the player, they keep ending back up in the same thread for their options. How I'll probably try it, because I'd like to keep some randomization, is have the players choose some random numbers early that will serve as the seed for the random days. Thanks to those who have given comments, they are appreciated.
One additional question - what is the limit on how many variables can be in a story/single chapter (if different). I have differing ideas on how much I might want to track and was wondering if there was a limit I should be concerned about.
Creating random numbers isn't possible yet. The closest thing that is still rather easy to achieve might be to create a frame with small white squares in it. Every square is linked with one of the chapter options and the reader is supposed to click to any position inside the frame. The "random" order of the squares (you'd defined) would give you some kind of randomness. (Though they could still choose from the chapter options.) That's another way to do it. There is a technical limit for the number of Conditions and Score Changes for each chapter. The exact number mostly depends on the length of the variable name. With a normal length, it should be possible to add at least 200 Score Changes in one chapter. If you add too many and save the chapter, the excess Score Changes are discarded. The technical limit for variables in a story is way higher. I think @Greyrock uses a lot of variables in their story, so they might be able to tell you how many variables won't be too many.
Hey! Is it possible to compare two different scores and give a 3rd score a value based on that comparison? Something like: if {score1} >{score2} you get 3 {points} , if {score1} <{score2} you get 0 {points} , if {score1} = {score2} you get 1 {points} If not can anyone think of a workaround? I can get to the end of the event but i can't differentiate between a bad event and a good event, and that can only be done by comparing the two values.
Currently, that isn't possible. It depends on how high score1 and score2 can be. If the number of states of score1 (and score2) is n, you would need 3n chapters E.g. n=4 (score1 and score2 can both be 0, 1, 2, or 3) Code: score1=0 ; score2=0 ; points + 1 score1=1 ; score2=1 ; points + 1 score1=2 ; score2=2 ; points + 1 score1=3 ; score2=3 ; points + 1 score1<1 ; score2>0 ; points + 0 score1<2 ; score2>1 ; points + 0 score1<3 ; score2>2 ; points + 0 score1<4 ; score2>3 ; points + 0 score1>0 ; score2<1 ; points + 3 score1>1 ; score2<2 ; points + 3 score1>2 ; score2<3 ; points + 3 score1>3 ; score2<4 ; points + 3 Another way might be to precalculate the winner in the respective chapters. For that, you would need a third variable point_difference. Player1 wins: Code: score1 + 1 ; point_difference + 1 Player2 wins: Code: score2 + 1 ; point_difference - 1 (If there is a way to get more points at once, adjust the numbers respectively.) At the end of the event, you can use the variable to see who is the winner: Code: point_difference = 0 ; points + 1 point_difference < 0 ; points + 0 point_difference > 0 ; points + 3