the_bob
06-13-2004, 08:15 PM
ok, one of my functions doesn't work. not only is it not working, it is also causing the text in my text boxes to not load. here is the whole page
<html>
<head>
<title>Wishing Well - Beta Version 0.1.2</title>
<h1 align="center"><font size = "5" font="Verdana">Wishing Well - Beta Version 0.1.2</font></h1><br>
<script LANGUAGE="Javascript" type="text/javascript">
var health = 50;
maxhealth = 50; //-- Player Stats
var strength = 15;
var defence = 5;
var level = 1;
var exp = 0;
var expntl = 50;
var gold = 5;
var mhealth=0; //-- Monster Stats
var mstrength=0;
var mdefence=0;
var currentcity="Barino";
var currentmonster=1; //--Miscellaneous Varibales
var moron = "...moron... <_<";
var counter = 0;
function levelup() {
if (exp >= expntl) {
exp = exp - expntl;
expntl = expntl * 2;
level = level + 1;
health = health + (10 * level);
maxhealth = maxhealth + (10 * level);
strength = strength + (5 * level);
defence = defence + (5 * level);
alert("Health: " + health);
alert("Strength: " + strength);
alert("Defence: " + defence);
} else {
alert("You do not yet have the experience to level up.");
alert(moron);
}}
function revive() {
if (health < 1) {
health = maxhealth
alert("Health: " + health);
} else {
alert("You are not dead.");
alert(moron);
}
}
ID=window.setTimeout("Update();",20);
function Update() {
counter ++;
document.form1.health.value="Health: " + health + "/" + maxhealth;
document.form1.strength.value="Strength: " + strength;
document.form1.defence.value="Defence: " + defence;
document.form1.level.value="Level: " + level;
document.form1.exp.value="EXP: " + exp + "/" + expntl;
document.form1.currentcity.value="Current City: " + currentcity;
document.form1.gold.value="Gold: " + gold;
ID=window.setTimeout("Update();",20);
}
function inn() {
if (gold >= 20) {
gold = gold - 20;
health = maxhealth
alert("Health: " + health + "/" + maxhealth);
alert("Gold: " + gold);
} else {
alert("You, sadly, no not have the funds to rest at the inn.");
alert(moron);
}}
function bossbattle(){
if (health > 0) {
if (currentcity=="Barino"){
bhealth=75;
bstrength=35;
bdefence=20;
if ((strength - bdefence) > 0) && ((bstrength - defence) > 0) {
bhealth = bhealth - (strength - bdefence);
alert("You attacked the boss for " + (strength - bdefence) + " damage.");
health = health - (bstrength - defence);
alert("The boss attacks you for " + (bstrength - defence) + " damage.");
}
if ((strength - bdefence) < 0) {
alert("The boss laughs at your pitifullness. He lets you leave without harming you.");
alert("You should train before facing him again.");
}
if ((bstrength - defence) < 0) {
alert("You slay the boss with your first attack.");
alert("You sure are strong...");
exp = exp + 50;
gold = gold + 100;
if (exp >= expntl) {
levelup();
}
}
}}}
</script>
</head>
<body>
<form NAME="form1">
<input type="button" value="Boss Battle" onclick="bossbattle()">
<input type="button" value="Random Battle" onclick="randombattle()">
<br><br>
<input type="button" value="Visit Inn" onclick="inn()">
<input type="button" value="Revive" onclick="revive()">
<hr>
<input type="text" NAME="health" SIZE="40">
<input type="text" NAME="currentcity" SIZE="40"><br>
<input type="text" NAME="strength" SIZE="40">
<input type="text" NAME="defence" SIZE="40"><br>
<input type="text" NAME="level" SIZE="40">
<input type="text" NAME="exp" SIZE="40"><br>
<input type="text" NAME="gold" SIZE="40">
</form>
<hr>
<img SRC="wishingmap.gif">
</body>
</html>
if i take this out, the textboxes work fine
function bossbattle(){
if (health > 0) {
if (currentcity=="Barino"){
bhealth=75;
bstrength=35;
bdefence=20;
if ((strength - bdefence) > 0) && ((bstrength - defence) > 0) {
bhealth = bhealth - (strength - bdefence);
alert("You attacked the boss for " + (strength - bdefence) + " damage.");
health = health - (bstrength - defence);
alert("The boss attacks you for " + (bstrength - defence) + " damage.");
}
if ((strength - bdefence) < 0) {
alert("The boss laughs at your pitifullness. He lets you leave without harming you.");
alert("You should train before facing him again.");
}
if ((bstrength - defence) < 0) {
alert("You slay the boss with your first attack.");
alert("You sure are strong...");
exp = exp + 50;
gold = gold + 100;
if (exp >= expntl) {
levelup();
}
}
}}}
where did i go wrong? IE says it is a syntax error
<html>
<head>
<title>Wishing Well - Beta Version 0.1.2</title>
<h1 align="center"><font size = "5" font="Verdana">Wishing Well - Beta Version 0.1.2</font></h1><br>
<script LANGUAGE="Javascript" type="text/javascript">
var health = 50;
maxhealth = 50; //-- Player Stats
var strength = 15;
var defence = 5;
var level = 1;
var exp = 0;
var expntl = 50;
var gold = 5;
var mhealth=0; //-- Monster Stats
var mstrength=0;
var mdefence=0;
var currentcity="Barino";
var currentmonster=1; //--Miscellaneous Varibales
var moron = "...moron... <_<";
var counter = 0;
function levelup() {
if (exp >= expntl) {
exp = exp - expntl;
expntl = expntl * 2;
level = level + 1;
health = health + (10 * level);
maxhealth = maxhealth + (10 * level);
strength = strength + (5 * level);
defence = defence + (5 * level);
alert("Health: " + health);
alert("Strength: " + strength);
alert("Defence: " + defence);
} else {
alert("You do not yet have the experience to level up.");
alert(moron);
}}
function revive() {
if (health < 1) {
health = maxhealth
alert("Health: " + health);
} else {
alert("You are not dead.");
alert(moron);
}
}
ID=window.setTimeout("Update();",20);
function Update() {
counter ++;
document.form1.health.value="Health: " + health + "/" + maxhealth;
document.form1.strength.value="Strength: " + strength;
document.form1.defence.value="Defence: " + defence;
document.form1.level.value="Level: " + level;
document.form1.exp.value="EXP: " + exp + "/" + expntl;
document.form1.currentcity.value="Current City: " + currentcity;
document.form1.gold.value="Gold: " + gold;
ID=window.setTimeout("Update();",20);
}
function inn() {
if (gold >= 20) {
gold = gold - 20;
health = maxhealth
alert("Health: " + health + "/" + maxhealth);
alert("Gold: " + gold);
} else {
alert("You, sadly, no not have the funds to rest at the inn.");
alert(moron);
}}
function bossbattle(){
if (health > 0) {
if (currentcity=="Barino"){
bhealth=75;
bstrength=35;
bdefence=20;
if ((strength - bdefence) > 0) && ((bstrength - defence) > 0) {
bhealth = bhealth - (strength - bdefence);
alert("You attacked the boss for " + (strength - bdefence) + " damage.");
health = health - (bstrength - defence);
alert("The boss attacks you for " + (bstrength - defence) + " damage.");
}
if ((strength - bdefence) < 0) {
alert("The boss laughs at your pitifullness. He lets you leave without harming you.");
alert("You should train before facing him again.");
}
if ((bstrength - defence) < 0) {
alert("You slay the boss with your first attack.");
alert("You sure are strong...");
exp = exp + 50;
gold = gold + 100;
if (exp >= expntl) {
levelup();
}
}
}}}
</script>
</head>
<body>
<form NAME="form1">
<input type="button" value="Boss Battle" onclick="bossbattle()">
<input type="button" value="Random Battle" onclick="randombattle()">
<br><br>
<input type="button" value="Visit Inn" onclick="inn()">
<input type="button" value="Revive" onclick="revive()">
<hr>
<input type="text" NAME="health" SIZE="40">
<input type="text" NAME="currentcity" SIZE="40"><br>
<input type="text" NAME="strength" SIZE="40">
<input type="text" NAME="defence" SIZE="40"><br>
<input type="text" NAME="level" SIZE="40">
<input type="text" NAME="exp" SIZE="40"><br>
<input type="text" NAME="gold" SIZE="40">
</form>
<hr>
<img SRC="wishingmap.gif">
</body>
</html>
if i take this out, the textboxes work fine
function bossbattle(){
if (health > 0) {
if (currentcity=="Barino"){
bhealth=75;
bstrength=35;
bdefence=20;
if ((strength - bdefence) > 0) && ((bstrength - defence) > 0) {
bhealth = bhealth - (strength - bdefence);
alert("You attacked the boss for " + (strength - bdefence) + " damage.");
health = health - (bstrength - defence);
alert("The boss attacks you for " + (bstrength - defence) + " damage.");
}
if ((strength - bdefence) < 0) {
alert("The boss laughs at your pitifullness. He lets you leave without harming you.");
alert("You should train before facing him again.");
}
if ((bstrength - defence) < 0) {
alert("You slay the boss with your first attack.");
alert("You sure are strong...");
exp = exp + 50;
gold = gold + 100;
if (exp >= expntl) {
levelup();
}
}
}}}
where did i go wrong? IE says it is a syntax error