This is what I got, a friend helped me out so button could only be pressed once, I actually have no clue on html
<!DOCTYPE html>
<html>
<body>
<h1 ALIGN=center>
<button id="boton" onclick="myFunction()">Try to hit</button>
<h2 ALIGN=center id="demo"></p ALIGN=center>
<script>
function myFunction() {
document.getElementById("boton").disabled = true;
var x = Math.floor((Math.random() * 20) + 1);
document.getElementById("demo").innerHTML =x;
if ( x <= 5 ) {
document.getElementById("demo").innerHTML += "<p>You fail your attack";
} else {
document.getElementById("demo").innerHTML += "<p>You hit";
}
}
</script>
</h1 ALIGN=center>
</body>
</html>
the text was something different but this is just fine for you guys to understand what I want to do :P
I tried replacing "You fail your attack" with "
Fail but, as you can conclude, no result
It would be awesome too to keep the random number hidden, and yes, I know there are better ways to do this but, those were too hard for me, sorry.
So, if anyone is willing to kindly help me, thanks in advance
Comments
Plus, I had introduced a spoiler that now is dissapeared for some reason, i'll just resend it and explain myself
Version: Harlowe 2.0.1
In my story this is something that happens after you decide to either do a thing or another, so you can dodge this event or autowin it with other route, it won't be frustrating at all, but I want to:
Make it random A or B outcome, maybe even without the reader/player knowing what's the numerical result, just the forced path (or forced different paths) that he can take from here.
I tried to just copy and paste the Tw-link thingy I can read when inspecting an element, it didn't either work out, so, resuming:
What is "Harlowe 2.0.1's way" to create a link from a scrpit
How can I make in html the number to exist but not show?
You can use:
A. a (link:) macro to show a single click link.
B. the combination of a (random:) macro, a (set:) macro, and a temporary variable to obtain the random value.
C. an (if: ) macro and an (else: ) macro to check the temporary variable to determine what to do next.
D. a Named hook combined with a (replace:) macro to update a portion of the page.
The code would look something like the following:
Now I know where to find most of the stuff I'd work with, really, this is way more simple than understanding javascript, that is a pain in the ass for a non-native english speaker as me