Randomly selecting a global variable

For questions about using Classic.

Post » Thu Apr 08, 2010 7:01 pm

[quote="Silent Cacophony":2vum4eem]While using an expression would be nice if you have a large number of variables to work with, I'm not able to get Construct to allow me to do that...[/quote:2vum4eem]Check your PM.
B
2
S
2
G
4
Posts: 259
Reputation: 1,968

Post » Fri Apr 09, 2010 2:41 am

[quote="Silent Cacophony":1itc0ef0]While using an expression would be nice if you have a large number of variables to work with, I'm not able to get Construct to allow me to do that...

Anyway, simple conditional statements would be fine in most cases. Here's a quick .cap with an example (made with v0.99.84): Random Global

Also, here is a good page of the wiki to know of, if you don't:

http://sourceforge.net/apps/mediawiki/c ... xpressions

It explains things like the Random() function.[/quote:1itc0ef0]


Thank you all, it works perfectly for my item system and I understand how to implement it properly within Construct.
B
8
S
1
G
2
Posts: 79
Reputation: 1,108

Post » Sat Apr 10, 2010 4:39 am

I am encountering a problem where "1" is added to a global variable constantly instead of just once. Below is the code:



Whichever Randvar gets "1" added to it, constantly has 1 added to it all the time, increasing its value. I am probably missing something easy, thank you again!
B
8
S
1
G
2
Posts: 79
Reputation: 1,108

Post » Sat Apr 10, 2010 8:39 pm

Hi. The reason that 1 is being constantly added to one variable is that you have the Random Var group of events executing every tick, instead of as a sub-event of the TreasureChest group. If you drag the Random Var group up to the bottom of the shaded area under event 47, it should indent the group to the right a bit, making it a sub-group. Then it will only execute when a chest is touched.

Also, it should be noted that the global variables are being incremented each time that group is executed, so the Var Gold event and the other 3 like it will not work properly after the first time that their respective variables are incremented, because they are checking for a value of one.

One way to remedy that is to set the global variables to 1, instead of adding to them, but you'd still have to set them back to zero after the action is taken on them, or you'd end up with the same problem as you have now, basically.

From what i can see of the event sheet, it looks to me like you may not need the global variables at all. you could just move the actions taken in event 52 to the actions for event 48, and so on for the rest.
B
3
S
2
G
2
Posts: 187
Reputation: 1,449

Post » Wed Apr 14, 2010 7:25 am

Thank you very much!
B
8
S
1
G
2
Posts: 79
Reputation: 1,108

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests