Python EOL Error on leveleditor

For questions about using Classic.

Post » Thu Jul 28, 2011 6:00 pm

I need an external python file because I'm making a leveleditor where people can change things.
I use CreateByName to load objects and substrings for their position, layer etc.
I have a few questions:

1. Why can I not use \ on the end but I have to load it in "textman" wich is a rename from Textmanipulator? (EOL error)

2. Why can't I insert the 3d box object in my application if this script is executed? (EOL error)

I don't know much about python.


---

path = System.apppath+"Data\Levels";
file = "level1"
ext = "txt"

if ListBox.GetCount == 0:
textman.SetString("\ ")
ListBox.Load(path+textman.GetLeft(1)+file+"."+ext)
l = 1

for i in range(0, ListBox.GetCount+1):
if i <= ListBox.GetCount+1:
if l == 1:
   textman.SetString(ListBox.LineText(i))
   # sub string 1 to 4 (name, layer, xPos, yPos)
   System.CreateByName(textman.GetSubstring("'",1),textman.GetSubstring("'",2),textman.GetSubstring("'",3),textman.GetSubstring("'",4))
if i == ListBox.GetCount:
if l == 1:
   msgbox.SetIcon(1)
   textman.SetString(file)
   textman.Uppercase()
   msgbox.MessageBoxID("File Loaded",textman.GetString+" Sucessfully Loaded", 1)
   l = 0
   break
B
18
S
4
G
1
Posts: 413
Reputation: 2,512

Post » Thu Jul 28, 2011 6:53 pm

Python always checks for escape sequences, which start with a backslash (e.g. \n for newline). To be able to use the backslash as a char just double it (e.g. "myfolder" + "\\", becomes "myfolder\").
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Thu Jul 28, 2011 7:02 pm

[QUOTE=tulamide] Python always checks for escape sequences, which start with a backslash (e.g. \n for newline). To be able to use the backslash as a char just double it (e.g. "myfolder" + "\\", becomes "myfolder\").[/QUOTE] It works perfectly. I thank you for that.
But now, when I add a 3D box to the canvas, i get this error:
--
File "<string>", line 739
class 3DBoxInstance:
    ^
SyntaxError: invalid Syntax.

and
--
Trackeback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'System' is not defined
B
18
S
4
G
1
Posts: 413
Reputation: 2,512

Post » Thu Jul 28, 2011 7:24 pm

You need to rename the 3dbox object so it's name does not start with a number.
B
79
S
24
G
53
Posts: 4,735
Reputation: 40,233


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests