Issue with function parameters

Get help using Construct 2

Post » Fri Aug 12, 2016 9:41 pm

Got a shooting system working, uses 13 parameters so I wrapped it up with a function instead of using another dozen of instance variables (do not know if this is a good idea). Works if it is given numbers, but it does not if given function.param(number). I've read both entries in the manual and looked around, but I cannot figure it out.

I'd appreciate any help!

Capx: https://www.dropbox.com/s/jp6a7sn0w37bu ... .capx?dl=1
B
9
S
3
Posts: 150
Reputation: 1,264

Post » Fri Aug 12, 2016 9:47 pm

You shouldn't use Wait in a function, as the function will return immediately, and the parameters are lost. A Timer is the better way to do this.
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Fri Aug 12, 2016 9:55 pm

Ugh... The point of the system was to avoid creating more instance booleans/variables and make it compact. Isn't there a more clean workaround? Making a timer seems messy. I'll try it out, anyway. Thanks, @blackhornet
B
9
S
3
Posts: 150
Reputation: 1,264

Post » Fri Aug 12, 2016 9:59 pm

This is what I meant to do (I did it quite a while ago, but it works), with parameters instead of instance variables.
Image
B
9
S
3
Posts: 150
Reputation: 1,264

Post » Fri Aug 12, 2016 10:01 pm

That's what instance variables do - I don't know why you are fighting it.
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Fri Aug 12, 2016 10:06 pm

Wouldn't having 20+ instance variables in 50+ instances constantly changing affect performance? This method made it more compact to design weapon stats too, but oh well ~
B
9
S
3
Posts: 150
Reputation: 1,264

Post » Fri Aug 12, 2016 10:23 pm

But those values have to exist somewhere, and I'd think passing 13 parameters to a function call would be more time consuming than accessing preallocated memory values. Seems like a minor thing to worry about.

https://www.scirra.com/blog/83/optimisa ... -your-time
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Fri Aug 12, 2016 10:55 pm

CloveltOc wrote:Wouldn't having 20+ instance variables in 50+ instances constantly changing affect performance? This method made it more compact to design weapon stats too, but oh well ~


Absolutely not at all
B
83
S
22
G
15
Posts: 1,039
Reputation: 15,219


Return to How do I....?

Who is online

Users browsing this forum: Rudi55 and 6 guests