Hi, I am currently making something for the game jam and, not gonna lie, i am probably a bit underprepared. I wanna make a Text RPG with a friend and i am mostly for coding there. However, i never managed to get a twine project really running because it’s just such a weird language to me. I get how the basics of it work, but when it comes to the more complicated stuff like this, my brain is at the current moment just not able to print out a solution.
The basic gist of what i wanna do is this: I want a simple fighting system with the player and one opponent as the enemy. Nothing fancy, just a very bare bones implementation. even if they just would repeatedly hit eachother, it would be fine, however, i have no idea what the setup could look like. no idea where to start, honestly.
Ok thats not exactly correct, i have this here:
=><=
''(print: $player's name)''
vs.
''(print: $opponent's name)''
<==
[Your HP are $player's currentHealth / $player's maxHealth]
[Your opponets HP are $opponents's currentHealth / $opponents's maxHealth]
(link-goto: "Attack", "Attack")
But I don’t know how to continue at (link-goto: “Attack”, “Attack”). How i am approaching this? What should be on the next screen? How do I make this loop “he moves, then he moves”?
Like, i don’t expect a full solution here, but because of the way you can manipulate what is on-screen with display and the other macros, I feel very overwhelmed.
(just for clarity, i am mostly used to Java, so if you explain it to me in object-oriented terms it would be very appreciated.
I know that Twine code works differently depending on what version you use (Sugarcube, Harlowe, etc), so i cant give an exact answer. But there are a few ways to handle it.
At the top of the screen calculate any attacks you want for one side, then have “Attack” link to a near identical scene that calculates the attacks for the other side. Then you just need a check at the end for each passage for if someones hp has reached 0 or less than 0. This also allows you to have different text for each side attacking.
Additionally, you could make the link redirect to the same passage and check what to calculate via variables like $playerTurn. That would be more complicated i believe, but ive seen it done well
Hope this helped!
1 Like
Thanks for the reccomendation!
I tried to implement it the way you told me and i made some decent progress… but now i am kinda stuck because it feels like tunneling so many things together just to get some basic things done, and now I feel very overwhelmed. Can i maybe dm you?
EDIT: Actually after testing it seems like i did it almost right. the only problem i have right now is that i struggle a bit with extracting the return value of a macro in the way i need it…
(display: (macro:[(output-data: "SlimeAttack")]))
caused an error: The (display:) macro’s 1st value is a custom macro (with no params), but should be a string.the (display:) macro must only be given a string.
Hard to tell what’s causing the error, especially since I don’t use macros too much . It seems like it might be a formatting issue with output-data. If you’re trying to just print “SlimeAttack” then there are other ways to do so, but it seems like you’re trying to pass it into output data as a variable. If so, then I don’t believe the quotation marks are allowing that and are making it read as a string.
https://twine2.neocities.org/#macro_output-data
And yes, if you want to dm me you can! I don’t have much experience in Twine, especially in Harlowe, but I’d be happy to help!
1 Like
Yeah that’s it, the thing is, I don’t know how to say twine that it should take out the string out of the macro instead of reading the macro as a string. In java I only have to use “” for the differentiation, but in twine I don’t know how to do that.
I could be mistaken, but I believe that removing the quotations would fix that. As long as those are there, it’s just reading it as a string. If just removing those doesn’t work, then you might need to check the Harlowe cookbook. Sorry I can’t give a more precise answer!
1 Like