Action "Set value" problem

0 favourites
  • 7 posts
From the Asset Store
11 loops of RPG, chiptune/8-bit music. Suitable for any pixel art game.
  • Hello Construct 2 community,

    I'm a beginner using Construct 2 and I'm currently following the tutorial "How to make a Platform game" by Ashley. I have stumbled upon a problem though, to which I couldn't find a solution yet.

    I'm trying to make the enemy move left and right to "edge markers". To do this, one of the steps is to use the action "Set value to "left"". But it's not working for me properly, it says it's an invalid value.

    This is how it's described in the tutorial:

    <img src="http://img853.imageshack.us/img853/7188/gqr2.png" border="0" />

    This is my situation:

    <img src="http://img802.imageshack.us/img802/6948/vg0q.png" border="0" />

    Can somebody help me out here? I would really appreciate it!

  • You probably missed this:

        Set the name to action, the type to text...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You probably missed this:

        Set the name to action, the type to text...

    I'm highly unsure what you mean by that... I can't type in "action to left" into the value, if that's what you mean. In the tutorial it says I have to enter "left" into the value section, but it says it's invalid for some reason. I would have to insert int() or float() to it, so it says... but It's not described this way in the tutorial.

  • Sorry, too little context. This is from the tutorial:

    A dialog listing all instance variables for the object appears. Click the 'add' icon to add a new one. Set the name to action, the type to text, and the initial value to right (for moving right).

    'action' should not be an int, it should be text.

  • I think you need to go through the manual and read up on the basics. Your problem is inherently the lack of understanding Object types.

    C2 is a wonderful tool that makes development a breeze. It is however not a magical tool. Principle understandings are still a requirement. Knowing the difference from a Number and a String is really required.

    The code you present has a problem.

    an int or INTEGER is a number range with no decimal place. Where as "LEFT" is a String and is not composed of any number what so ever. So it is impossible to result an int("left") to have any value that isn't 0; as 0 is the default to any failed math expression.

    int, number with no decimal. 1

    float, number with decimal; including 1.0.

    string, any set of characters including a numeral as a character(not a number). "abc76" is a string

    scirra.com/manual/65/project-primitives

  • Just go to your instance variable and edit it so the type is Text rather then Number. That should fix your issue.

  • Thanks for all of your responses! Yes, I didn't pay attention and forgot to set the type of the instance variable to text. Instead I had it to Number.

    Once again, thank you for passing the knowledge.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)