Thanks to everyone who gave me advice in my previous posts. But I still need help. ->Click here for my code<-
I need some serious help, all of a player’s info in my game is stored in the variables near the top of the script. But when the ‘save’ button is clicked, I get an error saying that the variables are not defined. What am I doing wrong?
I seem these variables are disposed after constructing objects.
how about code below ?
// Creates a new PlayerData instance
var PlayerData = function (entity) {
this.entity = entity;
// Player Stats and general information:
this.PlayerName = 'no name';
this.PlayerStrength = 1;
this.PlayerDefense = 1;
this.PlayerLevel = PlayerStrength + PlayerDefense;
// The variables for the items in the player's inventory:
// hum, it seems u should use Array for InventorySlot...
this.InventorySlot1 = 'no item';
this.InventorySlot2 = 'no item';
this.InventorySlot3 = 'no item';
this.InventorySlot4 = 'no item';
this.InventorySlot5 = 'no item';
this.InventorySlot6 = 'no item';
// The variables for the armor the player is wearing:
this.ArmorHead = 'no item';
this.ArmorBody = 'no item';
this.ArmorLegs = 'no item';
this.ArmorFeet = 'no item';
};
later on I will make the game multiplayer. Will this code work in a way to where the player’s inventory items are only in that player’s invenotry slots? Or will this effect all players?