On Monday, April 8, 2013 7:43:19 PM UTC+9:30, Adam wrote:
>
> On 07/04/13 12:05, James Gangur wrote:
>
> Hello all. I'm not quite sure how to explain this, but this is what I am
> trying to do.
>
> In my game (an RPG), I have a system where entities can call scripts
> written in python. Here is said entity:
>
> class entity_still_runscript(entity_object):
>> def __init__(self, grid_x, grid_y, sprite, solid, hover_text, above,
>> extra):
>> entity_object.__init__(self, "still_runscript", grid_x, grid_y,
>> pyglet.sprite.Sprite(sprite), solid, hover_text, above)
>> self.script = extra.pop("script")
>> self.infodict = extra
>>
>> def select(self):
>> script = string_import("scripts."+self.script)
>> script.go(self.infodict, self)
>>
>
> All that should matter is that select will get called when the player
> tells it to.
>
> Next, here is the script that is getting called, sort of in pseudo code:
>
>
> #!/usr/bin/python
>> def go(infodict, parent):
>> >run some function that contains opengl calls
>> >wait until the told to continue by some other function
>> >continue with script
>>
>
> No, to try and do this, I was using the threading module to no success. I
> then found out (after much confusion) that opengl call can't be made from
> separate threads.
>
> I tried a ton of other (nooby) things, but could not achieve the desired
> result.
>
> How would I go about doing this?
>
> Have you looked at the coroutines of any kind? The simplest would be to
> have go() be a generator, ie use the yield keyword to return to the calling
> routine but save all the state in go for the next time you need to call it.
> Alternatively there are greenlets and one or two other libraries that might
> get you what you want or try stackless python.
>
Thanks! I've had a look at these now (I hadn't previously) and it looks
like I'm going to give greelets + concurrence a go. I've set them up, and
am going to have a play with them now. Thanks :-)
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.