Jump to content

Math error undefined


jburridge
Go to solution Solved by requinix,

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);
    }
}
Edited by jburridge
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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