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 2 of 2
  1. #1
    Regular Coder GSimpson's Avatar
    Join Date
    Aug 2006
    Location
    New Zealand
    Posts
    268
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Question can't find error

    Ok i cant find the problem, in this script its supposed to add up the total of my attack and defense. But when i press the button that adds one to the attack variable and i press the button that displays the total, it still says 2. The default level is 2. I dont know how why its not adding it to the total. Heres the script:

    <!-- Begin
    var armour=3;
    var defense=1;
    var attack=1;
    var gp=0;
    var total=defense+attack;

    function stats(){
    var disp=0;
    if (disp==0) { alert("Your Attack Level Is:"+attack+"\nYour Defense Level Is:"+defense+"\nYour Armour Bonus

    Is:"+armour+"\n_________________\nINVENTORY\nYou Have "+ gp +" Gold Pieces\n\n_________________\nYour Total Level

    Is:"+total+"\nWith a bonus of "+armour+" Defense Points");}
    }

    function raiseattack(){
    var goupa=0;
    if (goupa==0) { attack++; alert("You gained One Level In Attack!\nIts now:"+attack); }
    }

    function raisedefense(){
    var goupd=0;
    if (goupd==0) { defense++; alert("You gained One Level In Defense!\nIts now:"+defense); }
    }

    // End -->
    The internet is my Sandbox, and notepad is my Spade n' Bucket.

  • #2
    Regular Coder GSimpson's Avatar
    Join Date
    Aug 2006
    Location
    New Zealand
    Posts
    268
    Thanks
    9
    Thanked 0 Times in 0 Posts
    ok i redone my script and it works now.
    The internet is my Sandbox, and notepad is my Spade n' Bucket.


  •  

    Posting Permissions

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