I have lately been looking at questions asked by people who have been using Squiffy to create their projects. It seems that Objects are the hot topic of the week. My question can be viewed here. Simply copy and paste into the Squiffy Scratchpad (http://docs.textadventures.co.uk/squiffy/scratchpad/):
function item(name, amount, type, returnAmount, descri){
this.name = name;
this.itemAmount = amount;
this.type = type;
this.returnVaule = returnAmount;
this.description = descri;
}
function person(name, hp, dex, str){
this.name = name;
this.healthPoints = hp;
this.dexPoints = dex;
this.strPoints = str;
}
var self = new person("You", 10, 5, 5)
var other = new person("Other Guy", 20, 8, 8)
var healthPotion = new item("Health Potion", 0, "potion", 5, "Heals you for five health points")
var strengthPotion = new item("Strength Potion", 0, "potion", 3, "Adds three points of Strength for one point of Dexterity")
[Test]
[Test]:
@clear
Viewing the this.name of self variable:
[View](V1)
Viewing the this.healthPoints of self variable:
[View](V2)
Viewing the two variables together:
[View](V3)
[V1]:
alert(self.name)
[V2]:
alert(self.healthPoints)
[V3]:
@clear
alert(self.name + " have " + self.healthPoints + " Health Tokens.")
How can I get self.name to appear here?