Squiffy: Interaction between objects

–1 vote
148 views
asked May 29 in Authoring by anonymous
edited May 31

Hello I am creating a proof of concept of a battle system. I am curious about how to extract the values of the subnames. Seen here.

    function item(name, amount, type, return, descri){
    this.name = name;
    this.itemAmount = amount;
    this.type = type; 
    this.returnVaule = return; 
    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", potion, 5, "Heals you for five health points")

var strengthPotion = new item("Strength Potion", potion, 3, "Adds three points of Strength for one point of Dexterity")
[Test]

You have {self.healthPoints} health points.

Here are the errors I am getting:
Uncaught SyntaxError: Unexpected token return
at Object.InjectedScript.evaluateOn (:895:140)
at Object.InjectedScript.
evaluateAndWrap (:828:34)
at Object.InjectedScript.evaluate (:694:21)

1 Answer

+1 vote
answered Jun 4 by Alex (486 points)

I have no idea what you're trying to do here, but as I've written in another answer: You need to store data using attributes. In your example, you're only setting local variables. These will be discarded as soon as the script block finishes running.

This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...