Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2004
    Location
    Coventry, UK
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Problem in NS script

    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()
    }

  • #2
    New Coder
    Join Date
    May 2004
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What part is it saying is undefined? You have a line number for it?

    Aside from that, this looks a bit odd

    Code:
    level = parseInt(document.fight.herolevel.value.value)
    I dont think the second ".value" should be there
    "The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect."

    --Tim Berners-Lee, W3C Director and Inventor of the World Wide Web

  • #3
    New Coder
    Join Date
    Jun 2004
    Location
    Coventry, UK
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Attackcalc() is the problem

    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??

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    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 ?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    New Coder
    Join Date
    Jun 2004
    Location
    Coventry, UK
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    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

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts

    Thumbs up

    You are welcome
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •