[SUGGESTION]More data types for the variables

Discussion and feedback on Construct 2

Post » Wed Oct 30, 2013 1:50 pm

It would be great if you could add some possible data types for the variables. What I miss the most is:

*Boolean
*Object
*One dimensional array
[edit]
* a variable that can store a reference to a sprite instance (I know this might be tricky)
* the possibility to scope the variable for only the current event sheet (private, public)
* A true composite object, like the movie clip in flash (tricky as well...)
[/edit]

Thank you! jeansson2013-10-31 07:23:29
B
7
S
1
Posts: 22
Reputation: 526

Post » Wed Oct 30, 2013 2:02 pm

You might find it advisable to read the manual. For instance, THIS SECTION deals with Boolean variables.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
136
S
31
G
87
Posts: 5,498
Reputation: 60,282

Post » Wed Oct 30, 2013 2:06 pm

I've read it, boolean is not exposed in the event sheet interface. I know there is array and dictionary but I think it would be easier to just be able to create them as ordinary variables.

Just my thoughts.
B
7
S
1
Posts: 22
Reputation: 526

Post » Wed Oct 30, 2013 4:56 pm

[QUOTE=zenox98] You might find it advisable to read the manual. For instance, THIS SECTION deals with Boolean variables.[/QUOTE] While boolean are available for instance variables, they are not for globals. And I really wonder why. I know it's not a big deal to use an integer instead, but it kinda makes you scratch your head why they are available in one case and not the otherOlivierC2013-10-30 16:56:51
B
12
S
5
G
2
Posts: 132
Reputation: 2,637

Post » Wed Oct 30, 2013 6:49 pm

agreed Global Booleans should be available
B
37
S
9
G
5
Posts: 437
Reputation: 6,094

Post » Wed Oct 30, 2013 7:09 pm

Not sure why we have booleans at all, really. Toggling seems to be their only use and you can do that with normal vars and a single event as well.

Also a string can essentially be a 1-dimensional array.
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Wed Oct 30, 2013 7:21 pm

For arrays you can pass them by there UID.

Put all your arrays in a family and then pass the UID as a parameter. When your in the function pick the instance of the family by uniqueUID and fill in Function.Parameter(0), or whatever index it is, for the expression.

*Edit

Booleans are most used when returning True or False values. A global boolean wouldn't really be useful because it's not connected to anything.

Example: "Is the character moving?" Return Boolean: True (yes) or False (no)

If the boolean is global it is just floating out there by it self and referencing nothing.Xerullian2013-10-30 19:27:35
"In truth we live, In Truth we die"
B
11
S
3
G
4
Posts: 22
Reputation: 3,177

Post » Wed Oct 30, 2013 7:42 pm

I remember reading one of Ashley's comments saying that global booleans are on his todo list, so it's not off their radar.
B
19
S
6
G
2
Posts: 57
Reputation: 2,524

Post » Thu Oct 31, 2013 7:21 am

Well, I think there is a big difference in using 1 and 0 instead of a boolean. By using the correct data type we have type safety which makes it impossible to use the boolean as anything else, e.g. assigning it a 2 by mistake. It gets a lot clearer for you or any of your colleagues what you are trying to do and you don't need to use hungarian notation to explain the purpose of the variable. Nice to read that they are planning it for the future.

As with using strings like arrays, it's the same thing here. Also for an array you would want to pop, push and slice, and event though it already exists as an object I think it would be clearer and nicer to be able to declare it as a variable.

Some other features I thought of:

* a variable that can store a reference to a sprite (I know this might be tricky)
* the possibility to scope the variable for only the current event sheet (private, public)
B
7
S
1
Posts: 22
Reputation: 526

Post » Thu Oct 31, 2013 7:36 am

A slight workaround...

In my projects I create two constant vars one called FALSE set to 0 and another called TRUE set to 1

This means when I'm using global/local vars that technically are acting as Boolean values my code is easier to read and understand
B
8
S
3
G
1
Posts: 34
Reputation: 1,395

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 4 guests