Function parameter limit?

For questions about using Classic.

Post » Sat Mar 17, 2012 5:29 pm

Why don't you do this in python? It's a lot more readable, especially if there are plenty of attributes.

If you are not familiar with python, I can help if you want.
B
10
S
6
G
3
Posts: 127
Reputation: 2,481

Post » Sat Mar 17, 2012 5:55 pm

I forget Python exists. I don't know it, but it seems real simple if combined with Construct.

How is it, speed-wise, to use a bunch of Python? Like if I made almost the whole behavior of a sprite in it and used as a script.
B
5
S
2
G
3
Posts: 234
Reputation: 1,818

Post » Sat Mar 17, 2012 6:03 pm

python is almost the same speed, at least in some tests I tried a long time ago, and python also has it's share of quirks. if I had more time I'd volunteer, there might be another plugin coder who'd volunteer, though. For large projects, especially ones where I have some complex sequence of events I would use over and over. I make a custom plugin to do that one thing.
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Sat Mar 17, 2012 6:04 pm

Yea, I do the same thing for effects in my game konjak, however I'm still using version 99.72. I just tested it in 99.72 and it's the same result; it seems this is a bug that has been there forever (ie, wasn't introduced with the new function object changes).

I don't really know how stable the python features are, I've never used them extensively.

This bug is pretty important to fix.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Sat Mar 17, 2012 6:26 pm

Yeah, python is the same in most of the cases, and if you don't use a function in every tick it's basicly up to you to wich one to use - I usually prefer python, unless I have to create something really quickly.

If you are not experienced in python, just send me the cap, I can take a look at it later.
B
10
S
6
G
3
Posts: 127
Reputation: 2,481

Post » Sat Mar 17, 2012 6:51 pm

Could you possibly just give me an example of how I'd through a function create a sprite and then instantly set its variables, though?

Construct is pretty picky about defining variables in the same event, or sub-events, of where you created the sprite...konjak2012-03-17 18:51:26
B
5
S
2
G
3
Posts: 234
Reputation: 1,818

Post » Sat Mar 17, 2012 7:50 pm

You can create objects like this
System.CreateByName("<sprite's\object's name", layer_num, x pos, y pos)

after that you can set it's variables like this
SOL.<sprite's\object's name>.SetValue('<value's name>', <the value>)

SOL stands for selected objects list, it picks the last created object in this case.
So your python function should look like this:

def create_sprite(layer, x, y, var1, var2):
     System.Create("Sprite", layer, x, y)
     SOL.Sprite.SetValue('a', var1)
     SOL.Sprite.SetValue('b', var2)
etc
and if you want to call it just insert this line under an event
create_sprite() - and fill the values of course.
You can set default values, so if you mostly use a specific layer, variables, etc, than you don't have to specify them over and over, just rewrite the original function like this
def create_sprite(layer = 1, x = 0, y = 0, var1 = 40, var2 = 20)

In this way you can spawn another instances by typing just create_sprite().
B
10
S
6
G
3
Posts: 127
Reputation: 2,481

Post » Sat Mar 17, 2012 7:53 pm

Thanks for that!

Just a question though, is Python not any good at all for every tick? Because this seemingly simple code I tried to make completely devestates my game's FPS in Unlimited. The actual code is 8 lines and dropped 900 FPS to 800, then I copied it to make up 118 lines and it's down to 200.

Am I just missing something? Thread's a bit derailed I guess!
B
5
S
2
G
3
Posts: 234
Reputation: 1,818

Post » Sat Mar 17, 2012 8:02 pm

sorry, my mistake, you only need to define the function at start, after that you shouldnt have any performance issues.
B
10
S
6
G
3
Posts: 127
Reputation: 2,481

Post » Sat Mar 17, 2012 8:10 pm

Well, with a defined function for it instead it still runs awful (this is me trying to replace some events, not make effects), but I'm thinking that maybe you can't really test performance of Python in that way in Unlimited? Like it will be far too demanding to reference that code so fast, but in normal speeds it's perfectly fine?

Hard to explain.
B
5
S
2
G
3
Posts: 234
Reputation: 1,818

PreviousNext

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests