[SUGGESTION]More data types for the variables

Discussion and feedback on Construct 2

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

Post » Thu Oct 31, 2013 2:02 pm

You can store references to objects by storing a UID in a number variable.

Put a data storage object like Array or Dictionary in a container with another object, and you also get a separate storage for each individual object. So you can get per-object multi-dimensional arrays this way.
Scirra Founder
B
387
S
230
G
87
Posts: 24,249
Reputation: 192,240

Post » Thu Oct 31, 2013 3:43 pm

[QUOTE=Ashley] You can store references to objects by storing a UID in a number variable.

Put a data storage object like Array or Dictionary in a container with another object, and you also get a separate storage for each individual object. So you can get per-object multi-dimensional arrays this way.[/QUOTE]

Wow, going to try that now :)
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Sun Dec 01, 2013 3:41 am

I agree with Jeansson.
A variable that can hold an object could come in handy in different situations.

Creating an object by UID is not possible as far as I know.
A possible use case is what I'm trying to accomplish in my current project:

I create 1 or multiple decks of cards, each card consists of a background, value, suit and face sprite.
This reduces file size considerably and offers much more flexibility in animating etc.
Now, I want the user to be able to choose different skins for the game. Instead of having to duplicate the function that creates the deck for each different skin, a variable referencing an object in the projectbar passed on to the function would do the trick.

Being able to create an object dynamically by string/name or UID would make that possible too. But another variable type for e.g. sprite/audio etc would be the best and would open up many more possibilities.
Moongaze2013-12-01 03:48:55
B
8
S
2
Posts: 26
Reputation: 604

Post » Sun Dec 01, 2013 5:12 pm

A little thing in regards to this topic i wanted to request/say.

Could we have local variables for event sheets, instead of just groups/separate events? I made a post about this here, but it appears that it got buried. Just wanted to hear your thoughts about this.
B
10
S
1
Posts: 163
Reputation: 1,436

Post » Sun Dec 01, 2013 5:16 pm


eh. Don't need Sheet Boolean.
If( bool != 0) there you go. boolean check
or
if (bool == 0) just make sure your if check is explicit for 0.
Though it is weird that it's not there.

Scope. Create a Group for the Event sheet. Everything goes into the group including the variable. This of course is private. However if you need public it's the strict OOP design model then. use getters/setters to set the group vars.

How about this suggestion. Baking in the Function plugin.
Having to use Function.Call("function_name") is a pain.
New variables are baked in to the drop down list and checked in the expression lines. Why can't Functions be built in :)
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,013

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: mammoth and 10 guests