variables in RTS game

Get help using Construct 2

Post » Sun Mar 16, 2014 8:30 pm

CASE: In a game (rts type) where I am designing building/resources: mine (ore), mine (iron), etc... I can work with global variables for: mine or building level, resources quantity, etc...

But the problem is for each new building or resource as we have to introduce the value of variables one to one. This is a waste of time...

I want do it with arrays, but as you know, the dialog of variables doesn't allow it. With arrays you can modify once instead of multiple times for each new building...

Image


What do you thinks about this? Any suggestion or other way to do this?
B
6
G
1
Posts: 15
Reputation: 405

Post » Sun Mar 16, 2014 9:44 pm

I can't help you but I am very interested, I hope experimented users will be able to help you...
B
17
S
5
G
2
Posts: 173
Reputation: 2,085

Post » Mon Mar 17, 2014 1:39 am

revived the post. I need to get to a solution.
B
6
G
1
Posts: 15
Reputation: 405

Post » Mon Mar 17, 2014 1:28 pm

@geometrix I'm sorry to bother you, but I could help.
B
6
G
1
Posts: 15
Reputation: 405

Post » Mon Mar 17, 2014 1:50 pm

I don't really get what you are trying to do, but if you just want to link a resource to a value like
metal: XXX
wood: XXX
cristal: XXX

why don't you use a dictionary? Try explaining again what you want to achieve, I might be able to help.
(please tag me in the response)
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Mon Mar 17, 2014 2:38 pm

@caiorosisca Thanks for wanting to help. Forgive me for my English.

I have to give a value to a variable, but this variable is selected from an Array

Now I have only 2 buildings. Glass and metal. So could do this

Image

but imagine you have 10, 20 or 60 different buildings.

I just want to assign a value to a variable without selecting literally

Image

have an alternative option to assign values ​​to variables.

Image
B
6
G
1
Posts: 15
Reputation: 405

Post » Mon Mar 17, 2014 2:45 pm

Have a look at this plugin: viewtopic.php?t=65765&start=0
You can use it like an associative array!
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Mon Mar 17, 2014 5:48 pm

Hmm, I don't think there's much you can do about it. If you need a variable for each resource you will need to do what you are currently doing.
I don't think I can help you, but I see no reason for not using a dictionary for it, it's organised and not a bad practice to do it like that.
Just pointing, even when you select the variable from the array you aren't referencing to it, just to the value.

var1 = 1;
Array> Set at XY> (0,0) var1; // here the value at array(0,0) is 1
var1 > set value> 2
//here var1 = 2, but array(0,0) is still 1
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643


Return to How do I....?

Who is online

Users browsing this forum: Fradno, marcinkowski, tarek2 and 9 guests