Login
Remember
IF Answers
Ask a Question

# 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)

- squiffy

## 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.

## Related questions

- Squiffy: Extracting Data From Objects Variables.
- Random text in Squiffy
- Is there a way to turn Squiffy passage links into a regular link for accessibility purposes?
- Squiffy: Inserting images?
- Why does this Javascript not work in squiffy but will in a js editor

...