Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Twine 2|Harlowe 2.0.1 - Problems with coding another mini-game...

edited May 2017 in Help! with 2.0
Okay. Here's the thing. I'm trying to get this frankly simple word game based on Last Letter/Shiritori programmed, and I'm having obscene numbers of problems with it. Most of it, I'm sure I can work out with a (few) good nights' sleep and some serious poking. However, I'm running into the same problems over and over again, so I'm going to dump this out here and see if anybody is willing to help me figure out at least a small part of it. (I'm not giving up and dumping my programming problems on the forum, I'm just sticking it out there to see if someone can figure it out faster than I can. (I'm sure someone can. I'm not really that great with programming. Only been doing this for half a year. Sporadically, at that.))

What I have so far are two passages, a bunch of arrays (one of which is my '$All_Words' array, and then there are the two sets of alphabetical arrays ('$Word_Starts_A' and '$Word_Ends_B' (and all the other letters involved))), three so-to-speak AI characters, and the player character.

All of the arrays are in the first passage, and that's about it. This passage is, however, set to (display:) the second passage.

What I'm trying to do is have Richter's "Catch" (which is the word that starts the game in-story), when clicked, start a timer. Which it does. The nifty little line of code below works perfectly.
(text-color: red)[|Begin>["Catch."]](click: ?Begin)[(live: 1s)[(set: $tick to it + 1)]]

Once the timer starts, the game pops up three options randomly chosen out of the '$All_Words' array for the player to (possibly) click on to add to the list of words. I had this working, but then re-did my arrays and basically stripped out all of the original coding, so... I need to fix that. (I will probably do so tomorrow on my lunch break.)

It's the stuff that goes along with that timer that doesn't want to work. Namely, me trying to get one of the 'AIs' to put up a word after x seconds. And this little piece of code is... not working. To say the least.
(set: $Catch_Word to (either: ...$Word_Starts_H))(set: $Player to (either: "Richter","Aster","Marta"))(set: $Catch_Post to 1 + (either: 1,2,3,4,5,6))
(if: $Catch_Post equals $tick)[(append: ?Catch_Game)[(if: $Player is "Marta")[(text-color: yellow)["$Catch_Word"]](if: $Player is "Aster")[(text-color: green)["$Catch_Word"]](if: $Player is "Richter")[(text-color: red)["$Catch_Word"]]]]

All of the math on that first line works, all of the character word stuff works... but I can't get the word to post when the $tick gets to the number $Catch_Post rolled. It just sits there from the get-go. This is probably me using a faulty macro, as it keeps telling me, but I don't know how to write that to make it work. (Relative newbie, with definite newbie mistakes.)

Also, I realize I need to, once the word's been posted, re-roll the number to add to $Catch_Post, re-roll the $Player, and figure out what $Word_Starts letter I'll need by finding the $Word_Ends array the previous word belongs to. Also, I'll be adding a penalty/shuffle to the player's three options if a word isn't posted by them within 20 seconds, or if the word doesn't start with the correct letter.

...I think I bit off more than I can chew, to be honest.
Something in my brain is telling me that what I'm trying to do can be done. I just don't know what the heck I'm doing. So even if it's just hints on how to fix a single part of my giant mess, I'll be happy to see if it's enough to get the ball rolling again or if I'm just... stuck.

To recap, the three biggest problems I'm having:
1) How is this supposed to be written?
(if: $Catch_Post equals $tick)
2) How do I re-roll the $Player and $Catch_Post additive variables?
3) And what would you feed the string "Home" to in order to make it identify the $Word_Ends_E array as containing it?


  • I can quickly answer your last two questions:

    1. The (if: ) macro's documentation states the expression your passing is a Boolean, and the Boolean data documentation lists the comparison/logic word-based operators that can be used with this data type. You will notice that equals is not one of them, try is instead.

    2. The Array data documentation lists the comparison/logic word-based operators that can be used this data type, and the list includes examples of how to determine if a String value (like "Home") is within an Array.

    The questions within the rest of your post will require more thought, it is a pity you are not using SugarCube which includes the ability to create custom macros/widgets.
Sign In or Register to comment.