...

View Full Version : Problem in NS script



lordofthesword8
07-03-2004, 07:23 PM
Hi, ive got a script and netscape is telling me me that it is not defined. Would anyone take a look and tell me whats wrong? Even if its just a hunch I would be gratefull. If you need anymore info about this script and the errors its giving me, send me an email or reply to this. :)

Thanks to anyone who can help me!





function attackcalc() {
if (document.fight.answer.value=="A") {
attackenemy()
enemyattack(0)
}
if (document.fight.answer.value=="B") {
enemyattack(parseInt(document.fight.herolevel.value))
}
if (document.fight.answer.value=="C") {
document.fight.location.value = 'magicwrite'
magiclist = new Array("Do you want to use:\rA. Fire Ball\r","Do you want to use:\rA. Fire Ball\rB. Meteor Ball\r","Do you want to use:\rA. Fire Ball\rB. Meteor Ball\rC. Shining Blade\r","Do you want to use:\rA. Fire Ball\rB. Meteor Ball\rC. Shining Blade\rD. Inferno\r","Do you want to use:\rA. Fire Ball\rB. Meteor Ball\rC. Shining Blade\rD. Inferno\rE. Final Blow")
level = parseInt(document.fight.herolevel.value.value)
document.fight.movelist.value = magicstring[level]
}
}

function fireball() {
if (parseInt(document.fight.yourcurrentmagic.value)>=5) {
alert("You cast a Fireball!")
var enemyhealth = parseInt(document.fight.enemycurrenthealth.value)
enemyhealth = enemyhealth-5
document.fight.enemycurrenthealth.value = enemyhealth
}
if (parseInt(document.fight.yourcurrentmagic.value)<5) {
alert("You do not have enough Magic left to cast this!")
}
enemyattack(0)
}

function magiccalc() {

if (document.fight.answer.value=="A") {
fireball()
}
if (document.fight.answer.value=="B") {
meteorball()
}
if (document.fight.answer.value=="C") {
shineingblade()
}
if (document.fight.answer.value=="D") {
inferno()
}
if (document.fight.answer.value=="E") {
finalblow()
}
}

function calccalc() {
var location = document.fight.location.value
if (location=="attackwrite") {
atackcalc()
}
if (location=="magicwrite") {
magiccalc()
}
}

function youwrite() {
var totalhealth = parseInt(opener.document.darkworlds.herolevel.value)
document.fight.heroname.value = opener.document.darkworlds.hero.value
document.fight.herolevel.value = opener.document.darkworlds.herolevel.value
document.images.youpic.src=opener.document.darkworlds.hero.value + ".gif"
document.fight.yourcurrenthealth.value = opener.document.darkworlds.health.value
document.fight.yourtotalhealth.value = totalhealth*20
totalmagic = parseInt(opener.document.darkworlds.herolevel.value)
document.fight.yourcurrentmagic.value = totalmagic*10
document.fight.yourtotalmagic.value = totalmagic*10
}

function enemywrite() {

enemyname = getenemyname()
enemylevel = getenemylevel()
document.fight.enemycurrenthealth.value = enemylevel*20
document.fight.enemytotalhealth.value = enemylevel*20
document.fight.enemyname.value = enemyname
document.fight.enemylevel.value = enemylevel
document.images.enemypic.src=enemyname + ".gif"

document.fight.enemycurrentmagic.value = enemylevel*10
document.fight.enemytotalmagic.value = enemylevel*10

}

function getenemyname() {
var loc = opener.document.darkworlds.location.value
var enemy = ""

switch(loc) {

case "mountain1write":
enemy = "Stone Snake"
break

case "mountain3write":
enemy = "Mountain Troll"
break

case "mountain6write":
enemy = "Elven Sentries"
break

}
return enemy
}

function getenemylevel() {
var loc = opener.document.darkworlds.location.value
var enemy = 0

switch(loc) {

case "mountain1write":
enemy = 1
break

case "mountain3write":
enemy = 2
break

case "mountain6write":
enemy = 3
break

}
return enemy
}

function attackwrite() {
document.fight.location.value = 'attackwrite'
document.fight.movelist.value = 'Do you want to:\r A. Attack \r B. Defend \r C. Cast a Spell'
}

function attackenemy() {
var yourattack = parseInt(document.fight.herolevel.value)
yourattack = yourattack*2
var enemyhealth = parseInt(docuemnt.fight.enemycurrenthealth.value)
enemyhealth = enemyhealth-yourattack
document.fight.enemycurrenthealth.value = enemyhealth
}

function start() {
youwrite()
enemywrite()
attackwrite()
}

LynxGrr
07-05-2004, 02:48 AM
What part is it saying is undefined? You have a line number for it?

Aside from that, this looks a bit odd


level = parseInt(document.fight.herolevel.value.value)

I dont think the second ".value" should be there

lordofthesword8
07-05-2004, 02:41 PM
The problem is when I use attackcalc() that function does not call and as a consequence, the functions i want it to call are not called. Any ideas??

Kor
07-06-2004, 01:57 PM
Try:

1. level = parseInt(document.fight.herolevel.value)

as Lynx said you had value.value...


2. document.fight.movelist.value = magicstring[level]

I dont see anywhere the array magicstring ?

lordofthesword8
07-07-2004, 11:14 AM
Ive now got rid of the .value.value error, and instead of magicstring[] it shoiuld have been magiclist[]. My Script is now working so thanks to all of you who have helped me get it working!!

LOTS8

Kor
07-07-2004, 11:26 AM
You are welcome :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum