Action "Set value" problem

Get help using Construct 2

Post » Sat Nov 02, 2013 8:31 pm

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:


This is my situation:


Can somebody help me out here? I would really appreciate it!DigitalGreenTea2013-11-02 20:48:30
B
8
Posts: 7
Reputation: 378

Post » Sat Nov 02, 2013 8:37 pm

You probably missed this:

    Set the name to action, the type to text...
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Sat Nov 02, 2013 8:47 pm

[QUOTE=blackhornet] You probably missed this:

    Set the name to action, the type to text...[/QUOTE]

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.DigitalGreenTea2013-11-02 20:48:16
B
8
Posts: 7
Reputation: 378

Post » Sat Nov 02, 2013 9:16 pm

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.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Sat Nov 02, 2013 9:18 pm

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

https://www.scirra.com/manual/65/project-primitives
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,018

Post » Sat Nov 02, 2013 9:27 pm

Just go to your instance variable and edit it so the type is Text rather then Number. That should fix your issue.
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,986

Post » Mon Nov 04, 2013 7:19 pm

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.
B
8
Posts: 7
Reputation: 378


Return to How do I....?

Who is online

Users browsing this forum: karthikavnair, OBLIVION, unicornspitfire and 13 guests