Jump to content

jburridge

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by jburridge


  1. function setCookie(c_name,value,exdays)
    {
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) +
    ((exdays==null) ? "" : ("; expires="+exdate.toUTCString()));
    document.cookie=c_name + "=" + c_value;
    }

    function getCookie(c_name)
    {
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i<ARRcookies.length;i++)
    {
    x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
    y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
    x=x.replace(/^\s+|\s+$/g,"");
    if (x==c_name)
    {
    return unescape(y);
    }
    }
    }
  2. Your variable characterBackpack doesn't exist when the first line is executed so you get an undefined variable error. Swap the order of the lines so you assign characterBackpack first then characterBackpackDisplay second.

     

    Your posted errors are similar undefined variable errors but the code you've posted provides no clues as to why.

     

    Welp, Thank you for reminding me that they are variables.. I swapped them around and also put "var" in front of them.. No more errors at all.

     

    I also changed

    world[0][0][0]=eventMove;

    to

    world[0][0][0]=eventMove();

     

    But... When I move I am still not receiving any "items". I believe their is something wrong with..

     

    movement.js

    //random loot function
    var randomLoot=loot[Math.floor(Math.random()*loot.length)];
    var randomRareLoot=rareLoot[Math.floor(Math.random()*rareLoot.length)];
    var randomInteger=Math.random()+11;
    var randomInteger2=Math.random()+11;
    
    function eventMove () {
        if (randomInteger==randomInteger2) {
            characterBackpack=characterBackpack+randomRareLoot;
        }
        else if (randomInteger==1||5||9) {
            characterBackpack=characterBackpack+randomLoot;
        }
    }
    

    items.js

    //One-Handed Weapons
    var infinityBlade="Infinity Blade"; // 4 dmg
    var crudeSword="Crude Sword"; // 2 dmg
    
    
    //Chest Armor
    var brokenArmor="Broken Armor"; // 5 health
    var superiorChestpiece="Superior Chestpiece"; // 10 health
    
    
    var loot=[];
    loot[0]=crudeSword;
    loot[1]=brokenArmor;
    
    var rareLoot=[];
    rareLoot[0]=infinityBlade;
    rareLoot[1]=superiorChestpiece;
    
  3. characterBackpackDisplay="Backpack: "+characterBackpack;
    characterBackpack="emptyyy";
    console.log(characterBackpackDisplay);

    For some reason that first line messes my whole script up, When commented out everything works again. I'm assuming theirs a syntax error?

     

    Some more code may help.

    var randomLoot=loot[Math.floor(Math.random()*loot.length)];
    var randomRareLoot=rareLoot[Math.floor(Math.random()*rareLoot.length)];
    var randomInteger=Math.random()+11;
    var randomInteger2=Math.random()+11;
    
    function eventMove () {
        if (randomInteger==randomInteger2) {
            characterBackpack=characterBackpack+randomRareLoot;
        }
        else if (randomInteger==1||5||9) {
            characterBackpack=characterBackpack+randomLoot;
        }
    }
    

    Again sorry for the questions, Some things I can't really google because I don't know where I'm going wrong... I don't know why it would break part of my array either?

     

    Heres my error

     

    ReferenceError: eventMove is not defined
    ReferenceError: characterBackpackDisplay is not defined
  4. I believe this may help as well

     

    items.js

    var loot=[];
    loot[0]=crudeSword;
    loot[1]=brokenArmor;
    
    var rareLoot=[];
    rareLoot[0]=infinityBlade;
    rareLoot[1]=superiorChestpiece;
    
    
    //One-Handed Weapons
    var infinityBlade="Infinity Blade"; // 4 dmg
    var crudeSword="Crude Sword"; // 2 dmg
    
    
    //Chest Armor
    var brokenArmor="Broken Armor"; // 5 health
    var superiorChestpiece="Superior Chestpiece"; // 10 health
    
  5. I keep receiving this error, I'm not really sure why. Any help is greatly appreciated.

    Also, If I don't put the random integer inside my function will it still generate new random numbers or will it only generate 1 random number and stay that way?

     

     

     

    " ReferenceError: math is not defined

     
     
    movement.js
    var randomLoot=loot[math.floor(math.random()*loot.length)];
    var randomRareLoot=rareLoot[math.floor(math.random()*rareLoot.length)];
    var randomInteger=math.random()+11;
    var randomInteger2=math.random()+11;
    
    //each new movement starts this function to find a random item
    
    function eventMove () {
        if (randomInteger==randomInteger2) {
            characterBackpack+randomRareLoot;
            console.log("You found a rare item!");
            console.log(characterBackpack);
        }
        else if (randomInteger==1||5||9) {
            characterBackpack+randomLoot;
            console.log("You found a item!");
            console.log(characterBackpack);
        }
    }
    
  6. Hey everyone I'm a Website Designer and would like to expand to a developer. I just recently started learning some PHP coding and I'm currently working on a login script which I'm not doing too bad at.

     

    I love coding HTML/CSS much more than designing websites so I figured development was my better option for a career. I currently go to Full Sail University, I just started, But I will be learning alot more javascript and PHP.

     

    My main question is, What exactly can I do with PHP? I know I can do simple things like login scripts and posting info to a database. But what are some more advanced things I can learn where I will excel in development when I start my first job?

     

    Thanks everyone!

  7. I'm trying to figure out what these examples of code are called?

     

    "DB()"

    "connect()"

     

    I don't believe they are variables because they are not defined anywhere in another part of a script. I'm also wondering if someone knows where I can find a list of all of these so I get a better understanding of all the functions of php.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.