Z's learning Construct thread

For questions about using Classic.

Post » Mon Jul 05, 2010 7:21 am

Well, you can access private variables from python only with objects that have been recompiled since the fix was added. Initial tests show that accessing private variables in python work in version 99.9 with Sprite, Panel, 3dObject and Light. However it doesn't work with Text, Canvas, 3dBox or TiledBackground. So private variable access from python is about halfway there.
B
79
S
24
G
52
Posts: 4,724
Reputation: 39,711

Post » Tue Jul 06, 2010 3:53 am

Made good progress today :)

The only thing I'm having trouble with is the SpriteFont plugin's edit box. I can get SpriteFont to display text no problem, but I'm not getting anything at all when trying to use the edit box. Maybe it's late and I'm not thinking clearly. Could someone give me a quick rundown on how you'd normally set one up, or maybe a sample cap file please? I've been at it for over an hour, and have yet to even see it do anything at all.

Thanks !
B
3
G
2
Posts: 35
Reputation: 745

Post » Tue Jul 06, 2010 2:53 pm

Spritefont is unstable and unfinished. I wouldn't recommend using it in a serious project, as there are many random and obscure bugs with it.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Tue Jul 06, 2010 3:18 pm

Ahh, ok. Anything else out there that has more features than the standard edit box?
B
3
G
2
Posts: 35
Reputation: 745

Post » Sun Jul 11, 2010 4:00 am

It would appear that I cannot set the color filter on an object during the same tick that it has been created? If I put the code for it right after the creation code, it doesn't work. If I put the same code in a button, it works fine.

Any ideas on how to solve this without gimicky bandaid code?

Thanks,
Z
B
3
G
2
Posts: 35
Reputation: 745

Post » Sun Jul 11, 2010 4:47 am

Objects are not fully created until the end of the event sheet. You only have been the event that the object was created in to modify anything about it until the next tick.

event one
conditions
- Create object sprite
- set sprite color filter

event two
- set sprite angle

In this example, the sprite would have its color filter set but its angle would not be set until the next tick.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Sun Jul 11, 2010 3:12 pm

Okay, well then I'm going to have to find a way to make it happen after the first tick, because I need to color filter several objects that are created at once, based on each player's number.

As you can see with the example below, only one of the sprites is being colored.
[url:112enuaj]http://dl.dropbox.com/u/6365460/colorfilters.cap[/url:112enuaj]

What I'm doing is, upon network connection, each client that connects to the server is given a unique number. After that, a random start position on the map is chosen for that player, and a starting building and harvesters are created. Rather than have to draw each color of each unit and building, I drew them all white, with the intention of using the color filter to apply colors after creation.

Any ideas?

EDIT: I made a 'only trigger once' event, based on whether or not the player has a number assigned yet, and moved it above the section that creates the sprites, so that it triggers on the second tick after creation. It works, but I'd still like to get that code out of the main loop.

Thanks,
Z
B
3
G
2
Posts: 35
Reputation: 745

Post » Sun Jul 11, 2010 6:51 pm

In your example only the last sprite is getting colored because only the most recently created sprite gets picked. So the trick is to assign a color filter as the sprites are created.

Here are two different ways to do it:
[code:3bh1xu44]+ Button: On Button clicked
-> System: Create object Sprite on layer 1 at (100, 100)
-> Sprite: Set filter to cyan
-> System: Create object Sprite on layer 1 at (250, 100)
-> Sprite: Set filter to cyan
-> System: Create object Sprite on layer 1 at (400, 100)
-> Sprite: Set filter to cyan
[/code:3bh1xu44]
[code:3bh1xu44]+ Button: On Button clicked
+ System: For "" from 1 to 3
-> System: Create object Sprite on layer 1 at ({100, 250, 400}@LoopIndex, 100)
-> Sprite: Set filter to cyan[/code:3bh1xu44]
B
79
S
24
G
52
Posts: 4,724
Reputation: 39,711

Post » Sun Jul 11, 2010 7:54 pm

Ok, that I can handle.

Next, I've got some python script for network communication directly after an object's creation. The code runs, but the same problem seems to be coming up here now, too. The variables for the object don't exist yet because the object was just brought into existence.

I need to transmit the x/y location, its uid, and some private variables about its creation. Rawr. This is being more difficult than I expected.

EDIT: I can set a text box to show the value of the created object's UID, but the python script throws an error on any variable I try to access about it until the next tick. Hmm..

EDIT2: It appears that the python script is running before the other actions in the event. I set the value of a text box to the x/y location of the created object. After that I have a python script trying to read those values. When run, the python error pops up before the text box shows the x/y locations.

Here's an example CAP to show what I mean: [url:28o5hlnw]http://dl.dropbox.com/u/6365460/pythonproblem.cap[/url:28o5hlnw]

If this is a limitation of the interface, I can live with that, I just need to figure out a reasonable work around. I had written down 28 different kinds of units I planned on making, so hopefully whatever it is won't be too long or complicated.
B
3
G
2
Posts: 35
Reputation: 745

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest