Python broken in a project (fixed)

For questions about using Classic.

Post » Thu Apr 29, 2010 2:32 pm

So it appears that Python is broken in a project I'm working on. I enabled scripting, and upon startup, I receive the following error message:

[code:2q97tc4w]File "<string>", line 2037
class 360Instance:
^
SyntaxError: invalid syntax[/code:2q97tc4w]

To clarify: I don't have anywhere near 2037 lines of Python in my project. Neither I have anything that would even remotely resemble class 360. I believe this is from Construct's internal Python code or something along the lines of that.

Anyway, after that, whenever I try to refer to any Construct objects in Python code, it gives an error like this:

[code:2q97tc4w]Traceback (most recent call last):
File "<string>", line 30, in <module>
NameError: name 'System' is not defined[/code:2q97tc4w]

Of course, the line number and name varies. No reference at any place works. Meanwhile, in other caps, everything works just fine and dandy. Everything Python that doesn't refer to Construct objects works just fine.

This is a serious showstopper for the project, since I really need Python and being unable to refer to anything means that I'm not able to do much with it. Any ideas how to fix this?
B
16
S
8
G
4
Posts: 136
Reputation: 3,144

Post » Thu Apr 29, 2010 6:47 pm

Do you have an object named "360"? If so you need to rename it so it doesn't start with a digit and it should work. Construct generates it's own python script on startup that builds an interface for each object, thus the 1027 lines.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Thu Apr 29, 2010 7:18 pm

I did, and renaming it fixed the problem! You, sir, are a lifesaver. Honestly.
B
16
S
8
G
4
Posts: 136
Reputation: 3,144

Post » Fri Apr 30, 2010 1:16 pm

How did you name an object "360"? Construct should prevent you giving objects names which are numbers, or starting with numbers, because it means you can't tell object names apart from numbers in expressions.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Fri Apr 30, 2010 3:04 pm

Don't know if this is the correct thread to be posting this in but anyway. The game I'm working on utilizes python scripting and for some odd reason when I have added a binary file to one of my Layouts the game suddenly stops working in the means of stuff in my python code doesn't work.

For instance I get the File "<string>", line xxxx def Get cursor position(self): SyntaxError: invalid syntax

and: Traceback (most recent call last): File "<string>", line 2, in <module> NameError: name "Sword" is not defined.

The "Sword" is a sprite. But when I remove the binary file object that I added to one of the layouts the problem goes away? Is this a bug I should report or is it known to happen that way?

Cheers!

P.S
I'm using Construct v0.99.84 (unstable)
Python version 2.6.5
B
1
G
2
Posts: 6
Reputation: 637

Post » Fri Apr 30, 2010 3:04 pm

[quote="Ashley":1d1r1ssx]Construct should prevent you giving objects names which are numbers, or starting with numbers, because it means you can't tell object names apart from numbers in expressions.[/quote:1d1r1ssx]Does this refer to objects only or function names, too?
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Fri Apr 30, 2010 4:53 pm

[quote="Ashley":26b6jnq5]How did you name an object "360"? Construct should prevent you giving objects names which are numbers, or starting with numbers, because it means you can't tell object names apart from numbers in expressions.[/quote:26b6jnq5]

Well, I just made an Xbox 360 Controller object, and renamed it 360. From the looks of it, I can rename anything to any number, though. Like renaming a gradient to 303882 works.
B
16
S
8
G
4
Posts: 136
Reputation: 3,144

Post » Fri Apr 30, 2010 7:49 pm

@1146Ullman
That is a known problem. The solution is not to use the binary object when using python. It's no loss because python can do everything the binary object can do and more.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Mon May 03, 2010 8:11 am

Good to know :)
B
1
G
2
Posts: 6
Reputation: 637


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests