External Python Scripting?

For questions about using Classic.

Post » Fri Dec 24, 2010 10:32 pm

How can I have construct call external scripts from a folder? I thought this would be a cool idea for modding. Also, while we are on the topic of folders, how do get the game to read the folders in the apppath? I.e. [code:2jkarqgx]%AppPath% & "scripts\gameplay\wakawakawaka.py"[/code:2jkarqgx] Or something like that?

Also, A video I uploaded not to long ago about the said game I am working on.

http://www.youtube.com/watch?v=NjsyoKF1-2k
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Fri Dec 24, 2010 10:44 pm

Python has an exec statement that does that:
[code:2w8c0vef]exec System.AppPath + r'scripts\gameplay\wakawakawaka.py'[/code:2w8c0vef]
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Sat Dec 25, 2010 4:38 pm

[quote="R0J0hound":3dbduc55]Python has an exec statement that does that:
[code:3dbduc55]exec System.AppPath + r'scripts\gameplay\wakawakawaka.py'[/code:3dbduc55][/quote:3dbduc55]

Thank you. Now to learn python. xD
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Sat Dec 25, 2010 5:09 pm

I'm not sure but I think the system object has a call for that too.
+ System: Start of layout
-> System: Run Script ("")
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Mon Nov 21, 2011 8:46 pm

Old thread, but i need help. When i try executing python code through exec it gives me syntax error.

i used exec(System.AppPath + 'Data\py\array.py')


to exute this file in Data\py\
called array.py
Urled2011-11-22 15:44:29
B
18
S
4
G
1
Posts: 413
Reputation: 2,512

Post » Mon Nov 21, 2011 8:50 pm

From rojohounds example it is the same error:

B
18
S
4
G
1
Posts: 413
Reputation: 2,512

Post » Mon Nov 21, 2011 9:18 pm

Try
execfile(System.AppPath + 'Data\py\array.py')
or
exec(open(System.AppPath + 'Data\py\array.py'))
instead.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests