get python picking plugin for 99.5/99.6/99.72 here

New releases and general discussions.

Post » Sat Jan 02, 2010 3:36 pm

[quote="R0J0hound":3chu1h2w]First: thanks Lucid, Now I know how to access different instances of objects in python.
Second: Madster, yes you can import python libraries just add an action like this:
[code:3chu1h2w]System: Run Script("import math")[/code:3chu1h2w]
Then retrieve some function later like:
[code:3chu1h2w]Text: Set text to Python("math.pi")[/code:3chu1h2w]

[/quote:3chu1h2w]

Has anyone gotten external libraries to work with Construct? I have tried a couple times before with no luck. I'm talking about libraries that are not part of the built-in Python 2.6 libraries.

Thanks Lucid for the fix... this is really nice work.
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Sat Jan 02, 2010 5:03 pm

[quote="scidave":1os633cy]Has anyone gotten external libraries to work with Construct? I have tried a couple times before with no luck. I'm talking about libraries that are not part of the built-in Python 2.6 libraries.[/quote:1os633cy]
I have! Just last night I did a test to get an external library up and running, and managed to do that just fine - I installed Beautiful Soup, a HTML parser, and it worked just fine in Construct using the following code:

[code:1os633cy]from BeautifulSoup import BeautifulSoup
import re

doc = ['<html><head><title>Page title</title></head>',
'<body><p id="firstpara" align="center">This is paragraph <b>one</b>.',
'<p id="secondpara" align="blah">This is paragraph <b>two</b>.',
'</html>']
soup = BeautifulSoup(''.join(doc))
prettysoup = soup.prettify()

Text.SetText(prettysoup)
[/code:1os633cy]

So external libraries should work just fine (though not graphical libraries for obvious reasons).
B
16
S
8
G
4
Posts: 136
Reputation: 3,144

Post » Sat Jan 02, 2010 6:33 pm

@Diaz You are awesome!! That gave me enough motivation to try again to figure out why my example wasn't working. For whatever reason when I was instantiating a PyAiml object using k=aiml.kernel (), I was not getting any return value when printing it out. I normally get a return value when printing from a regular python program. So I went back and looked at my example and tried casting the output k as a string str(k). Sure enough that did the trick and now it is working.

I kinda feel like an idiot thinking all along it was not working... but this just made my day!

Edit: Just tried to build an .exe and I get an error message popup from your example and my code. Do you have the same problem?
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Tue May 31, 2011 6:56 am

Hey.. Can't [code:wh3tx9c3]
py.GetSOL("object name here")[/code:wh3tx9c3]
instead of a object name, use:
[code:wh3tx9c3]

name=Sprite
py.GetSOL(name)[/code:wh3tx9c3]

When I do this, The game crashes.. any solution?
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Tue May 31, 2011 6:59 am

This method is obsolete.

instead of
py.GetSOL("Sprite")
use
SOL.Sprite
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Previous

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 3 guests