Jump to content

Math error undefined


jburridge

Recommended Posts

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);
    }
}
Link to comment
https://forums.phpfreaks.com/topic/285425-math-error-undefined/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.