Im having a problem that is really throwing me through a bind. Heres my code, basically, the second button wont call fightScene(), but fightScene is usable straight from the code.
I took out some bits that werent important for both size constraints and just so no one steals it... its a very new project of mine, using it for a school project. Anything anyone can tell me would be great thanks!
<script>
var damage = 10;
var enemyHealth;
var fightText = "You come across a shady looking figure. He pulls his blade and you pull your weapon.";
function nextThing() {
x = Math.floor((Math.random() * 4) + 1);
if (x == 1) {
woodsWalk();
}
if (x == 2) {
riverWalk();
}
if (x == 3) {
caveWalk();
}
if (x == 4) {
shadyFigure();
}
function shadyFigure() {
document.getElementById("output").innerHTML = fightText;
document.getElementById("forwardButton").disabled = true;
document.getElementById("continueButton").style.visibility = "visible";
enemyHealth = 50;
fightScene();
}
function fightScene() {
if (enemyHealth > 0) {
enemyHealth = enemyHealth - 10;
fightText = fightText + "<br/> You deal " + damage + " damage. <br/> Enemy Health: " + enemyHealth;
document.getElementById("output").innerHTML = fightText;
} else {
document.getElementById("continueButton").style.visibility = "hidden";
document.getElementById("forwardButton").disabled = false;
nextThing();
}
}
}
</script>
<table border="1" width="80%" align="center">
<tr>
<td width="60%">
<button onclick="nextThing()" id="forwardButton">Forward</button>
<br/>
<!--Make an image-->
</td>
<td width="20%" valign="top">
<p id="items">Items:</p>
</td>
</tr>
<tr>
<td colspan="2">
<p id="output"></p>
<button onclick="fightScene()" style="visibility:hidden; float:right" id="continueButton">Continue</button>
</td>
</tr>
</table>